@gyldendalas/gyldendal-divine-api 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +371 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +386 -15
- package/dist/index.d.ts +386 -15
- package/dist/index.js +361 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,12 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AIBotService: () => AIBotService,
|
|
24
|
+
CookieConsentLog: () => CookieConsentLog,
|
|
25
|
+
HighlightResultType: () => HighlightResultType,
|
|
26
|
+
HighlightService: () => HighlightService,
|
|
27
|
+
PdfGeneratorService: () => PdfGeneratorService,
|
|
28
|
+
PollyService: () => PollyService,
|
|
29
|
+
SSMLSpeechSpeeds: () => SSMLSpeechSpeeds,
|
|
30
|
+
SolrProxyService: () => SolrProxyService,
|
|
23
31
|
TaggingService: () => TaggingService,
|
|
24
32
|
UserFolders: () => UserFolders,
|
|
25
33
|
UserSettingsBookmarks: () => UserSettingsBookmarks,
|
|
26
34
|
UserSettingsClientSettings: () => UserSettingsClientSettings,
|
|
27
35
|
UserSettingsContinue: () => UserSettingsContinue,
|
|
28
|
-
UserSettingsMRU: () => UserSettingsMRU
|
|
36
|
+
UserSettingsMRU: () => UserSettingsMRU,
|
|
37
|
+
WritingTaskService: () => WritingTaskService
|
|
29
38
|
});
|
|
30
39
|
module.exports = __toCommonJS(index_exports);
|
|
31
40
|
|
|
@@ -80,55 +89,55 @@ var BaseService = class {
|
|
|
80
89
|
async getAsync({
|
|
81
90
|
url,
|
|
82
91
|
headers,
|
|
92
|
+
addAuthHeaders = true,
|
|
83
93
|
timeout
|
|
84
94
|
}) {
|
|
85
95
|
const method = "GET";
|
|
86
|
-
|
|
87
|
-
return response.json();
|
|
96
|
+
return await this.callAsync({ url, body: null, method, headers, addAuthHeaders, timeout });
|
|
88
97
|
}
|
|
89
98
|
async putAsync({
|
|
90
99
|
url,
|
|
91
100
|
headers,
|
|
101
|
+
addAuthHeaders = true,
|
|
92
102
|
body,
|
|
93
103
|
timeout
|
|
94
104
|
}) {
|
|
95
105
|
const method = "PUT";
|
|
96
|
-
|
|
97
|
-
return response.json();
|
|
106
|
+
return await this.callAsync({ url, body, method, headers, addAuthHeaders, timeout });
|
|
98
107
|
}
|
|
99
108
|
async postAsync({
|
|
100
109
|
url,
|
|
101
110
|
headers,
|
|
111
|
+
addAuthHeaders = true,
|
|
102
112
|
body,
|
|
103
113
|
timeout
|
|
104
114
|
}) {
|
|
105
115
|
const method = "POST";
|
|
106
|
-
|
|
107
|
-
return response.json();
|
|
116
|
+
return await this.callAsync({ url, body, method, headers, addAuthHeaders, timeout });
|
|
108
117
|
}
|
|
109
118
|
async deleteAsync({
|
|
110
119
|
url,
|
|
111
120
|
headers,
|
|
121
|
+
addAuthHeaders = true,
|
|
112
122
|
timeout
|
|
113
123
|
}) {
|
|
114
124
|
const method = "DELETE";
|
|
115
|
-
|
|
116
|
-
if (response.status === 204) {
|
|
117
|
-
return {};
|
|
118
|
-
}
|
|
119
|
-
return response.json();
|
|
125
|
+
return await this.callAsync({ url, body: null, method, headers, addAuthHeaders, timeout });
|
|
120
126
|
}
|
|
121
127
|
async callAsync({
|
|
122
128
|
url,
|
|
123
129
|
body,
|
|
124
130
|
method,
|
|
125
131
|
headers,
|
|
126
|
-
timeout
|
|
132
|
+
timeout,
|
|
133
|
+
addAuthHeaders
|
|
127
134
|
}) {
|
|
128
135
|
if (!headers) {
|
|
129
136
|
headers = new Headers();
|
|
130
137
|
}
|
|
131
|
-
|
|
138
|
+
if (addAuthHeaders) {
|
|
139
|
+
headers = await this.addAuthHeaders(headers);
|
|
140
|
+
}
|
|
132
141
|
const response = await fetch(url, {
|
|
133
142
|
method,
|
|
134
143
|
body,
|
|
@@ -152,6 +161,8 @@ var TaggingService = class extends base_service_default {
|
|
|
152
161
|
case "development":
|
|
153
162
|
case "local":
|
|
154
163
|
return `https://staging-tagging.services.${this.baseDomain}`;
|
|
164
|
+
case "test":
|
|
165
|
+
return `https://localhost:3010/services/tagging`;
|
|
155
166
|
default:
|
|
156
167
|
throw new Error(`Unknown environment: ${this.environment}`);
|
|
157
168
|
}
|
|
@@ -165,7 +176,8 @@ var TaggingService = class extends base_service_default {
|
|
|
165
176
|
}) {
|
|
166
177
|
const url = `${this.getUrlPrefix()}/tags/by_resource/${identity}${resource_type ? `/${resource_type}` : ""}${resource_name ? `/${resource_name}` : ""}${tag_name ? `/${tag_name}` : ""}`;
|
|
167
178
|
const headers = new Headers();
|
|
168
|
-
|
|
179
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
180
|
+
return response.json();
|
|
169
181
|
}
|
|
170
182
|
async getTagsByName({
|
|
171
183
|
identity,
|
|
@@ -176,7 +188,8 @@ var TaggingService = class extends base_service_default {
|
|
|
176
188
|
}) {
|
|
177
189
|
const url = `${this.getUrlPrefix()}/tags/by_tag_name/${identity}/${tag_name}${resource_type ? `/${resource_type}` : ""}${resource_name ? `/${resource_name}` : ""}`;
|
|
178
190
|
const headers = new Headers();
|
|
179
|
-
|
|
191
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
192
|
+
return await response.json();
|
|
180
193
|
}
|
|
181
194
|
async createTag({
|
|
182
195
|
tag,
|
|
@@ -185,7 +198,8 @@ var TaggingService = class extends base_service_default {
|
|
|
185
198
|
const url = `${this.getUrlPrefix()}/tags`;
|
|
186
199
|
const headers = new Headers();
|
|
187
200
|
headers.append("Content-Type", "application/json");
|
|
188
|
-
|
|
201
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(tag), timeout });
|
|
202
|
+
return await response.json();
|
|
189
203
|
}
|
|
190
204
|
async updateTag({
|
|
191
205
|
tag,
|
|
@@ -194,7 +208,8 @@ var TaggingService = class extends base_service_default {
|
|
|
194
208
|
const url = `${this.getUrlPrefix()}/tags`;
|
|
195
209
|
const headers = new Headers();
|
|
196
210
|
headers.append("Content-Type", "application/json");
|
|
197
|
-
|
|
211
|
+
const response = await this.putAsync({ url, headers, body: JSON.stringify(tag), timeout });
|
|
212
|
+
return await response.json();
|
|
198
213
|
}
|
|
199
214
|
async deleteTag({
|
|
200
215
|
identity,
|
|
@@ -205,11 +220,169 @@ var TaggingService = class extends base_service_default {
|
|
|
205
220
|
}) {
|
|
206
221
|
const url = `${this.getUrlPrefix()}/tags/${identity}${resource_type ? `/${resource_type}` : ""}${resource_name ? `/${resource_name}` : ""}${tag_name ? `/${tag_name}` : ""}`;
|
|
207
222
|
const headers = new Headers();
|
|
208
|
-
await this.deleteAsync({ url, headers, timeout });
|
|
223
|
+
const response = await this.deleteAsync({ url, headers, timeout });
|
|
224
|
+
await response.json();
|
|
225
|
+
return;
|
|
209
226
|
}
|
|
210
227
|
};
|
|
211
228
|
var tagging_service_default = TaggingService;
|
|
212
229
|
|
|
230
|
+
// src/services/polly_service.ts
|
|
231
|
+
var SSMLSpeechSpeeds = /* @__PURE__ */ ((SSMLSpeechSpeeds2) => {
|
|
232
|
+
SSMLSpeechSpeeds2[SSMLSpeechSpeeds2["X_SLOW"] = 1] = "X_SLOW";
|
|
233
|
+
SSMLSpeechSpeeds2[SSMLSpeechSpeeds2["SLOW"] = 2] = "SLOW";
|
|
234
|
+
SSMLSpeechSpeeds2[SSMLSpeechSpeeds2["MEDIUM"] = 3] = "MEDIUM";
|
|
235
|
+
SSMLSpeechSpeeds2[SSMLSpeechSpeeds2["FAST"] = 4] = "FAST";
|
|
236
|
+
SSMLSpeechSpeeds2[SSMLSpeechSpeeds2["X_FAST"] = 5] = "X_FAST";
|
|
237
|
+
return SSMLSpeechSpeeds2;
|
|
238
|
+
})(SSMLSpeechSpeeds || {});
|
|
239
|
+
var PollyService = class extends base_service_default {
|
|
240
|
+
discoverUrlPrefix() {
|
|
241
|
+
switch (this.environment) {
|
|
242
|
+
case "production":
|
|
243
|
+
return `https://appear-polly.services.${this.baseDomain}`;
|
|
244
|
+
case "development":
|
|
245
|
+
case "local":
|
|
246
|
+
return `https://staging-appear-polly.services.${this.baseDomain}`;
|
|
247
|
+
case "test":
|
|
248
|
+
return `https://localhost:3010/services/polly`;
|
|
249
|
+
default:
|
|
250
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async synthesize({
|
|
254
|
+
body,
|
|
255
|
+
timeout = 3e3
|
|
256
|
+
}) {
|
|
257
|
+
const url = `${this.getUrlPrefix()}/synthesizeSpeech`;
|
|
258
|
+
const headers = new Headers();
|
|
259
|
+
headers.append("Content-Type", "application/json");
|
|
260
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
|
|
261
|
+
return response.json();
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// src/services/cookie_consent_log.ts
|
|
266
|
+
var CookieConsentLog = class extends base_service_default {
|
|
267
|
+
discoverUrlPrefix() {
|
|
268
|
+
switch (this.environment) {
|
|
269
|
+
case "production":
|
|
270
|
+
return `https://cookieconsentlog.services.${this.baseDomain}`;
|
|
271
|
+
case "development":
|
|
272
|
+
case "local":
|
|
273
|
+
return `https://staging-cookieconsentlog.services.${this.baseDomain}`;
|
|
274
|
+
case "test":
|
|
275
|
+
return `https://localhost:3010/services/cookieconsentlog`;
|
|
276
|
+
default:
|
|
277
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async logCookieConsent({
|
|
281
|
+
body,
|
|
282
|
+
timeout = 3e3
|
|
283
|
+
}) {
|
|
284
|
+
const url = `${this.getUrlPrefix()}/log`;
|
|
285
|
+
const headers = new Headers();
|
|
286
|
+
headers.append("Content-Type", "application/json");
|
|
287
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(body), addAuthHeaders: false, timeout });
|
|
288
|
+
return response.text();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// src/services/highlight_service.ts
|
|
293
|
+
var HighlightResultType = /* @__PURE__ */ ((HighlightResultType2) => {
|
|
294
|
+
HighlightResultType2["highlight"] = "highlight";
|
|
295
|
+
HighlightResultType2["note"] = "note";
|
|
296
|
+
return HighlightResultType2;
|
|
297
|
+
})(HighlightResultType || {});
|
|
298
|
+
var HighlightService = class extends base_service_default {
|
|
299
|
+
discoverUrlPrefix() {
|
|
300
|
+
switch (this.environment) {
|
|
301
|
+
case "production":
|
|
302
|
+
return `https://highlights.services.${this.baseDomain}`;
|
|
303
|
+
case "development":
|
|
304
|
+
case "local":
|
|
305
|
+
return `https://staging-highlights.services.${this.baseDomain}`;
|
|
306
|
+
case "test":
|
|
307
|
+
return `https://localhost:3010/services/highlight`;
|
|
308
|
+
default:
|
|
309
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async search({
|
|
313
|
+
search,
|
|
314
|
+
timeout = 3e3
|
|
315
|
+
}) {
|
|
316
|
+
const url = `${this.getUrlPrefix()}/v2/search`;
|
|
317
|
+
const headers = new Headers();
|
|
318
|
+
headers.append("Content-Type", "application/json");
|
|
319
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(search), timeout });
|
|
320
|
+
return response.json();
|
|
321
|
+
}
|
|
322
|
+
async deleteHighlightOrNote({
|
|
323
|
+
isbn,
|
|
324
|
+
pid,
|
|
325
|
+
key,
|
|
326
|
+
timeout = 3e3
|
|
327
|
+
}) {
|
|
328
|
+
const url = `${this.getUrlPrefix()}/v2/isbn/${isbn}/pid/${pid}/key/${key}`;
|
|
329
|
+
const headers = new Headers();
|
|
330
|
+
headers.append("Content-Type", "application/json");
|
|
331
|
+
const response = await this.deleteAsync({ url, headers, timeout });
|
|
332
|
+
return response.json();
|
|
333
|
+
}
|
|
334
|
+
async getHighlightOrNote({
|
|
335
|
+
isbn,
|
|
336
|
+
pid,
|
|
337
|
+
timeout = 3e3
|
|
338
|
+
}) {
|
|
339
|
+
let url = `${this.getUrlPrefix()}/v2/isbn/${isbn}`;
|
|
340
|
+
if (pid) {
|
|
341
|
+
url += `/pid/${pid}`;
|
|
342
|
+
}
|
|
343
|
+
const headers = new Headers();
|
|
344
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
345
|
+
return response.json();
|
|
346
|
+
}
|
|
347
|
+
async getHighlightOrNoteCounts({
|
|
348
|
+
noteType,
|
|
349
|
+
timeout = 3e3
|
|
350
|
+
}) {
|
|
351
|
+
let url = `${this.getUrlPrefix()}/v2/count`;
|
|
352
|
+
if (noteType) {
|
|
353
|
+
url += `/${noteType}`;
|
|
354
|
+
}
|
|
355
|
+
const headers = new Headers();
|
|
356
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
357
|
+
return response.json();
|
|
358
|
+
}
|
|
359
|
+
async updateHighlightOrNote({
|
|
360
|
+
payload,
|
|
361
|
+
isbn,
|
|
362
|
+
pid,
|
|
363
|
+
key,
|
|
364
|
+
timeout = 5e3
|
|
365
|
+
}) {
|
|
366
|
+
const url = `${this.getUrlPrefix()}/v2/isbn/${isbn}/pid/${pid}/key/${key}`;
|
|
367
|
+
const headers = new Headers();
|
|
368
|
+
headers.set("Content-Type", "application/json");
|
|
369
|
+
const response = await this.putAsync({ url, headers, body: JSON.stringify(payload), timeout });
|
|
370
|
+
return response.json();
|
|
371
|
+
}
|
|
372
|
+
async addHighlightOrNote({
|
|
373
|
+
payload,
|
|
374
|
+
isbn,
|
|
375
|
+
pid,
|
|
376
|
+
timeout = 5e3
|
|
377
|
+
}) {
|
|
378
|
+
const url = `${this.getUrlPrefix()}/v2/isbn/${isbn}/pid/${pid}`;
|
|
379
|
+
const headers = new Headers();
|
|
380
|
+
headers.set("Content-Type", "application/json");
|
|
381
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(payload), timeout });
|
|
382
|
+
return response.json();
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
213
386
|
// src/services/user_settings_base.ts
|
|
214
387
|
var UserSettingsBase = class extends base_service_default {
|
|
215
388
|
discoverUrlPrefix() {
|
|
@@ -219,6 +392,8 @@ var UserSettingsBase = class extends base_service_default {
|
|
|
219
392
|
case "development":
|
|
220
393
|
case "local":
|
|
221
394
|
return `https://staging-user-settings-service.services.${this.baseDomain}`;
|
|
395
|
+
case "test":
|
|
396
|
+
return `https://localhost:3010/services/usersettingsservice`;
|
|
222
397
|
default:
|
|
223
398
|
throw new Error(`Unknown environment: ${this.environment}`);
|
|
224
399
|
}
|
|
@@ -235,7 +410,8 @@ var UserSettingsClientSettings = class extends user_settings_base_default {
|
|
|
235
410
|
const url = `${this.getUrlPrefix()}/clientsettings/isbn/${isbn}`;
|
|
236
411
|
const headers = new Headers();
|
|
237
412
|
try {
|
|
238
|
-
|
|
413
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
414
|
+
return response.json();
|
|
239
415
|
} catch (Error2) {
|
|
240
416
|
if (Error2 instanceof HTTPError && Error2.response.status === 404) {
|
|
241
417
|
return {};
|
|
@@ -252,7 +428,8 @@ var UserSettingsClientSettings = class extends user_settings_base_default {
|
|
|
252
428
|
const url = `${this.getUrlPrefix()}/clientsettings/isbn/${isbn}`;
|
|
253
429
|
const headers = new Headers();
|
|
254
430
|
headers.set("Content-Type", "application/json");
|
|
255
|
-
|
|
431
|
+
const response = await this.putAsync({ url, headers, body: JSON.stringify(settings), timeout });
|
|
432
|
+
return response.json();
|
|
256
433
|
}
|
|
257
434
|
async deleteSettings({
|
|
258
435
|
isbn,
|
|
@@ -279,7 +456,8 @@ var UserSettingsBookmarks = class extends user_settings_base_default {
|
|
|
279
456
|
headers.set("external-user-id", externalUserId);
|
|
280
457
|
}
|
|
281
458
|
headers.set("Content-Type", "application/json");
|
|
282
|
-
|
|
459
|
+
const response = await this.putAsync({ url, headers, body: JSON.stringify(bookmark), timeout });
|
|
460
|
+
return response.json();
|
|
283
461
|
}
|
|
284
462
|
async deleteBookmark({
|
|
285
463
|
isbn,
|
|
@@ -308,7 +486,8 @@ var UserSettingsBookmarks = class extends user_settings_base_default {
|
|
|
308
486
|
url += `/page/${pageId}`;
|
|
309
487
|
}
|
|
310
488
|
const headers = new Headers();
|
|
311
|
-
|
|
489
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
490
|
+
return response.json();
|
|
312
491
|
}
|
|
313
492
|
// Favourites are bookmarks that are ISBN specific, with a pageId of 0.
|
|
314
493
|
async getFavourite({
|
|
@@ -316,7 +495,8 @@ var UserSettingsBookmarks = class extends user_settings_base_default {
|
|
|
316
495
|
}) {
|
|
317
496
|
let url = `${this.getUrlPrefix()}/bookmark/favourite`;
|
|
318
497
|
const headers = new Headers();
|
|
319
|
-
|
|
498
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
499
|
+
return response.json();
|
|
320
500
|
}
|
|
321
501
|
};
|
|
322
502
|
|
|
@@ -337,7 +517,8 @@ var UserSettingsContinue = class extends user_settings_base_default {
|
|
|
337
517
|
headers.set("external-user-id", externalUserId);
|
|
338
518
|
}
|
|
339
519
|
headers.set("Content-Type", "application/json");
|
|
340
|
-
|
|
520
|
+
const response = await this.putAsync({ url, headers, body: JSON.stringify(continueBody), timeout });
|
|
521
|
+
return response.json();
|
|
341
522
|
}
|
|
342
523
|
async deleteContinue({
|
|
343
524
|
isbn,
|
|
@@ -355,7 +536,8 @@ var UserSettingsContinue = class extends user_settings_base_default {
|
|
|
355
536
|
let url = `${this.getUrlPrefix()}/continue/isbn/${isbn}`;
|
|
356
537
|
const headers = new Headers();
|
|
357
538
|
try {
|
|
358
|
-
|
|
539
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
540
|
+
return response.json();
|
|
359
541
|
} catch (Error2) {
|
|
360
542
|
if (Error2 instanceof HTTPError && Error2.response.status === 404) {
|
|
361
543
|
return {};
|
|
@@ -379,7 +561,8 @@ var UserSettingsMRU = class extends user_settings_base_default {
|
|
|
379
561
|
headers.set("external-user-id", externalUserId);
|
|
380
562
|
}
|
|
381
563
|
headers.set("Content-Type", "application/json");
|
|
382
|
-
|
|
564
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(mru), timeout });
|
|
565
|
+
return response.json();
|
|
383
566
|
}
|
|
384
567
|
async clearMRU({
|
|
385
568
|
timeout = 5e3
|
|
@@ -394,7 +577,55 @@ var UserSettingsMRU = class extends user_settings_base_default {
|
|
|
394
577
|
}) {
|
|
395
578
|
let url = `${this.getUrlPrefix()}/mru`;
|
|
396
579
|
const headers = new Headers();
|
|
397
|
-
|
|
580
|
+
const response = await this.getAsync({ url, headers, timeout });
|
|
581
|
+
return response.json();
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// src/services/pdf_generator.ts
|
|
586
|
+
var PdfGeneratorService = class extends base_service_default {
|
|
587
|
+
discoverUrlPrefix() {
|
|
588
|
+
switch (this.environment) {
|
|
589
|
+
case "production":
|
|
590
|
+
return `https://pdfgenerator.services.${this.baseDomain}`;
|
|
591
|
+
case "development":
|
|
592
|
+
case "local":
|
|
593
|
+
return `https://staging-pdfgenerator.services.${this.baseDomain}`;
|
|
594
|
+
case "test":
|
|
595
|
+
return `https://localhost:3010/services/pdfgenerator`;
|
|
596
|
+
default:
|
|
597
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async pdfFromSiteMap({
|
|
601
|
+
body,
|
|
602
|
+
timeout = 3e3
|
|
603
|
+
}) {
|
|
604
|
+
const url = `${this.getUrlPrefix()}/sitemap`;
|
|
605
|
+
const headers = new Headers();
|
|
606
|
+
headers.append("Content-Type", "application/json");
|
|
607
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
|
|
608
|
+
return response.json();
|
|
609
|
+
}
|
|
610
|
+
async pdfFromWritingTask({
|
|
611
|
+
body,
|
|
612
|
+
timeout = 3e3
|
|
613
|
+
}) {
|
|
614
|
+
const url = `${this.getUrlPrefix()}/writingTask`;
|
|
615
|
+
const headers = new Headers();
|
|
616
|
+
headers.append("Content-Type", "application/json");
|
|
617
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
|
|
618
|
+
return response.json();
|
|
619
|
+
}
|
|
620
|
+
async pdfFromNotes({
|
|
621
|
+
body,
|
|
622
|
+
timeout = 3e3
|
|
623
|
+
}) {
|
|
624
|
+
const url = `${this.getUrlPrefix()}/notes`;
|
|
625
|
+
const headers = new Headers();
|
|
626
|
+
headers.append("Content-Type", "application/json");
|
|
627
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
|
|
628
|
+
return response.json();
|
|
398
629
|
}
|
|
399
630
|
};
|
|
400
631
|
|
|
@@ -748,13 +979,124 @@ var UserFolders = class extends tagging_service_default {
|
|
|
748
979
|
);
|
|
749
980
|
}
|
|
750
981
|
};
|
|
982
|
+
|
|
983
|
+
// src/services/ai_bot_service.ts
|
|
984
|
+
var AIBotService = class extends base_service_default {
|
|
985
|
+
discoverUrlPrefix() {
|
|
986
|
+
switch (this.environment) {
|
|
987
|
+
case "production":
|
|
988
|
+
return `https://ai-bot-service.eu-west-1.${this.baseDomain}`;
|
|
989
|
+
case "development":
|
|
990
|
+
case "local":
|
|
991
|
+
return `https://ai-bot-service-staging.eu-west-1.${this.baseDomain}`;
|
|
992
|
+
case "test":
|
|
993
|
+
return `https://localhost:3010/services/aibotservice`;
|
|
994
|
+
default:
|
|
995
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
async constructChatUrl({
|
|
999
|
+
interactivityId,
|
|
1000
|
+
isbn,
|
|
1001
|
+
stream
|
|
1002
|
+
}) {
|
|
1003
|
+
if (interactivityId && isbn) {
|
|
1004
|
+
throw new Error("interactivityId and isbn are mutually exclusive");
|
|
1005
|
+
}
|
|
1006
|
+
if (!interactivityId && !isbn) {
|
|
1007
|
+
throw new Error("Either interactivityId or isbn must be provided");
|
|
1008
|
+
}
|
|
1009
|
+
let url = "";
|
|
1010
|
+
if (interactivityId) {
|
|
1011
|
+
url = `${this.getUrlPrefix()}/${interactivityId}/chat`;
|
|
1012
|
+
}
|
|
1013
|
+
if (isbn) {
|
|
1014
|
+
url = `${this.getUrlPrefix()}/interactivity_from_isbn/${isbn}`;
|
|
1015
|
+
}
|
|
1016
|
+
if (stream) {
|
|
1017
|
+
url += "/stream";
|
|
1018
|
+
}
|
|
1019
|
+
return url;
|
|
1020
|
+
}
|
|
1021
|
+
async chat({
|
|
1022
|
+
interactivityId,
|
|
1023
|
+
isbn,
|
|
1024
|
+
body,
|
|
1025
|
+
timeout = 1e4
|
|
1026
|
+
}) {
|
|
1027
|
+
const url = await this.constructChatUrl({ interactivityId, isbn, stream: false });
|
|
1028
|
+
const headers = new Headers();
|
|
1029
|
+
headers.append("Content-Type", "application/json");
|
|
1030
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
|
|
1031
|
+
return response.json();
|
|
1032
|
+
}
|
|
1033
|
+
async streamingChat({
|
|
1034
|
+
interactivityId,
|
|
1035
|
+
isbn,
|
|
1036
|
+
body,
|
|
1037
|
+
timeout = 1e4
|
|
1038
|
+
}) {
|
|
1039
|
+
const url = await this.constructChatUrl({ interactivityId, isbn, stream: true });
|
|
1040
|
+
const headers = new Headers();
|
|
1041
|
+
headers.append("Content-Type", "application/json");
|
|
1042
|
+
const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
|
|
1043
|
+
const responseBody = response.body;
|
|
1044
|
+
if (!responseBody) {
|
|
1045
|
+
throw new Error("Response body is null");
|
|
1046
|
+
}
|
|
1047
|
+
return responseBody;
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
// src/services/writing_task_service.ts
|
|
1052
|
+
var WritingTaskService = class extends base_service_default {
|
|
1053
|
+
discoverUrlPrefix() {
|
|
1054
|
+
switch (this.environment) {
|
|
1055
|
+
case "production":
|
|
1056
|
+
return `https://writingtask.services.${this.baseDomain}`;
|
|
1057
|
+
case "development":
|
|
1058
|
+
case "local":
|
|
1059
|
+
return `https://staging-writingtask.services.${this.baseDomain}`;
|
|
1060
|
+
case "test":
|
|
1061
|
+
return `https://localhost:3010/services/writingtask`;
|
|
1062
|
+
default:
|
|
1063
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
// src/services/solr_proxy_service.ts
|
|
1069
|
+
var SolrProxyService = class extends base_service_default {
|
|
1070
|
+
discoverUrlPrefix() {
|
|
1071
|
+
switch (this.environment) {
|
|
1072
|
+
case "production":
|
|
1073
|
+
return `https://solr-proxy.eu-west-1.${this.baseDomain}`;
|
|
1074
|
+
case "development":
|
|
1075
|
+
case "local":
|
|
1076
|
+
return `https://solr-proxy-staging.eu-west-1.${this.baseDomain}`;
|
|
1077
|
+
case "test":
|
|
1078
|
+
return `https://localhost:3010/services/solrproxy`;
|
|
1079
|
+
default:
|
|
1080
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
751
1084
|
// Annotate the CommonJS export names for ESM import in node:
|
|
752
1085
|
0 && (module.exports = {
|
|
1086
|
+
AIBotService,
|
|
1087
|
+
CookieConsentLog,
|
|
1088
|
+
HighlightResultType,
|
|
1089
|
+
HighlightService,
|
|
1090
|
+
PdfGeneratorService,
|
|
1091
|
+
PollyService,
|
|
1092
|
+
SSMLSpeechSpeeds,
|
|
1093
|
+
SolrProxyService,
|
|
753
1094
|
TaggingService,
|
|
754
1095
|
UserFolders,
|
|
755
1096
|
UserSettingsBookmarks,
|
|
756
1097
|
UserSettingsClientSettings,
|
|
757
1098
|
UserSettingsContinue,
|
|
758
|
-
UserSettingsMRU
|
|
1099
|
+
UserSettingsMRU,
|
|
1100
|
+
WritingTaskService
|
|
759
1101
|
});
|
|
760
1102
|
//# sourceMappingURL=index.cjs.map
|