@gyldendalas/gyldendal-divine-api 1.1.4 → 1.1.6

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/README.md CHANGED
@@ -27,11 +27,11 @@ mock server, 8000/8100 DynamoDB local, 8001 DynamoDB admin).
27
27
  | highlight | `http://localhost:3030` | `systime_highlight_server` docker-compose-development |
28
28
  | user settings | `http://localhost:4000` | `user_settings_service` Dockerfile |
29
29
  | pdf generator | `http://localhost:3050` | `pdf_generation_service` docker-compose-development |
30
- | writing task | `http://localhost:5000` | `systime_sso` local service block |
30
+ | writing task | `http://localhost:4050` | chosen; 5000 is taken by macOS AirPlay Receiver |
31
31
  | AI bot | `http://localhost:3100` | `ai-bot-service` main.py |
32
32
  | cookie consent log | `http://localhost:1337` | `cookie_consent_service` docker-compose |
33
- | tagging | `http://localhost:8010` | chosen; its uvicorn default 8000 is taken by user settings' local DynamoDB |
34
- | solr proxy | `http://localhost:8090` | chosen; its uvicorn default 8000 is taken by user settings' local DynamoDB |
33
+ | tagging | `http://localhost:8010` | chosen; its uvicorn default 8000 collides with the other local services |
34
+ | solr proxy | `http://localhost:8090` | chosen; its uvicorn default 8000 collides with the other local services |
35
35
  | polly | `http://localhost:3200` | chosen; its container port 3000 is taken by nuxt dev |
36
36
  | quiz (Gale CMS) | `https://galecms.test.tibalo.dk/api` | no local Gale, shared test instance |
37
37
 
package/dist/index.cjs CHANGED
@@ -559,6 +559,17 @@ var PdfGeneratorService = class extends BaseService {
559
559
  timeout
560
560
  })).json();
561
561
  }
562
+ async pdfFromPrint({ body, timeout = 3e3 }) {
563
+ const url = `${this.getUrlPrefix()}/print`;
564
+ const headers = new Headers();
565
+ headers.append("Content-Type", "application/json");
566
+ return (await this.postAsync({
567
+ url,
568
+ headers,
569
+ body: JSON.stringify(body),
570
+ timeout
571
+ })).json();
572
+ }
562
573
  async pdfFromNotes({ body, timeout = 3e3 }) {
563
574
  const url = `${this.getUrlPrefix()}/notes`;
564
575
  const headers = new Headers();
@@ -1139,17 +1150,79 @@ var QuizService = class extends BaseService {
1139
1150
  };
1140
1151
  //#endregion
1141
1152
  //#region src/services/writing_task_service.ts
1153
+ /**
1154
+ * The writing task service authenticates on the bearer token but still reads
1155
+ * the user from the request body, and only accepts the token when its `sub`
1156
+ * claim matches that `userId`. It also keys stored answers by user and
1157
+ * account, so both travel in every body here rather than being taken from the
1158
+ * token as the highlight service does.
1159
+ */
1142
1160
  var WritingTaskService = class extends BaseService {
1143
1161
  discoverUrlPrefix() {
1144
1162
  switch (this.environment) {
1145
1163
  case "production": return `https://writingtask.services.${this.baseDomain}`;
1146
1164
  case "development":
1147
1165
  case "testing": return `https://staging-writingtask.services.${this.baseDomain}`;
1148
- case "local": return `http://localhost:5000`;
1166
+ case "local": return `http://localhost:4050`;
1149
1167
  case "test": return `https://localhost:3010/services/writingtask`;
1150
1168
  default: throw new Error(`Unknown environment: ${this.environment}`);
1151
1169
  }
1152
1170
  }
1171
+ /** Answers stored for the given content ids, one bucket per cid. */
1172
+ async getResponse({ userId, isbn, pid, cids, timeout = 5e3 }) {
1173
+ const url = `${this.getUrlPrefix()}/getResponse`;
1174
+ const headers = new Headers();
1175
+ headers.set("Content-Type", "application/json");
1176
+ return (await this.postAsync({
1177
+ url,
1178
+ headers,
1179
+ body: JSON.stringify({
1180
+ userId,
1181
+ isbn,
1182
+ pid,
1183
+ cids,
1184
+ myaccountId: this.myAccountId
1185
+ }),
1186
+ timeout
1187
+ })).json();
1188
+ }
1189
+ /**
1190
+ * Stores an answer. The service upserts on the content id, so this covers
1191
+ * both the first save and every later one.
1192
+ */
1193
+ async newResponse({ userId, answer, timeout = 5e3 }) {
1194
+ const url = `${this.getUrlPrefix()}/newResponse`;
1195
+ const headers = new Headers();
1196
+ headers.set("Content-Type", "application/json");
1197
+ await this.postAsync({
1198
+ url,
1199
+ headers,
1200
+ body: JSON.stringify({
1201
+ ...answer,
1202
+ userId,
1203
+ myaccountId: this.myAccountId
1204
+ }),
1205
+ timeout
1206
+ });
1207
+ }
1208
+ /** Marks a stored answer deleted. */
1209
+ async deleteResponse({ userId, cid, isbn, pid, timeout = 5e3 }) {
1210
+ const url = `${this.getUrlPrefix()}/deleteResponse`;
1211
+ const headers = new Headers();
1212
+ headers.set("Content-Type", "application/json");
1213
+ await this.postAsync({
1214
+ url,
1215
+ headers,
1216
+ body: JSON.stringify({
1217
+ userId,
1218
+ cid,
1219
+ isbn,
1220
+ pid,
1221
+ myaccountId: this.myAccountId
1222
+ }),
1223
+ timeout
1224
+ });
1225
+ }
1153
1226
  };
1154
1227
  //#endregion
1155
1228
  //#region src/services/solr_proxy_service.ts