@jaaq/jaaq-sdk-js 1.0.1 → 1.1.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.
Files changed (41) hide show
  1. package/README.md +733 -92
  2. package/dist/embed/embed-collection.html +275 -0
  3. package/dist/embed/embed.html +270 -0
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/jaaq-sdk.min.js.map +1 -1
  7. package/dist/ui/index.cjs +5051 -0
  8. package/dist/ui/index.cjs.map +1 -0
  9. package/dist/ui/index.d.ts +378 -0
  10. package/dist/ui/index.mjs +5044 -0
  11. package/dist/ui/index.mjs.map +1 -0
  12. package/dist/ui/jaaq-ui-bundled.min.js +8 -0
  13. package/dist/ui/jaaq-ui-bundled.min.js.map +1 -0
  14. package/dist/ui/jaaq-ui.min.js +8 -0
  15. package/dist/ui/jaaq-ui.min.js.map +1 -0
  16. package/dist/ui/react/index.cjs +4756 -0
  17. package/dist/ui/react/index.cjs.map +1 -0
  18. package/dist/ui/react/index.d.ts +182 -0
  19. package/dist/ui/react/index.mjs +4735 -0
  20. package/dist/ui/react/index.mjs.map +1 -0
  21. package/dist/ui/react/jaaq-ui-react.min.js +8 -0
  22. package/dist/ui/react/jaaq-ui-react.min.js.map +1 -0
  23. package/dist/ui/vanilla/index.cjs +5052 -0
  24. package/dist/ui/vanilla/index.cjs.map +1 -0
  25. package/dist/ui/vanilla/index.d.ts +465 -0
  26. package/dist/ui/vanilla/index.mjs +5044 -0
  27. package/dist/ui/vanilla/index.mjs.map +1 -0
  28. package/dist/ui/vanilla/jaaq-vanilla-bundled.min.js +8 -0
  29. package/dist/ui/vanilla/jaaq-vanilla-bundled.min.js.map +1 -0
  30. package/dist/ui/vanilla/jaaq-vanilla.min.js +8 -0
  31. package/dist/ui/vanilla/jaaq-vanilla.min.js.map +1 -0
  32. package/dist/ui/webcomponents/index.cjs +4619 -0
  33. package/dist/ui/webcomponents/index.cjs.map +1 -0
  34. package/dist/ui/webcomponents/index.d.ts +288 -0
  35. package/dist/ui/webcomponents/index.mjs +4614 -0
  36. package/dist/ui/webcomponents/index.mjs.map +1 -0
  37. package/dist/ui/webcomponents/jaaq-webcomponents-bundled.min.js +8 -0
  38. package/dist/ui/webcomponents/jaaq-webcomponents-bundled.min.js.map +1 -0
  39. package/dist/ui/webcomponents/jaaq-webcomponents.min.js +8 -0
  40. package/dist/ui/webcomponents/jaaq-webcomponents.min.js.map +1 -0
  41. package/package.json +42 -2
@@ -0,0 +1,275 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>JAAQ Embed Collection Player</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ html,
15
+ body {
16
+ width: 100%;
17
+ height: 100%;
18
+ overflow: hidden;
19
+ }
20
+
21
+ body {
22
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
23
+ background: #000;
24
+ }
25
+
26
+ #player-container {
27
+ width: 100%;
28
+ height: 100%;
29
+ }
30
+
31
+ jaaq-collection-player {
32
+ display: block !important;
33
+ width: 100% !important;
34
+ height: 100% !important;
35
+ }
36
+
37
+ jaaq-collection-player::part(container) {
38
+ height: 100% !important;
39
+ }
40
+
41
+ .error-container {
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ width: 100%;
46
+ height: 100%;
47
+ background: #1a1a1a;
48
+ color: #fff;
49
+ padding: 20px;
50
+ }
51
+
52
+ .error-content {
53
+ text-align: center;
54
+ max-width: 400px;
55
+ }
56
+
57
+ .error-content h1 {
58
+ font-size: 18px;
59
+ margin-bottom: 12px;
60
+ color: #ff6b6b;
61
+ }
62
+
63
+ .error-content p {
64
+ font-size: 14px;
65
+ color: #ccc;
66
+ line-height: 1.5;
67
+ }
68
+ </style>
69
+ </head>
70
+ <body>
71
+ <div id="player-container"></div>
72
+
73
+ <script>
74
+ function showError(message) {
75
+ console.error('[Embed Collection] Showing error:', message);
76
+ const container = document.getElementById('player-container');
77
+ if (!container) {
78
+ console.error('[Embed Collection] Container not found!');
79
+ return;
80
+ }
81
+ container.innerHTML = `
82
+ <div class="error-container">
83
+ <div class="error-content">
84
+ <h1>⚠️ Collection Player Error</h1>
85
+ <p>${message}</p>
86
+ </div>
87
+ </div>
88
+ `;
89
+ }
90
+
91
+ function getQueryParams() {
92
+ const params = new URLSearchParams(window.location.search);
93
+ const config = {};
94
+
95
+ const apiKey = params.get('apiKey');
96
+ const clientId = params.get('clientId');
97
+ const collectionId = params.get('collectionId');
98
+
99
+ if (!apiKey || !clientId || !collectionId) {
100
+ const missing = [];
101
+ if (!apiKey) missing.push('apiKey');
102
+ if (!clientId) missing.push('clientId');
103
+ if (!collectionId) missing.push('collectionId');
104
+ throw new Error(`Missing required parameters: ${missing.join(', ')}`);
105
+ }
106
+
107
+ config.apiKey = apiKey;
108
+ config.clientId = clientId;
109
+ config.collectionId = collectionId;
110
+
111
+ const autoplay = params.get('autoplay');
112
+ if (autoplay !== null) {
113
+ config.autoplay = autoplay === 'true' || autoplay === '1';
114
+ }
115
+
116
+ const baseUrl = params.get('baseUrl');
117
+ if (baseUrl) {
118
+ config.baseUrl = baseUrl;
119
+ }
120
+
121
+ return config;
122
+ }
123
+
124
+ function notifyParent(event, data) {
125
+ if (window.parent && window.parent !== window) {
126
+ window.parent.postMessage(
127
+ {
128
+ type: 'jaaq-collection-event',
129
+ event: event,
130
+ data: data,
131
+ },
132
+ '*',
133
+ );
134
+ }
135
+ }
136
+
137
+ function initPlayer() {
138
+ try {
139
+ console.log('[Embed Collection] Initializing player...');
140
+ const config = getQueryParams();
141
+ console.log('[Embed Collection] Config:', config);
142
+ const container = document.getElementById('player-container');
143
+
144
+ const player = document.createElement('jaaq-collection-player');
145
+ console.log('[Embed Collection] Created web component:', player);
146
+ player.setAttribute('collection-id', config.collectionId);
147
+ player.setAttribute('api-key', config.apiKey);
148
+ player.setAttribute('client-id', config.clientId);
149
+
150
+ if (config.baseUrl) {
151
+ player.setAttribute('base-url', config.baseUrl);
152
+ }
153
+
154
+ if (config.autoplay) {
155
+ player.setAttribute('autoplay', 'true');
156
+ }
157
+
158
+ player.style.width = '100%';
159
+ player.style.height = '100%';
160
+ player.style.display = 'block';
161
+
162
+ setTimeout(() => {
163
+ if (player.shadowRoot) {
164
+ const container = player.shadowRoot.querySelector('.jaaq-collection-player');
165
+ if (container) {
166
+ container.style.height = '100%';
167
+ container.style.display = 'flex';
168
+ container.style.flexDirection = 'column';
169
+ }
170
+ }
171
+ }, 100);
172
+
173
+ player.addEventListener('jaaq:collection:loaded', (e) => {
174
+ const collection = e.detail;
175
+ notifyParent('loaded', {
176
+ collection: {
177
+ id: collection.id,
178
+ name: collection.name,
179
+ description: collection.description,
180
+ },
181
+ videoCount: collection.videos?.length || 0,
182
+ });
183
+ });
184
+
185
+ player.addEventListener('jaaq:collection:slidechange', (e) => {
186
+ const { index, video } = e.detail;
187
+ notifyParent('slidechange', {
188
+ index,
189
+ video: video
190
+ ? {
191
+ id: video.videoId,
192
+ title: video.title,
193
+ question: video.question,
194
+ }
195
+ : null,
196
+ });
197
+ });
198
+
199
+ player.addEventListener('jaaq:collection:error', (e) => {
200
+ console.error('[Embed Collection] Player error event:', e.detail);
201
+ showError(e.detail?.message || 'Unknown collection error');
202
+ notifyParent('error', { message: e.detail?.message || 'Unknown error' });
203
+ });
204
+
205
+ window.addEventListener('message', (event) => {
206
+ if (event.data && event.data.type === 'jaaq-collection-command') {
207
+ const { command, args } = event.data;
208
+
209
+ switch (command) {
210
+ case 'next':
211
+ player.next();
212
+ break;
213
+ case 'prev':
214
+ player.prev();
215
+ break;
216
+ case 'goToSlide':
217
+ if (args && typeof args.index === 'number') {
218
+ player.go(args.index);
219
+ }
220
+ break;
221
+ case 'refresh':
222
+ player.refresh();
223
+ break;
224
+ case 'getCollection':
225
+ const collectionData = player.getCollection();
226
+ notifyParent('collection-data', { collection: collectionData });
227
+ break;
228
+ }
229
+ }
230
+ });
231
+
232
+ container.appendChild(player);
233
+ console.log('[Embed Collection] Player appended to container');
234
+ notifyParent('ready', null);
235
+ } catch (error) {
236
+ console.error('[Embed Collection] Initialization error:', error);
237
+ showError(error.message);
238
+ notifyParent('error', { message: error.message });
239
+ }
240
+ }
241
+
242
+ function waitForComponent() {
243
+ if (customElements.get('jaaq-collection-player')) {
244
+ console.log('[Embed Collection] Web component already registered');
245
+ initPlayer();
246
+ } else {
247
+ console.log('[Embed Collection] Waiting for web component registration...');
248
+
249
+ if (typeof JaaqWebComponents !== 'undefined' && JaaqWebComponents.registerJaaqComponents) {
250
+ console.log('[Embed Collection] Manually registering components...');
251
+ JaaqWebComponents.registerJaaqComponents();
252
+ initPlayer();
253
+ } else {
254
+ customElements.whenDefined('jaaq-collection-player').then(() => {
255
+ console.log('[Embed Collection] Web component registered');
256
+ initPlayer();
257
+ });
258
+ }
259
+ }
260
+ }
261
+
262
+ if (document.readyState === 'loading') {
263
+ document.addEventListener('DOMContentLoaded', waitForComponent);
264
+ } else {
265
+ waitForComponent();
266
+ }
267
+ </script>
268
+
269
+ <script
270
+ src="https://cdn.jaaq.app/jaaq-sdk-js/latest/jaaq-webcomponents-bundled.min.js"
271
+ onerror="console.error('[Embed Collection] Failed to load web component script'); showError('Failed to load collection player script');"
272
+ onload="console.log('[Embed Collection] Web component script loaded');"
273
+ ></script>
274
+ </body>
275
+ </html>
@@ -0,0 +1,270 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>JAAQ Embed Player</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ html,
15
+ body {
16
+ width: 100%;
17
+ height: 100%;
18
+ overflow: hidden;
19
+ }
20
+
21
+ body {
22
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
23
+ background: #000;
24
+ }
25
+
26
+ #player-container {
27
+ width: 100%;
28
+ height: 100%;
29
+ }
30
+
31
+ .error-container {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ width: 100%;
36
+ height: 100%;
37
+ background: #1a1a1a;
38
+ color: #fff;
39
+ padding: 20px;
40
+ }
41
+
42
+ .error-content {
43
+ text-align: center;
44
+ max-width: 400px;
45
+ }
46
+
47
+ .error-content h1 {
48
+ font-size: 18px;
49
+ margin-bottom: 12px;
50
+ color: #ff6b6b;
51
+ }
52
+
53
+ .error-content p {
54
+ font-size: 14px;
55
+ color: #ccc;
56
+ line-height: 1.5;
57
+ }
58
+ </style>
59
+ </head>
60
+ <body>
61
+ <div id="player-container"></div>
62
+
63
+ <script>
64
+ function showError(message) {
65
+ console.error('[Embed] Showing error:', message);
66
+ const container = document.getElementById('player-container');
67
+ if (!container) {
68
+ console.error('[Embed] Container not found!');
69
+ return;
70
+ }
71
+ container.innerHTML = `
72
+ <div class="error-container">
73
+ <div class="error-content">
74
+ <h1>⚠️ Player Error</h1>
75
+ <p>${message}</p>
76
+ </div>
77
+ </div>
78
+ `;
79
+ }
80
+
81
+ function getQueryParams() {
82
+ const params = new URLSearchParams(window.location.search);
83
+ const config = {};
84
+
85
+ const apiKey = params.get('apiKey');
86
+ const clientId = params.get('clientId');
87
+ const videoId = params.get('videoId');
88
+
89
+ if (!apiKey || !clientId || !videoId) {
90
+ const missing = [];
91
+ if (!apiKey) missing.push('apiKey');
92
+ if (!clientId) missing.push('clientId');
93
+ if (!videoId) missing.push('videoId');
94
+ throw new Error(`Missing required parameters: ${missing.join(', ')}`);
95
+ }
96
+
97
+ config.apiKey = apiKey;
98
+ config.clientId = clientId;
99
+ config.videoId = videoId;
100
+
101
+ const autoplay = params.get('autoplay');
102
+ if (autoplay !== null) {
103
+ config.autoplay = autoplay === 'true' || autoplay === '1';
104
+ }
105
+
106
+ const width = params.get('width');
107
+ if (width) {
108
+ config.width = width;
109
+ }
110
+
111
+ const height = params.get('height');
112
+ if (height) {
113
+ config.height = height;
114
+ }
115
+
116
+ const baseUrl = params.get('baseUrl');
117
+ if (baseUrl) {
118
+ config.baseUrl = baseUrl;
119
+ }
120
+
121
+ return config;
122
+ }
123
+
124
+ function notifyParent(event, data) {
125
+ if (window.parent && window.parent !== window) {
126
+ window.parent.postMessage(
127
+ {
128
+ type: 'jaaq-player-event',
129
+ event: event,
130
+ data: data,
131
+ },
132
+ '*',
133
+ );
134
+ }
135
+ }
136
+
137
+ function initPlayer() {
138
+ try {
139
+ console.log('[Embed] Initializing player...');
140
+ const config = getQueryParams();
141
+ console.log('[Embed] Config:', config);
142
+ const container = document.getElementById('player-container');
143
+
144
+ const player = document.createElement('jaaq-video-player');
145
+ console.log('[Embed] Created web component:', player);
146
+ player.setAttribute('video-id', config.videoId);
147
+ player.setAttribute('api-key', config.apiKey);
148
+ player.setAttribute('client-id', config.clientId);
149
+
150
+ if (config.baseUrl) {
151
+ player.setAttribute('base-url', config.baseUrl);
152
+ }
153
+
154
+ if (config.autoplay) {
155
+ player.setAttribute('autoplay', 'true');
156
+ }
157
+
158
+ player.setAttribute('width', config.width || '100%');
159
+ player.setAttribute('height', config.height || '100%');
160
+
161
+ player.addEventListener('jaaq:loaded', (e) => {
162
+ const video = e.detail;
163
+ notifyParent('loaded', { id: video.id, title: video.title, question: video.question });
164
+ });
165
+
166
+ player.addEventListener('jaaq:play', () => {
167
+ notifyParent('play', null);
168
+ });
169
+
170
+ player.addEventListener('jaaq:pause', () => {
171
+ notifyParent('pause', null);
172
+ });
173
+
174
+ player.addEventListener('jaaq:timeupdate', (e) => {
175
+ notifyParent('timeupdate', { currentTime: e.detail });
176
+ });
177
+
178
+ player.addEventListener('jaaq:volumechange', (e) => {
179
+ notifyParent('volumechange', { volume: e.detail });
180
+ });
181
+
182
+ player.addEventListener('jaaq:ended', () => {
183
+ notifyParent('ended', null);
184
+ });
185
+
186
+ player.addEventListener('jaaq:error', (e) => {
187
+ console.error('[Embed] Player error event:', e.detail);
188
+ showError(e.detail?.message || 'Unknown player error');
189
+ notifyParent('error', { message: e.detail?.message || 'Unknown error' });
190
+ });
191
+
192
+ player.addEventListener('jaaq:fullscreenchange', (e) => {
193
+ notifyParent('fullscreenchange', { isFullscreen: e.detail });
194
+ });
195
+
196
+ window.addEventListener('message', (event) => {
197
+ if (event.data && event.data.type === 'jaaq-player-command') {
198
+ const { command, args } = event.data;
199
+
200
+ switch (command) {
201
+ case 'play':
202
+ player.play();
203
+ break;
204
+ case 'pause':
205
+ player.pause();
206
+ break;
207
+ case 'toggleMute':
208
+ player.toggleMute();
209
+ break;
210
+ case 'setVolume':
211
+ if (args && typeof args.volume === 'number') {
212
+ player.setVolume(args.volume);
213
+ }
214
+ break;
215
+ case 'seek':
216
+ if (args && typeof args.time === 'number') {
217
+ player.seek(args.time);
218
+ }
219
+ break;
220
+ case 'getState':
221
+ notifyParent('state', player.getState());
222
+ break;
223
+ }
224
+ }
225
+ });
226
+
227
+ container.appendChild(player);
228
+ console.log('[Embed] Player appended to container');
229
+ notifyParent('ready', null);
230
+ } catch (error) {
231
+ console.error('[Embed] Initialization error:', error);
232
+ showError(error.message);
233
+ notifyParent('error', { message: error.message });
234
+ }
235
+ }
236
+
237
+ function waitForComponent() {
238
+ if (customElements.get('jaaq-video-player')) {
239
+ console.log('[Embed] Web component already registered');
240
+ initPlayer();
241
+ } else {
242
+ console.log('[Embed] Waiting for web component registration...');
243
+
244
+ if (typeof JaaqWebComponents !== 'undefined' && JaaqWebComponents.registerJaaqComponents) {
245
+ console.log('[Embed] Manually registering components...');
246
+ JaaqWebComponents.registerJaaqComponents();
247
+ initPlayer();
248
+ } else {
249
+ customElements.whenDefined('jaaq-video-player').then(() => {
250
+ console.log('[Embed] Web component registered');
251
+ initPlayer();
252
+ });
253
+ }
254
+ }
255
+ }
256
+
257
+ if (document.readyState === 'loading') {
258
+ document.addEventListener('DOMContentLoaded', waitForComponent);
259
+ } else {
260
+ waitForComponent();
261
+ }
262
+ </script>
263
+
264
+ <script
265
+ src="https://cdn.jaaq.app/jaaq-sdk-js/latest/jaaq-webcomponents-bundled.min.js"
266
+ onerror="console.error('[Embed] Failed to load web component script'); showError('Failed to load player script');"
267
+ onload="console.log('[Embed] Web component script loaded');"
268
+ ></script>
269
+ </body>
270
+ </html>
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/core/httpClient.ts","../src/resources/videos.ts","../src/resources/collections.ts","../src/index.ts"],"sourcesContent":["export type FetchLike = typeof globalThis.fetch;\ntype RequestOptions = Parameters<typeof globalThis.fetch>[1];\ntype FetchResponse = Awaited<ReturnType<FetchLike>>;\n\nexport interface HttpClientConfig {\n baseUrl: string;\n apiKey: string;\n clientId: string;\n fetch?: FetchLike;\n timeoutMs?: number;\n}\n\nexport interface HttpClient {\n get<T>(_path: string, _init?: RequestOptions): Promise<T>;\n post<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n put<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n patch<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n delete<T>(_path: string, _init?: RequestOptions): Promise<T>;\n}\n\nasync function parseJson<T>(res: FetchResponse): Promise<T> {\n if (!res.ok) {\n const text = await res.text().catch(() => '');\n throw new Error(`HTTP ${res.status}: ${text || res.statusText}`);\n }\n if (res.status === 204) return undefined as unknown as T;\n return res.json() as Promise<T>;\n}\n\nfunction joinUrl(baseUrl: string, clientId: string, path: string): string {\n // return path if it is an absolute URL\n if (/^https?:\\/\\//i.test(path)) return path;\n const base = baseUrl.replace(/\\/+$/, '');\n const relative = path.replace(/^\\/+/, '');\n return `${base}/b2b/v1/subscription/${encodeURIComponent(clientId)}${relative.startsWith('/') ? relative : `/${relative}`}`;\n}\n\nexport function createHttpClient(config: HttpClientConfig): HttpClient {\n const { baseUrl, apiKey, clientId, fetch: fetchImpl } = config;\n\n const f: FetchLike | undefined = fetchImpl ?? (globalThis.fetch as FetchLike | undefined);\n if (!f) {\n throw new Error('No fetch implementation found. Provide one in SDKConfig.fetch for Node or custom environments.');\n }\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n };\n\n const fullUrl = (path: string) => joinUrl(baseUrl, clientId, path);\n\n const request = async <T>(method: string, path: string, init?: RequestOptions, body?: unknown) => {\n const reqInit: RequestOptions = {\n method,\n headers: {\n ...baseHeaders,\n ...(init?.headers as Record<string, string> | undefined),\n },\n ...init,\n };\n if (body !== undefined) reqInit.body = JSON.stringify(body);\n const res = await f(fullUrl(path), reqInit);\n return parseJson<T>(res);\n };\n\n return {\n get: <T>(path: string, init?: RequestOptions) => request<T>('GET', path, init),\n post: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('POST', path, init, body),\n put: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PUT', path, init, body),\n patch: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PATCH', path, init, body),\n delete: <T>(path: string, init?: RequestOptions) => request<T>('DELETE', path, init),\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { VideoDTO } from '@src/types/videos';\n\nexport type VideosResource = {\n getById(_id: string): Promise<VideoDTO>;\n};\n\nexport function createVideosResource(http: HttpClient): VideosResource {\n return {\n async getById(id: string) {\n const path = `/videos/${encodeURIComponent(id)}`;\n const response = await http.get<{ video: VideoDTO }>(path);\n return response.video;\n },\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { CollectionDTO } from '@src/types/collection';\n\nexport type CollectionsResource = {\n list(): Promise<CollectionDTO[]>;\n getById(_id: string): Promise<CollectionDTO>;\n};\n\nexport function createCollectionsResource(http: HttpClient): CollectionsResource {\n return {\n async list() {\n const path = '/collections';\n const response = await http.get<{ collections: CollectionDTO[] }>(path);\n return response.collections;\n },\n async getById(id: string) {\n const path = `/collections/${encodeURIComponent(id)}`;\n const response = await http.get<{ collection: CollectionDTO }>(path);\n return response.collection;\n },\n };\n}\n","import { createHttpClient, type HttpClient, type FetchLike } from '@core/httpClient';\nimport { createVideosResource, type VideosResource } from '@resources/videos';\nimport { createCollectionsResource, type CollectionsResource } from '@resources/collections';\n\n// Public type exports for consumers (barrel)\nexport * from '@src/types';\n\nexport const BASE_URL = process.env.JAAQ_API_URL as string;\n\nexport interface SDKConfig {\n baseUrl?: string; // Pending to approve\n apiKey: string; // Provided by backend per client\n clientId: string; // Provided by each consuming company at init\n fetch?: FetchLike; // Optional fetch injection (Node/custom envs) // Pending to approve\n timeoutMs?: number;\n}\n\nexport class JaaqClient {\n public readonly videos: VideosResource;\n public readonly collections: CollectionsResource;\n\n // Keep constructor private to enforce controlled instantiation.\n private constructor(http: HttpClient) {\n this.videos = createVideosResource(http);\n this.collections = createCollectionsResource(http);\n }\n\n /**\n * Public \"friend\" constructor that remains inside the class boundary.\n * This method is callable from the module-level build function\n * without exposing `new JaaqClient(...)` to consumers.\n */\n static fromHttp(http: HttpClient): JaaqClient {\n return new JaaqClient(http);\n }\n\n /**\n * OO-friendly static initializer.\n * Delegates to the single source of truth: `buildClient`.\n */\n static init(config: SDKConfig): JaaqClient {\n return buildClient(config);\n }\n}\n\n/**\n * Canonical factory (idiomatic for JS/TS).\n * Delegates to the single source of truth: `buildClient`.\n */\nexport function createJaaqClient(config: SDKConfig): JaaqClient {\n return buildClient(config);\n}\n\n/**\n * Single source of truth for constructing the client.\n * Both `createJaaqClient` and `JaaqClient.init` call this function.\n * The constructor stays private; instantiation is funneled via `JaaqClient.fromHttp`.\n */\nfunction buildClient(config: SDKConfig): JaaqClient {\n const { baseUrl = BASE_URL, apiKey, clientId, fetch: fetchImpl } = config;\n\n const http = createHttpClient({\n baseUrl,\n apiKey,\n clientId,\n fetch: fetchImpl ?? (globalThis.fetch as FetchLike | undefined),\n });\n\n return JaaqClient.fromHttp(http);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W,CAAC,MAAM,CAAC;IAC5B;AACD;AAED;;;AAGG;AACG,SAAU,gBAAgB,CAAC,MAAiB,EAAA;AAChD,IAAA,OAAO,WAAW,CAAC,MAAM,CAAC;AAC5B;AAEA;;;;AAIG;AACH,SAAS,WAAW,CAAC,MAAiB,EAAA;AACpC,IAAA,MAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM;IAEzE,MAAM,IAAI,GAAG,gBAAgB,CAAC;QAC5B,OAAO;QACP,MAAM;QACN,QAAQ;AACR,QAAA,KAAK,EAAE,SAAS,IAAK,UAAU,CAAC,KAA+B;AAChE,KAAA,CAAC;AAEF,IAAA,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;AAClC;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/core/httpClient.ts","../src/resources/videos.ts","../src/resources/collections.ts","../src/index.ts"],"sourcesContent":["export type FetchLike = typeof globalThis.fetch;\ntype RequestOptions = Parameters<typeof globalThis.fetch>[1];\ntype FetchResponse = Awaited<ReturnType<FetchLike>>;\n\nexport interface HttpClientConfig {\n baseUrl: string;\n apiKey: string;\n clientId: string;\n fetch?: FetchLike;\n timeoutMs?: number;\n}\n\nexport interface HttpClient {\n get<T>(_path: string, _init?: RequestOptions): Promise<T>;\n post<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n put<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n patch<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n delete<T>(_path: string, _init?: RequestOptions): Promise<T>;\n}\n\nasync function parseJson<T>(res: FetchResponse): Promise<T> {\n if (!res.ok) {\n const text = await res.text().catch(() => '');\n throw new Error(`HTTP ${res.status}: ${text || res.statusText}`);\n }\n if (res.status === 204) return undefined as unknown as T;\n return res.json() as Promise<T>;\n}\n\nfunction joinUrl(baseUrl: string, clientId: string, path: string): string {\n // return path if it is an absolute URL\n if (/^https?:\\/\\//i.test(path)) return path;\n const base = baseUrl.replace(/\\/+$/, '');\n const relative = path.replace(/^\\/+/, '');\n return `${base}/b2b/v1/subscription/${encodeURIComponent(clientId)}${relative.startsWith('/') ? relative : `/${relative}`}`;\n}\n\nexport function createHttpClient(config: HttpClientConfig): HttpClient {\n const { baseUrl, apiKey, clientId, fetch: fetchImpl } = config;\n\n const f: FetchLike | undefined = fetchImpl ?? (globalThis.fetch as FetchLike | undefined);\n if (!f) {\n throw new Error('No fetch implementation found. Provide one in SDKConfig.fetch for Node or custom environments.');\n }\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n };\n\n const fullUrl = (path: string) => joinUrl(baseUrl, clientId, path);\n\n const request = async <T>(method: string, path: string, init?: RequestOptions, body?: unknown) => {\n const reqInit: RequestOptions = {\n method,\n headers: {\n ...baseHeaders,\n ...(init?.headers as Record<string, string> | undefined),\n },\n ...init,\n };\n if (body !== undefined) reqInit.body = JSON.stringify(body);\n const res = await f(fullUrl(path), reqInit);\n return parseJson<T>(res);\n };\n\n return {\n get: <T>(path: string, init?: RequestOptions) => request<T>('GET', path, init),\n post: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('POST', path, init, body),\n put: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PUT', path, init, body),\n patch: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PATCH', path, init, body),\n delete: <T>(path: string, init?: RequestOptions) => request<T>('DELETE', path, init),\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { VideoDTO } from '@src/types/videos';\n\nexport type VideosResource = {\n getById(_id: string): Promise<VideoDTO>;\n};\n\nexport function createVideosResource(http: HttpClient): VideosResource {\n return {\n async getById(id: string) {\n const path = `/videos/${encodeURIComponent(id)}`;\n const response = await http.get<{ video: VideoDTO }>(path);\n return response.video;\n },\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { CollectionDTO } from '@src/types/collection';\n\nexport type CollectionsResource = {\n list(): Promise<CollectionDTO[]>;\n getById(_id: string): Promise<CollectionDTO>;\n};\n\nexport function createCollectionsResource(http: HttpClient): CollectionsResource {\n return {\n async list() {\n const path = '/collections';\n const response = await http.get<{ collections: CollectionDTO[] }>(path);\n return response.collections;\n },\n async getById(id: string) {\n const path = `/collections/${encodeURIComponent(id)}`;\n const response = await http.get<{ collection: CollectionDTO }>(path);\n return response.collection;\n },\n };\n}\n","import { createHttpClient, type HttpClient, type FetchLike } from '@core/httpClient';\nimport { createVideosResource, type VideosResource } from '@resources/videos';\nimport { createCollectionsResource, type CollectionsResource } from '@resources/collections';\n\n// Public type exports for consumers (barrel)\nexport * from '@src/types';\n\nexport const BASE_URL = process.env.JAAQ_API_URL || 'https://api.jaaq.app';\n\nexport interface SDKConfig {\n baseUrl?: string; // Pending to approve\n apiKey: string; // Provided by backend per client\n clientId: string; // Provided by each consuming company at init\n fetch?: FetchLike; // Optional fetch injection (Node/custom envs) // Pending to approve\n timeoutMs?: number;\n}\n\nexport class JaaqClient {\n public readonly videos: VideosResource;\n public readonly collections: CollectionsResource;\n\n // Keep constructor private to enforce controlled instantiation.\n private constructor(http: HttpClient) {\n this.videos = createVideosResource(http);\n this.collections = createCollectionsResource(http);\n }\n\n /**\n * Public \"friend\" constructor that remains inside the class boundary.\n * This method is callable from the module-level build function\n * without exposing `new JaaqClient(...)` to consumers.\n */\n static fromHttp(http: HttpClient): JaaqClient {\n return new JaaqClient(http);\n }\n\n /**\n * OO-friendly static initializer.\n * Delegates to the single source of truth: `buildClient`.\n */\n static init(config: SDKConfig): JaaqClient {\n return buildClient(config);\n }\n}\n\n/**\n * Canonical factory (idiomatic for JS/TS).\n * Delegates to the single source of truth: `buildClient`.\n */\nexport function createJaaqClient(config: SDKConfig): JaaqClient {\n return buildClient(config);\n}\n\n/**\n * Single source of truth for constructing the client.\n * Both `createJaaqClient` and `JaaqClient.init` call this function.\n * The constructor stays private; instantiation is funneled via `JaaqClient.fromHttp`.\n */\nfunction buildClient(config: SDKConfig): JaaqClient {\n const { baseUrl = BASE_URL, apiKey, clientId, fetch: fetchImpl } = config;\n\n const http = createHttpClient({\n baseUrl,\n apiKey,\n clientId,\n fetch: fetchImpl ?? (globalThis.fetch as FetchLike | undefined),\n });\n\n return JaaqClient.fromHttp(http);\n}\n"],"names":[],"mappings":";;AAoBA,eAAe,SAAS,CAAI,GAAkB,EAAA;AAC5C,IAAA,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;AACX,QAAA,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;AAC7C,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,KAAA,EAAQ,GAAG,CAAC,MAAM,CAAA,EAAA,EAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAA,CAAE,CAAC;IAClE;AACA,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;AAAE,QAAA,OAAO,SAAyB;AACxD,IAAA,OAAO,GAAG,CAAC,IAAI,EAAgB;AACjC;AAEA,SAAS,OAAO,CAAC,OAAe,EAAE,QAAgB,EAAE,IAAY,EAAA;;AAE9D,IAAA,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACzC,OAAO,CAAA,EAAG,IAAI,CAAA,qBAAA,EAAwB,kBAAkB,CAAC,QAAQ,CAAC,CAAA,EAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,QAAQ,GAAG,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAE,CAAA,CAAE;AAC7H;AAEM,SAAU,gBAAgB,CAAC,MAAwB,EAAA;AACvD,IAAA,MAAM,E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BAAyB,CAAC,IAAI,CAAC;IACpD;AAEA;;;;AAIG;IACH,OAAO,QAAQ,CAAC,IAAgB,EAAA;AAC9B,QAAA,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC;IAC7B;AAEA;;;AAGG;IACH,OAAO,IAAI,CAAC,MAAiB,EAAA;AAC3B,QAAA,OAAO,WAAW,CAAC,MAAM,CAAC;IAC5B;AACD;AAED;;;AAGG;AACG,SAAU,gBAAgB,CAAC,MAAiB,EAAA;AAChD,IAAA,OAAO,WAAW,CAAC,MAAM,CAAC;AAC5B;AAEA;;;;AAIG;AACH,SAAS,WAAW,CAAC,MAAiB,EAAA;AACpC,IAAA,MAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM;IAEzE,MAAM,IAAI,GAAG,gBAAgB,CAAC;QAC5B,OAAO;QACP,MAAM;QACN,QAAQ;AACR,QAAA,KAAK,EAAE,SAAS,IAAK,UAAU,CAAC,KAA+B;AAChE,KAAA,CAAC;AAEF,IAAA,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;AAClC;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/core/httpClient.ts","../src/resources/videos.ts","../src/resources/collections.ts","../src/index.ts"],"sourcesContent":["export type FetchLike = typeof globalThis.fetch;\ntype RequestOptions = Parameters<typeof globalThis.fetch>[1];\ntype FetchResponse = Awaited<ReturnType<FetchLike>>;\n\nexport interface HttpClientConfig {\n baseUrl: string;\n apiKey: string;\n clientId: string;\n fetch?: FetchLike;\n timeoutMs?: number;\n}\n\nexport interface HttpClient {\n get<T>(_path: string, _init?: RequestOptions): Promise<T>;\n post<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n put<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n patch<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n delete<T>(_path: string, _init?: RequestOptions): Promise<T>;\n}\n\nasync function parseJson<T>(res: FetchResponse): Promise<T> {\n if (!res.ok) {\n const text = await res.text().catch(() => '');\n throw new Error(`HTTP ${res.status}: ${text || res.statusText}`);\n }\n if (res.status === 204) return undefined as unknown as T;\n return res.json() as Promise<T>;\n}\n\nfunction joinUrl(baseUrl: string, clientId: string, path: string): string {\n // return path if it is an absolute URL\n if (/^https?:\\/\\//i.test(path)) return path;\n const base = baseUrl.replace(/\\/+$/, '');\n const relative = path.replace(/^\\/+/, '');\n return `${base}/b2b/v1/subscription/${encodeURIComponent(clientId)}${relative.startsWith('/') ? relative : `/${relative}`}`;\n}\n\nexport function createHttpClient(config: HttpClientConfig): HttpClient {\n const { baseUrl, apiKey, clientId, fetch: fetchImpl } = config;\n\n const f: FetchLike | undefined = fetchImpl ?? (globalThis.fetch as FetchLike | undefined);\n if (!f) {\n throw new Error('No fetch implementation found. Provide one in SDKConfig.fetch for Node or custom environments.');\n }\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n };\n\n const fullUrl = (path: string) => joinUrl(baseUrl, clientId, path);\n\n const request = async <T>(method: string, path: string, init?: RequestOptions, body?: unknown) => {\n const reqInit: RequestOptions = {\n method,\n headers: {\n ...baseHeaders,\n ...(init?.headers as Record<string, string> | undefined),\n },\n ...init,\n };\n if (body !== undefined) reqInit.body = JSON.stringify(body);\n const res = await f(fullUrl(path), reqInit);\n return parseJson<T>(res);\n };\n\n return {\n get: <T>(path: string, init?: RequestOptions) => request<T>('GET', path, init),\n post: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('POST', path, init, body),\n put: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PUT', path, init, body),\n patch: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PATCH', path, init, body),\n delete: <T>(path: string, init?: RequestOptions) => request<T>('DELETE', path, init),\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { VideoDTO } from '@src/types/videos';\n\nexport type VideosResource = {\n getById(_id: string): Promise<VideoDTO>;\n};\n\nexport function createVideosResource(http: HttpClient): VideosResource {\n return {\n async getById(id: string) {\n const path = `/videos/${encodeURIComponent(id)}`;\n const response = await http.get<{ video: VideoDTO }>(path);\n return response.video;\n },\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { CollectionDTO } from '@src/types/collection';\n\nexport type CollectionsResource = {\n list(): Promise<CollectionDTO[]>;\n getById(_id: string): Promise<CollectionDTO>;\n};\n\nexport function createCollectionsResource(http: HttpClient): CollectionsResource {\n return {\n async list() {\n const path = '/collections';\n const response = await http.get<{ collections: CollectionDTO[] }>(path);\n return response.collections;\n },\n async getById(id: string) {\n const path = `/collections/${encodeURIComponent(id)}`;\n const response = await http.get<{ collection: CollectionDTO }>(path);\n return response.collection;\n },\n };\n}\n","import { createHttpClient, type HttpClient, type FetchLike } from '@core/httpClient';\nimport { createVideosResource, type VideosResource } from '@resources/videos';\nimport { createCollectionsResource, type CollectionsResource } from '@resources/collections';\n\n// Public type exports for consumers (barrel)\nexport * from '@src/types';\n\nexport const BASE_URL = process.env.JAAQ_API_URL as string;\n\nexport interface SDKConfig {\n baseUrl?: string; // Pending to approve\n apiKey: string; // Provided by backend per client\n clientId: string; // Provided by each consuming company at init\n fetch?: FetchLike; // Optional fetch injection (Node/custom envs) // Pending to approve\n timeoutMs?: number;\n}\n\nexport class JaaqClient {\n public readonly videos: VideosResource;\n public readonly collections: CollectionsResource;\n\n // Keep constructor private to enforce controlled instantiation.\n private constructor(http: HttpClient) {\n this.videos = createVideosResource(http);\n this.collections = createCollectionsResource(http);\n }\n\n /**\n * Public \"friend\" constructor that remains inside the class boundary.\n * This method is callable from the module-level build function\n * without exposing `new JaaqClient(...)` to consumers.\n */\n static fromHttp(http: HttpClient): JaaqClient {\n return new JaaqClient(http);\n }\n\n /**\n * OO-friendly static initializer.\n * Delegates to the single source of truth: `buildClient`.\n */\n static init(config: SDKConfig): JaaqClient {\n return buildClient(config);\n }\n}\n\n/**\n * Canonical factory (idiomatic for JS/TS).\n * Delegates to the single source of truth: `buildClient`.\n */\nexport function createJaaqClient(config: SDKConfig): JaaqClient {\n return buildClient(config);\n}\n\n/**\n * Single source of truth for constructing the client.\n * Both `createJaaqClient` and `JaaqClient.init` call this function.\n * The constructor stays private; instantiation is funneled via `JaaqClient.fromHttp`.\n */\nfunction buildClient(config: SDKConfig): JaaqClient {\n const { baseUrl = BASE_URL, apiKey, clientId, fetch: fetchImpl } = config;\n\n const http = createHttpClient({\n baseUrl,\n apiKey,\n clientId,\n fetch: fetchImpl ?? (globalThis.fetch as FetchLike | undefined),\n });\n\n return JaaqClient.fromHttp(http);\n}\n"],"names":[],"mappings":"AAoBA,eAAe,SAAS,CAAI,GAAkB,EAAA;AAC5C,IAAA,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;AACX,QAAA,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;AAC7C,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,KAAA,EAAQ,GAAG,CAAC,MAAM,CAAA,EAAA,EAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAA,CAAE,CAAC;IAClE;AACA,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;AAAE,QAAA,OAAO,SAAyB;AACxD,IAAA,OAAO,GAAG,CAAC,IAAI,EAAgB;AACjC;AAEA,SAAS,OAAO,CAAC,OAAe,EAAE,QAAgB,EAAE,IAAY,EAAA;;AAE9D,IAAA,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACzC,OAAO,CAAA,EAAG,IAAI,CAAA,qBAAA,EAAwB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AAU;QAC5B,CAAC;KACF;AACH;;MCda,QAAQ,GAAG;MAUX,UAAU,CAAA;;AAKrB,IAAA,WAAA,CAAoB,IAAgB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC;AACxC,QAAA,IAAI,CAAC,WAAW,GAAG,yBAAyB,CAAC,IAAI,CAAC;IACpD;AAEA;;;;AAIG;IACH,OAAO,QAAQ,CAAC,IAAgB,EAAA;AAC9B,QAAA,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC;IAC7B;AAEA;;;AAGG;IACH,OAAO,IAAI,CAAC,MAAiB,EAAA;AAC3B,QAAA,OAAO,WAAW,CAAC,MAAM,CAAC;IAC5B;AACD;AAED;;;AAGG;AACG,SAAU,gBAAgB,CAAC,MAAiB,EAAA;AAChD,IAAA,OAAO,WAAW,CAAC,MAAM,CAAC;AAC5B;AAEA;;;;AAIG;AACH,SAAS,WAAW,CAAC,MAAiB,EAAA;AACpC,IAAA,MAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM;IAEzE,MAAM,IAAI,GAAG,gBAAgB,CAAC;QAC5B,OAAO;QACP,MAAM;QACN,QAAQ;AACR,QAAA,KAAK,EAAE,SAAS,IAAK,UAAU,CAAC,KAA+B;AAChE,KAAA,CAAC;AAEF,IAAA,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;AAClC;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/core/httpClient.ts","../src/resources/videos.ts","../src/resources/collections.ts","../src/index.ts"],"sourcesContent":["export type FetchLike = typeof globalThis.fetch;\ntype RequestOptions = Parameters<typeof globalThis.fetch>[1];\ntype FetchResponse = Awaited<ReturnType<FetchLike>>;\n\nexport interface HttpClientConfig {\n baseUrl: string;\n apiKey: string;\n clientId: string;\n fetch?: FetchLike;\n timeoutMs?: number;\n}\n\nexport interface HttpClient {\n get<T>(_path: string, _init?: RequestOptions): Promise<T>;\n post<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n put<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n patch<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;\n delete<T>(_path: string, _init?: RequestOptions): Promise<T>;\n}\n\nasync function parseJson<T>(res: FetchResponse): Promise<T> {\n if (!res.ok) {\n const text = await res.text().catch(() => '');\n throw new Error(`HTTP ${res.status}: ${text || res.statusText}`);\n }\n if (res.status === 204) return undefined as unknown as T;\n return res.json() as Promise<T>;\n}\n\nfunction joinUrl(baseUrl: string, clientId: string, path: string): string {\n // return path if it is an absolute URL\n if (/^https?:\\/\\//i.test(path)) return path;\n const base = baseUrl.replace(/\\/+$/, '');\n const relative = path.replace(/^\\/+/, '');\n return `${base}/b2b/v1/subscription/${encodeURIComponent(clientId)}${relative.startsWith('/') ? relative : `/${relative}`}`;\n}\n\nexport function createHttpClient(config: HttpClientConfig): HttpClient {\n const { baseUrl, apiKey, clientId, fetch: fetchImpl } = config;\n\n const f: FetchLike | undefined = fetchImpl ?? (globalThis.fetch as FetchLike | undefined);\n if (!f) {\n throw new Error('No fetch implementation found. Provide one in SDKConfig.fetch for Node or custom environments.');\n }\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n };\n\n const fullUrl = (path: string) => joinUrl(baseUrl, clientId, path);\n\n const request = async <T>(method: string, path: string, init?: RequestOptions, body?: unknown) => {\n const reqInit: RequestOptions = {\n method,\n headers: {\n ...baseHeaders,\n ...(init?.headers as Record<string, string> | undefined),\n },\n ...init,\n };\n if (body !== undefined) reqInit.body = JSON.stringify(body);\n const res = await f(fullUrl(path), reqInit);\n return parseJson<T>(res);\n };\n\n return {\n get: <T>(path: string, init?: RequestOptions) => request<T>('GET', path, init),\n post: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('POST', path, init, body),\n put: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PUT', path, init, body),\n patch: <T>(path: string, body?: unknown, init?: RequestOptions) => request<T>('PATCH', path, init, body),\n delete: <T>(path: string, init?: RequestOptions) => request<T>('DELETE', path, init),\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { VideoDTO } from '@src/types/videos';\n\nexport type VideosResource = {\n getById(_id: string): Promise<VideoDTO>;\n};\n\nexport function createVideosResource(http: HttpClient): VideosResource {\n return {\n async getById(id: string) {\n const path = `/videos/${encodeURIComponent(id)}`;\n const response = await http.get<{ video: VideoDTO }>(path);\n return response.video;\n },\n };\n}\n","import type { HttpClient } from '@core/httpClient';\nimport type { CollectionDTO } from '@src/types/collection';\n\nexport type CollectionsResource = {\n list(): Promise<CollectionDTO[]>;\n getById(_id: string): Promise<CollectionDTO>;\n};\n\nexport function createCollectionsResource(http: HttpClient): CollectionsResource {\n return {\n async list() {\n const path = '/collections';\n const response = await http.get<{ collections: CollectionDTO[] }>(path);\n return response.collections;\n },\n async getById(id: string) {\n const path = `/collections/${encodeURIComponent(id)}`;\n const response = await http.get<{ collection: CollectionDTO }>(path);\n return response.collection;\n },\n };\n}\n","import { createHttpClient, type HttpClient, type FetchLike } from '@core/httpClient';\nimport { createVideosResource, type VideosResource } from '@resources/videos';\nimport { createCollectionsResource, type CollectionsResource } from '@resources/collections';\n\n// Public type exports for consumers (barrel)\nexport * from '@src/types';\n\nexport const BASE_URL = process.env.JAAQ_API_URL || 'https://api.jaaq.app';\n\nexport interface SDKConfig {\n baseUrl?: string; // Pending to approve\n apiKey: string; // Provided by backend per client\n clientId: string; // Provided by each consuming company at init\n fetch?: FetchLike; // Optional fetch injection (Node/custom envs) // Pending to approve\n timeoutMs?: number;\n}\n\nexport class JaaqClient {\n public readonly videos: VideosResource;\n public readonly collections: CollectionsResource;\n\n // Keep constructor private to enforce controlled instantiation.\n private constructor(http: HttpClient) {\n this.videos = createVideosResource(http);\n this.collections = createCollectionsResource(http);\n }\n\n /**\n * Public \"friend\" constructor that remains inside the class boundary.\n * This method is callable from the module-level build function\n * without exposing `new JaaqClient(...)` to consumers.\n */\n static fromHttp(http: HttpClient): JaaqClient {\n return new JaaqClient(http);\n }\n\n /**\n * OO-friendly static initializer.\n * Delegates to the single source of truth: `buildClient`.\n */\n static init(config: SDKConfig): JaaqClient {\n return buildClient(config);\n }\n}\n\n/**\n * Canonical factory (idiomatic for JS/TS).\n * Delegates to the single source of truth: `buildClient`.\n */\nexport function createJaaqClient(config: SDKConfig): JaaqClient {\n return buildClient(config);\n}\n\n/**\n * Single source of truth for constructing the client.\n * Both `createJaaqClient` and `JaaqClient.init` call this function.\n * The constructor stays private; instantiation is funneled via `JaaqClient.fromHttp`.\n */\nfunction buildClient(config: SDKConfig): JaaqClient {\n const { baseUrl = BASE_URL, apiKey, clientId, fetch: fetchImpl } = config;\n\n const http = createHttpClient({\n baseUrl,\n apiKey,\n clientId,\n fetch: fetchImpl ?? (globalThis.fetch as FetchLike | undefined),\n });\n\n return JaaqClient.fromHttp(http);\n}\n"],"names":[],"mappings":"AAoBA,eAAe,SAAS,CAAI,GAAkB,EAAA;AAC5C,IAAA,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;AACX,QAAA,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;AAC7C,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,KAAA,EAAQ,GAAG,CAAC,MAAM,CAAA,EAAA,EAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAA,CAAE,CAAC;IAClE;AACA,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;AAAE,QAAA,OAAO,SAAyB;AACxD,IAAA,OAAO,GAAG,CAAC,IAAI,EAAgB;AACjC;AAEA,SAAS,OAAO,CAAC,OAAe,EAAE,QAAgB,EAAE,IAAY,EAAA;;AAE9D,IAAA,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO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