@examplary/sdk 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -88,6 +88,36 @@ var request = async (ctx, method, pathTemplate, pathKeys, queryKeys, hasBody, ar
88
88
  return response.data;
89
89
  };
90
90
 
91
+ // src/overrides/media.upload.ts
92
+ var override = async (ctx, args, options) => {
93
+ const contentType = args.contentType ?? "application/octet-stream";
94
+ const { data } = await ctx.axios.request({
95
+ ...options,
96
+ method: "GET",
97
+ url: "/media/upload",
98
+ params: {
99
+ contentType,
100
+ ...args.filename ? { filename: args.filename } : {},
101
+ ...args.type ? { type: args.type } : {}
102
+ }
103
+ });
104
+ if (args.content) {
105
+ const body = typeof Buffer !== "undefined" && !Buffer.isBuffer(args.content) ? Buffer.from(args.content) : args.content;
106
+ const uploadRes = await fetch(data.uploadUrl, {
107
+ method: "PUT",
108
+ headers: { "Content-Type": contentType },
109
+ body
110
+ });
111
+ if (!uploadRes.ok) {
112
+ throw new ExamplaryError(
113
+ `Upload failed: ${await uploadRes.text()}`,
114
+ "UploadError"
115
+ );
116
+ }
117
+ }
118
+ return data;
119
+ };
120
+
91
121
  // generated/sdk.ts
92
122
  var QuestionTypes = class {
93
123
  constructor(ctx) {
@@ -223,6 +253,167 @@ var EmbedSessions = class {
223
253
  return request(this.ctx, "DELETE", "/embed-sessions/{id}", ["id"], [], false, args, options);
224
254
  }
225
255
  };
256
+ var ExamsSessionsComments = class {
257
+ constructor(ctx) {
258
+ this.ctx = ctx;
259
+ }
260
+ list(arg, options) {
261
+ const args = arg;
262
+ return request(this.ctx, "GET", "/exams/{examId}/sessions/{sessionId}/comments", ["examId", "sessionId"], [], false, args, options);
263
+ }
264
+ create(arg, options) {
265
+ const args = arg;
266
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/comments", ["examId", "sessionId"], [], true, args, options);
267
+ }
268
+ update(arg, options) {
269
+ const args = arg;
270
+ return request(this.ctx, "PATCH", "/exams/{examId}/sessions/{sessionId}/comments/{commentId}", ["examId", "sessionId", "commentId"], [], true, args, options);
271
+ }
272
+ delete(arg, options) {
273
+ const args = arg;
274
+ return request(this.ctx, "DELETE", "/exams/{examId}/sessions/{sessionId}/comments/{commentId}", ["examId", "sessionId", "commentId"], [], false, args, options);
275
+ }
276
+ };
277
+ var ExamsSessions = class {
278
+ constructor(ctx) {
279
+ this.ctx = ctx;
280
+ this.comments = new ExamsSessionsComments(this.ctx);
281
+ }
282
+ list(arg, options) {
283
+ const args = typeof arg === "string" ? { examId: arg } : arg;
284
+ return request(this.ctx, "GET", "/exams/{examId}/sessions", ["examId"], [], false, args, options);
285
+ }
286
+ import(arg, options) {
287
+ const args = arg;
288
+ return request(this.ctx, "POST", "/exams/{examId}/sessions", ["examId"], [], true, args, options);
289
+ }
290
+ scan(arg, options) {
291
+ const args = typeof arg === "string" ? { examId: arg } : arg;
292
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/scan", ["examId"], [], false, args, options);
293
+ }
294
+ scanDocument(arg, options) {
295
+ const args = arg;
296
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/scan-document", ["examId"], [], true, args, options);
297
+ }
298
+ get(arg, options) {
299
+ const args = arg;
300
+ return request(this.ctx, "GET", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
301
+ }
302
+ delete(arg, options) {
303
+ const args = arg;
304
+ return request(this.ctx, "DELETE", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
305
+ }
306
+ saveFeedback(arg, options) {
307
+ const args = arg;
308
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/feedback", ["examId", "sessionId"], [], true, args, options);
309
+ }
310
+ saveOverallFeedback(arg, options) {
311
+ const args = arg;
312
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/overall-feedback", ["examId", "sessionId"], [], true, args, options);
313
+ }
314
+ generateOverallFeedback(arg, options) {
315
+ const args = arg;
316
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/generate-overall-feedback", ["examId", "sessionId"], [], false, args, options);
317
+ }
318
+ acceptAllSuggestions(arg, options) {
319
+ const args = arg;
320
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/accept-all", ["examId", "sessionId"], [], false, args, options);
321
+ }
322
+ acceptSuggestion(arg, options) {
323
+ const args = arg;
324
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/{questionId}/accept", ["examId", "sessionId", "questionId"], [], false, args, options);
325
+ }
326
+ editAnswer(arg, options) {
327
+ const args = arg;
328
+ return request(this.ctx, "PATCH", "/exams/{examId}/sessions/{sessionId}/answers/{questionId}", ["examId", "sessionId", "questionId"], [], true, args, options);
329
+ }
330
+ };
331
+ var ExamsQuestions = class {
332
+ constructor(ctx) {
333
+ this.ctx = ctx;
334
+ }
335
+ import(arg, options) {
336
+ const args = arg;
337
+ return request(this.ctx, "POST", "/exams/{examId}/questions/import", ["examId"], [], true, args, options);
338
+ }
339
+ generate(arg, options) {
340
+ const args = arg;
341
+ return request(this.ctx, "POST", "/exams/{examId}/questions/generate", ["examId"], [], true, args, options);
342
+ }
343
+ get(arg, options) {
344
+ const args = arg;
345
+ return request(this.ctx, "GET", "/exams/{examId}/questions/{questionId}", ["examId", "questionId"], ["format"], false, args, options);
346
+ }
347
+ regenerate(arg, options) {
348
+ const args = arg;
349
+ return request(this.ctx, "POST", "/exams/{examId}/questions/{questionId}/generate", ["examId", "questionId"], [], true, args, options);
350
+ }
351
+ };
352
+ var ExamsExport = class {
353
+ constructor(ctx) {
354
+ this.ctx = ctx;
355
+ }
356
+ qti3Zip(arg, options) {
357
+ const args = typeof arg === "string" ? { examId: arg } : arg;
358
+ return request(this.ctx, "POST", "/exams/{examId}/export/qti3-zip", ["examId"], [], false, args, options);
359
+ }
360
+ qti21Zip(arg, options) {
361
+ const args = typeof arg === "string" ? { examId: arg } : arg;
362
+ return request(this.ctx, "POST", "/exams/{examId}/export/qti21-zip", ["examId"], [], false, args, options);
363
+ }
364
+ };
365
+ var Exams = class {
366
+ constructor(ctx) {
367
+ this.ctx = ctx;
368
+ this.sessions = new ExamsSessions(this.ctx);
369
+ this.questions = new ExamsQuestions(this.ctx);
370
+ this.export = new ExamsExport(this.ctx);
371
+ }
372
+ list(arg, options) {
373
+ const args = arg;
374
+ return request(this.ctx, "GET", "/exams", [], ["folder", "role"], false, args, options);
375
+ }
376
+ create(arg, options) {
377
+ const args = arg;
378
+ return request(this.ctx, "POST", "/exams", [], [], true, args, options);
379
+ }
380
+ import(arg, options) {
381
+ const args = arg;
382
+ return request(this.ctx, "POST", "/exams/import", [], [], true, args, options);
383
+ }
384
+ get(arg, options) {
385
+ const args = typeof arg === "string" ? { id: arg } : arg;
386
+ return request(this.ctx, "GET", "/exams/{id}", ["id"], [], false, args, options);
387
+ }
388
+ update(arg, options) {
389
+ const args = typeof arg === "string" ? { id: arg } : arg;
390
+ return request(this.ctx, "POST", "/exams/{id}", ["id"], [], false, args, options);
391
+ }
392
+ delete(arg, options) {
393
+ const args = typeof arg === "string" ? { id: arg } : arg;
394
+ return request(this.ctx, "DELETE", "/exams/{id}", ["id"], [], false, args, options);
395
+ }
396
+ duplicate(arg, options) {
397
+ const args = arg;
398
+ return request(this.ctx, "POST", "/exams/{examId}/duplicate", ["examId"], [], true, args, options);
399
+ }
400
+ print(arg, options) {
401
+ const args = typeof arg === "string" ? { examId: arg } : arg;
402
+ return request(this.ctx, "POST", "/exams/{examId}/print", ["examId"], [], false, args, options);
403
+ }
404
+ startGeneration(arg, options) {
405
+ const args = typeof arg === "string" ? { examId: arg } : arg;
406
+ return request(this.ctx, "POST", "/exams/{examId}/generate", ["examId"], [], false, args, options);
407
+ }
408
+ cancelGeneration(arg, options) {
409
+ const args = typeof arg === "string" ? { examId: arg } : arg;
410
+ return request(this.ctx, "POST", "/exams/{examId}/generate/cancel", ["examId"], [], false, args, options);
411
+ }
412
+ getContextSuggestions(arg, options) {
413
+ const args = typeof arg === "string" ? { examId: arg } : arg;
414
+ return request(this.ctx, "GET", "/exams/{examId}/context-suggestions", ["examId"], [], false, args, options);
415
+ }
416
+ };
226
417
  var Me = class {
227
418
  constructor(ctx) {
228
419
  this.ctx = ctx;
@@ -240,9 +431,15 @@ var Media = class {
240
431
  constructor(ctx) {
241
432
  this.ctx = ctx;
242
433
  }
243
- upload(arg, options) {
244
- const args = arg;
245
- return request(this.ctx, "GET", "/media/upload", [], ["filename", "type", "contentType"], false, args, options);
434
+ /**
435
+ * Get file upload URL
436
+ *
437
+ * Returns a signed URL for uploading a file, and a public URL for accessing it afterwards.
438
+ *
439
+ * API endpoint: `GET /media/upload`
440
+ */
441
+ upload(args, options) {
442
+ return override(this.ctx, args, options);
246
443
  }
247
444
  };
248
445
  var OrgCustomDomain = class {
@@ -403,145 +600,6 @@ var Users = class {
403
600
  return request(this.ctx, "DELETE", "/users/{id}", ["id"], [], false, args, options);
404
601
  }
405
602
  };
406
- var ExamsSessions = class {
407
- constructor(ctx) {
408
- this.ctx = ctx;
409
- }
410
- list(arg, options) {
411
- const args = typeof arg === "string" ? { examId: arg } : arg;
412
- return request(this.ctx, "GET", "/exams/{examId}/sessions", ["examId"], [], false, args, options);
413
- }
414
- import(arg, options) {
415
- const args = arg;
416
- return request(this.ctx, "POST", "/exams/{examId}/sessions", ["examId"], [], true, args, options);
417
- }
418
- scan(arg, options) {
419
- const args = typeof arg === "string" ? { examId: arg } : arg;
420
- return request(this.ctx, "POST", "/exams/{examId}/sessions/scan", ["examId"], [], false, args, options);
421
- }
422
- scanDocument(arg, options) {
423
- const args = arg;
424
- return request(this.ctx, "POST", "/exams/{examId}/sessions/scan-document", ["examId"], [], true, args, options);
425
- }
426
- get(arg, options) {
427
- const args = arg;
428
- return request(this.ctx, "GET", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
429
- }
430
- delete(arg, options) {
431
- const args = arg;
432
- return request(this.ctx, "DELETE", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
433
- }
434
- saveFeedback(arg, options) {
435
- const args = arg;
436
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/feedback", ["examId", "sessionId"], [], true, args, options);
437
- }
438
- saveOverallFeedback(arg, options) {
439
- const args = arg;
440
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/overall-feedback", ["examId", "sessionId"], [], true, args, options);
441
- }
442
- generateOverallFeedback(arg, options) {
443
- const args = arg;
444
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/generate-overall-feedback", ["examId", "sessionId"], [], false, args, options);
445
- }
446
- acceptAllSuggestions(arg, options) {
447
- const args = arg;
448
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/accept-all", ["examId", "sessionId"], [], false, args, options);
449
- }
450
- acceptSuggestion(arg, options) {
451
- const args = arg;
452
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/{questionId}/accept", ["examId", "sessionId", "questionId"], [], false, args, options);
453
- }
454
- editAnswer(arg, options) {
455
- const args = arg;
456
- return request(this.ctx, "PATCH", "/exams/{examId}/sessions/{sessionId}/answers/{questionId}", ["examId", "sessionId", "questionId"], [], true, args, options);
457
- }
458
- };
459
- var ExamsQuestions = class {
460
- constructor(ctx) {
461
- this.ctx = ctx;
462
- }
463
- import(arg, options) {
464
- const args = arg;
465
- return request(this.ctx, "POST", "/exams/{examId}/questions/import", ["examId"], [], true, args, options);
466
- }
467
- generate(arg, options) {
468
- const args = arg;
469
- return request(this.ctx, "POST", "/exams/{examId}/questions/generate", ["examId"], [], true, args, options);
470
- }
471
- get(arg, options) {
472
- const args = arg;
473
- return request(this.ctx, "GET", "/exams/{examId}/questions/{questionId}", ["examId", "questionId"], ["format"], false, args, options);
474
- }
475
- regenerate(arg, options) {
476
- const args = arg;
477
- return request(this.ctx, "POST", "/exams/{examId}/questions/{questionId}/generate", ["examId", "questionId"], [], true, args, options);
478
- }
479
- };
480
- var ExamsExport = class {
481
- constructor(ctx) {
482
- this.ctx = ctx;
483
- }
484
- qti3Zip(arg, options) {
485
- const args = typeof arg === "string" ? { examId: arg } : arg;
486
- return request(this.ctx, "POST", "/exams/{examId}/export/qti3-zip", ["examId"], [], false, args, options);
487
- }
488
- qti21Zip(arg, options) {
489
- const args = typeof arg === "string" ? { examId: arg } : arg;
490
- return request(this.ctx, "POST", "/exams/{examId}/export/qti21-zip", ["examId"], [], false, args, options);
491
- }
492
- };
493
- var Exams = class {
494
- constructor(ctx) {
495
- this.ctx = ctx;
496
- this.sessions = new ExamsSessions(this.ctx);
497
- this.questions = new ExamsQuestions(this.ctx);
498
- this.export = new ExamsExport(this.ctx);
499
- }
500
- list(arg, options) {
501
- const args = arg;
502
- return request(this.ctx, "GET", "/exams", [], ["folder", "role"], false, args, options);
503
- }
504
- create(arg, options) {
505
- const args = arg;
506
- return request(this.ctx, "POST", "/exams", [], [], true, args, options);
507
- }
508
- import(arg, options) {
509
- const args = arg;
510
- return request(this.ctx, "POST", "/exams/import", [], [], true, args, options);
511
- }
512
- get(arg, options) {
513
- const args = typeof arg === "string" ? { id: arg } : arg;
514
- return request(this.ctx, "GET", "/exams/{id}", ["id"], [], false, args, options);
515
- }
516
- update(arg, options) {
517
- const args = typeof arg === "string" ? { id: arg } : arg;
518
- return request(this.ctx, "POST", "/exams/{id}", ["id"], [], false, args, options);
519
- }
520
- delete(arg, options) {
521
- const args = typeof arg === "string" ? { id: arg } : arg;
522
- return request(this.ctx, "DELETE", "/exams/{id}", ["id"], [], false, args, options);
523
- }
524
- duplicate(arg, options) {
525
- const args = arg;
526
- return request(this.ctx, "POST", "/exams/{examId}/duplicate", ["examId"], [], true, args, options);
527
- }
528
- print(arg, options) {
529
- const args = typeof arg === "string" ? { examId: arg } : arg;
530
- return request(this.ctx, "POST", "/exams/{examId}/print", ["examId"], [], false, args, options);
531
- }
532
- startGeneration(arg, options) {
533
- const args = typeof arg === "string" ? { examId: arg } : arg;
534
- return request(this.ctx, "POST", "/exams/{examId}/generate", ["examId"], [], false, args, options);
535
- }
536
- cancelGeneration(arg, options) {
537
- const args = typeof arg === "string" ? { examId: arg } : arg;
538
- return request(this.ctx, "POST", "/exams/{examId}/generate/cancel", ["examId"], [], false, args, options);
539
- }
540
- getContextSuggestions(arg, options) {
541
- const args = typeof arg === "string" ? { examId: arg } : arg;
542
- return request(this.ctx, "GET", "/exams/{examId}/context-suggestions", ["examId"], [], false, args, options);
543
- }
544
- };
545
603
  var PracticeSpacesStudents = class {
546
604
  constructor(ctx) {
547
605
  this.ctx = ctx;
@@ -755,6 +813,7 @@ var Examplary = class {
755
813
  this.library = new Library(this.ctx);
756
814
  this.oauth = new Oauth(this.ctx);
757
815
  this.embedSessions = new EmbedSessions(this.ctx);
816
+ this.exams = new Exams(this.ctx);
758
817
  this.me = new Me(this.ctx);
759
818
  this.media = new Media(this.ctx);
760
819
  this.org = new Org(this.ctx);
@@ -765,7 +824,6 @@ var Examplary = class {
765
824
  this.permissions = new Permissions(this.ctx);
766
825
  this.studentLevels = new StudentLevels(this.ctx);
767
826
  this.users = new Users(this.ctx);
768
- this.exams = new Exams(this.ctx);
769
827
  this.practiceSpaces = new PracticeSpaces(this.ctx);
770
828
  this.sourceMaterials = new SourceMaterials(this.ctx);
771
829
  this.folders = new Folders(this.ctx);