@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.js CHANGED
@@ -123,6 +123,36 @@ var request = async (ctx, method, pathTemplate, pathKeys, queryKeys, hasBody, ar
123
123
  return response.data;
124
124
  };
125
125
 
126
+ // src/overrides/media.upload.ts
127
+ var override = async (ctx, args, options) => {
128
+ const contentType = args.contentType ?? "application/octet-stream";
129
+ const { data } = await ctx.axios.request({
130
+ ...options,
131
+ method: "GET",
132
+ url: "/media/upload",
133
+ params: {
134
+ contentType,
135
+ ...args.filename ? { filename: args.filename } : {},
136
+ ...args.type ? { type: args.type } : {}
137
+ }
138
+ });
139
+ if (args.content) {
140
+ const body = typeof Buffer !== "undefined" && !Buffer.isBuffer(args.content) ? Buffer.from(args.content) : args.content;
141
+ const uploadRes = await fetch(data.uploadUrl, {
142
+ method: "PUT",
143
+ headers: { "Content-Type": contentType },
144
+ body
145
+ });
146
+ if (!uploadRes.ok) {
147
+ throw new ExamplaryError(
148
+ `Upload failed: ${await uploadRes.text()}`,
149
+ "UploadError"
150
+ );
151
+ }
152
+ }
153
+ return data;
154
+ };
155
+
126
156
  // generated/sdk.ts
127
157
  var QuestionTypes = class {
128
158
  constructor(ctx) {
@@ -258,6 +288,167 @@ var EmbedSessions = class {
258
288
  return request(this.ctx, "DELETE", "/embed-sessions/{id}", ["id"], [], false, args, options);
259
289
  }
260
290
  };
291
+ var ExamsSessionsComments = class {
292
+ constructor(ctx) {
293
+ this.ctx = ctx;
294
+ }
295
+ list(arg, options) {
296
+ const args = arg;
297
+ return request(this.ctx, "GET", "/exams/{examId}/sessions/{sessionId}/comments", ["examId", "sessionId"], [], false, args, options);
298
+ }
299
+ create(arg, options) {
300
+ const args = arg;
301
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/comments", ["examId", "sessionId"], [], true, args, options);
302
+ }
303
+ update(arg, options) {
304
+ const args = arg;
305
+ return request(this.ctx, "PATCH", "/exams/{examId}/sessions/{sessionId}/comments/{commentId}", ["examId", "sessionId", "commentId"], [], true, args, options);
306
+ }
307
+ delete(arg, options) {
308
+ const args = arg;
309
+ return request(this.ctx, "DELETE", "/exams/{examId}/sessions/{sessionId}/comments/{commentId}", ["examId", "sessionId", "commentId"], [], false, args, options);
310
+ }
311
+ };
312
+ var ExamsSessions = class {
313
+ constructor(ctx) {
314
+ this.ctx = ctx;
315
+ this.comments = new ExamsSessionsComments(this.ctx);
316
+ }
317
+ list(arg, options) {
318
+ const args = typeof arg === "string" ? { examId: arg } : arg;
319
+ return request(this.ctx, "GET", "/exams/{examId}/sessions", ["examId"], [], false, args, options);
320
+ }
321
+ import(arg, options) {
322
+ const args = arg;
323
+ return request(this.ctx, "POST", "/exams/{examId}/sessions", ["examId"], [], true, args, options);
324
+ }
325
+ scan(arg, options) {
326
+ const args = typeof arg === "string" ? { examId: arg } : arg;
327
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/scan", ["examId"], [], false, args, options);
328
+ }
329
+ scanDocument(arg, options) {
330
+ const args = arg;
331
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/scan-document", ["examId"], [], true, args, options);
332
+ }
333
+ get(arg, options) {
334
+ const args = arg;
335
+ return request(this.ctx, "GET", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
336
+ }
337
+ delete(arg, options) {
338
+ const args = arg;
339
+ return request(this.ctx, "DELETE", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
340
+ }
341
+ saveFeedback(arg, options) {
342
+ const args = arg;
343
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/feedback", ["examId", "sessionId"], [], true, args, options);
344
+ }
345
+ saveOverallFeedback(arg, options) {
346
+ const args = arg;
347
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/overall-feedback", ["examId", "sessionId"], [], true, args, options);
348
+ }
349
+ generateOverallFeedback(arg, options) {
350
+ const args = arg;
351
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/generate-overall-feedback", ["examId", "sessionId"], [], false, args, options);
352
+ }
353
+ acceptAllSuggestions(arg, options) {
354
+ const args = arg;
355
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/accept-all", ["examId", "sessionId"], [], false, args, options);
356
+ }
357
+ acceptSuggestion(arg, options) {
358
+ const args = arg;
359
+ return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/{questionId}/accept", ["examId", "sessionId", "questionId"], [], false, args, options);
360
+ }
361
+ editAnswer(arg, options) {
362
+ const args = arg;
363
+ return request(this.ctx, "PATCH", "/exams/{examId}/sessions/{sessionId}/answers/{questionId}", ["examId", "sessionId", "questionId"], [], true, args, options);
364
+ }
365
+ };
366
+ var ExamsQuestions = class {
367
+ constructor(ctx) {
368
+ this.ctx = ctx;
369
+ }
370
+ import(arg, options) {
371
+ const args = arg;
372
+ return request(this.ctx, "POST", "/exams/{examId}/questions/import", ["examId"], [], true, args, options);
373
+ }
374
+ generate(arg, options) {
375
+ const args = arg;
376
+ return request(this.ctx, "POST", "/exams/{examId}/questions/generate", ["examId"], [], true, args, options);
377
+ }
378
+ get(arg, options) {
379
+ const args = arg;
380
+ return request(this.ctx, "GET", "/exams/{examId}/questions/{questionId}", ["examId", "questionId"], ["format"], false, args, options);
381
+ }
382
+ regenerate(arg, options) {
383
+ const args = arg;
384
+ return request(this.ctx, "POST", "/exams/{examId}/questions/{questionId}/generate", ["examId", "questionId"], [], true, args, options);
385
+ }
386
+ };
387
+ var ExamsExport = class {
388
+ constructor(ctx) {
389
+ this.ctx = ctx;
390
+ }
391
+ qti3Zip(arg, options) {
392
+ const args = typeof arg === "string" ? { examId: arg } : arg;
393
+ return request(this.ctx, "POST", "/exams/{examId}/export/qti3-zip", ["examId"], [], false, args, options);
394
+ }
395
+ qti21Zip(arg, options) {
396
+ const args = typeof arg === "string" ? { examId: arg } : arg;
397
+ return request(this.ctx, "POST", "/exams/{examId}/export/qti21-zip", ["examId"], [], false, args, options);
398
+ }
399
+ };
400
+ var Exams = class {
401
+ constructor(ctx) {
402
+ this.ctx = ctx;
403
+ this.sessions = new ExamsSessions(this.ctx);
404
+ this.questions = new ExamsQuestions(this.ctx);
405
+ this.export = new ExamsExport(this.ctx);
406
+ }
407
+ list(arg, options) {
408
+ const args = arg;
409
+ return request(this.ctx, "GET", "/exams", [], ["folder", "role"], false, args, options);
410
+ }
411
+ create(arg, options) {
412
+ const args = arg;
413
+ return request(this.ctx, "POST", "/exams", [], [], true, args, options);
414
+ }
415
+ import(arg, options) {
416
+ const args = arg;
417
+ return request(this.ctx, "POST", "/exams/import", [], [], true, args, options);
418
+ }
419
+ get(arg, options) {
420
+ const args = typeof arg === "string" ? { id: arg } : arg;
421
+ return request(this.ctx, "GET", "/exams/{id}", ["id"], [], false, args, options);
422
+ }
423
+ update(arg, options) {
424
+ const args = typeof arg === "string" ? { id: arg } : arg;
425
+ return request(this.ctx, "POST", "/exams/{id}", ["id"], [], false, args, options);
426
+ }
427
+ delete(arg, options) {
428
+ const args = typeof arg === "string" ? { id: arg } : arg;
429
+ return request(this.ctx, "DELETE", "/exams/{id}", ["id"], [], false, args, options);
430
+ }
431
+ duplicate(arg, options) {
432
+ const args = arg;
433
+ return request(this.ctx, "POST", "/exams/{examId}/duplicate", ["examId"], [], true, args, options);
434
+ }
435
+ print(arg, options) {
436
+ const args = typeof arg === "string" ? { examId: arg } : arg;
437
+ return request(this.ctx, "POST", "/exams/{examId}/print", ["examId"], [], false, args, options);
438
+ }
439
+ startGeneration(arg, options) {
440
+ const args = typeof arg === "string" ? { examId: arg } : arg;
441
+ return request(this.ctx, "POST", "/exams/{examId}/generate", ["examId"], [], false, args, options);
442
+ }
443
+ cancelGeneration(arg, options) {
444
+ const args = typeof arg === "string" ? { examId: arg } : arg;
445
+ return request(this.ctx, "POST", "/exams/{examId}/generate/cancel", ["examId"], [], false, args, options);
446
+ }
447
+ getContextSuggestions(arg, options) {
448
+ const args = typeof arg === "string" ? { examId: arg } : arg;
449
+ return request(this.ctx, "GET", "/exams/{examId}/context-suggestions", ["examId"], [], false, args, options);
450
+ }
451
+ };
261
452
  var Me = class {
262
453
  constructor(ctx) {
263
454
  this.ctx = ctx;
@@ -275,9 +466,15 @@ var Media = class {
275
466
  constructor(ctx) {
276
467
  this.ctx = ctx;
277
468
  }
278
- upload(arg, options) {
279
- const args = arg;
280
- return request(this.ctx, "GET", "/media/upload", [], ["filename", "type", "contentType"], false, args, options);
469
+ /**
470
+ * Get file upload URL
471
+ *
472
+ * Returns a signed URL for uploading a file, and a public URL for accessing it afterwards.
473
+ *
474
+ * API endpoint: `GET /media/upload`
475
+ */
476
+ upload(args, options) {
477
+ return override(this.ctx, args, options);
281
478
  }
282
479
  };
283
480
  var OrgCustomDomain = class {
@@ -438,145 +635,6 @@ var Users = class {
438
635
  return request(this.ctx, "DELETE", "/users/{id}", ["id"], [], false, args, options);
439
636
  }
440
637
  };
441
- var ExamsSessions = class {
442
- constructor(ctx) {
443
- this.ctx = ctx;
444
- }
445
- list(arg, options) {
446
- const args = typeof arg === "string" ? { examId: arg } : arg;
447
- return request(this.ctx, "GET", "/exams/{examId}/sessions", ["examId"], [], false, args, options);
448
- }
449
- import(arg, options) {
450
- const args = arg;
451
- return request(this.ctx, "POST", "/exams/{examId}/sessions", ["examId"], [], true, args, options);
452
- }
453
- scan(arg, options) {
454
- const args = typeof arg === "string" ? { examId: arg } : arg;
455
- return request(this.ctx, "POST", "/exams/{examId}/sessions/scan", ["examId"], [], false, args, options);
456
- }
457
- scanDocument(arg, options) {
458
- const args = arg;
459
- return request(this.ctx, "POST", "/exams/{examId}/sessions/scan-document", ["examId"], [], true, args, options);
460
- }
461
- get(arg, options) {
462
- const args = arg;
463
- return request(this.ctx, "GET", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
464
- }
465
- delete(arg, options) {
466
- const args = arg;
467
- return request(this.ctx, "DELETE", "/exams/{examId}/sessions/{sessionId}", ["examId", "sessionId"], [], false, args, options);
468
- }
469
- saveFeedback(arg, options) {
470
- const args = arg;
471
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/feedback", ["examId", "sessionId"], [], true, args, options);
472
- }
473
- saveOverallFeedback(arg, options) {
474
- const args = arg;
475
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/overall-feedback", ["examId", "sessionId"], [], true, args, options);
476
- }
477
- generateOverallFeedback(arg, options) {
478
- const args = arg;
479
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/generate-overall-feedback", ["examId", "sessionId"], [], false, args, options);
480
- }
481
- acceptAllSuggestions(arg, options) {
482
- const args = arg;
483
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/accept-all", ["examId", "sessionId"], [], false, args, options);
484
- }
485
- acceptSuggestion(arg, options) {
486
- const args = arg;
487
- return request(this.ctx, "POST", "/exams/{examId}/sessions/{sessionId}/suggestions/{questionId}/accept", ["examId", "sessionId", "questionId"], [], false, args, options);
488
- }
489
- editAnswer(arg, options) {
490
- const args = arg;
491
- return request(this.ctx, "PATCH", "/exams/{examId}/sessions/{sessionId}/answers/{questionId}", ["examId", "sessionId", "questionId"], [], true, args, options);
492
- }
493
- };
494
- var ExamsQuestions = class {
495
- constructor(ctx) {
496
- this.ctx = ctx;
497
- }
498
- import(arg, options) {
499
- const args = arg;
500
- return request(this.ctx, "POST", "/exams/{examId}/questions/import", ["examId"], [], true, args, options);
501
- }
502
- generate(arg, options) {
503
- const args = arg;
504
- return request(this.ctx, "POST", "/exams/{examId}/questions/generate", ["examId"], [], true, args, options);
505
- }
506
- get(arg, options) {
507
- const args = arg;
508
- return request(this.ctx, "GET", "/exams/{examId}/questions/{questionId}", ["examId", "questionId"], ["format"], false, args, options);
509
- }
510
- regenerate(arg, options) {
511
- const args = arg;
512
- return request(this.ctx, "POST", "/exams/{examId}/questions/{questionId}/generate", ["examId", "questionId"], [], true, args, options);
513
- }
514
- };
515
- var ExamsExport = class {
516
- constructor(ctx) {
517
- this.ctx = ctx;
518
- }
519
- qti3Zip(arg, options) {
520
- const args = typeof arg === "string" ? { examId: arg } : arg;
521
- return request(this.ctx, "POST", "/exams/{examId}/export/qti3-zip", ["examId"], [], false, args, options);
522
- }
523
- qti21Zip(arg, options) {
524
- const args = typeof arg === "string" ? { examId: arg } : arg;
525
- return request(this.ctx, "POST", "/exams/{examId}/export/qti21-zip", ["examId"], [], false, args, options);
526
- }
527
- };
528
- var Exams = class {
529
- constructor(ctx) {
530
- this.ctx = ctx;
531
- this.sessions = new ExamsSessions(this.ctx);
532
- this.questions = new ExamsQuestions(this.ctx);
533
- this.export = new ExamsExport(this.ctx);
534
- }
535
- list(arg, options) {
536
- const args = arg;
537
- return request(this.ctx, "GET", "/exams", [], ["folder", "role"], false, args, options);
538
- }
539
- create(arg, options) {
540
- const args = arg;
541
- return request(this.ctx, "POST", "/exams", [], [], true, args, options);
542
- }
543
- import(arg, options) {
544
- const args = arg;
545
- return request(this.ctx, "POST", "/exams/import", [], [], true, args, options);
546
- }
547
- get(arg, options) {
548
- const args = typeof arg === "string" ? { id: arg } : arg;
549
- return request(this.ctx, "GET", "/exams/{id}", ["id"], [], false, args, options);
550
- }
551
- update(arg, options) {
552
- const args = typeof arg === "string" ? { id: arg } : arg;
553
- return request(this.ctx, "POST", "/exams/{id}", ["id"], [], false, args, options);
554
- }
555
- delete(arg, options) {
556
- const args = typeof arg === "string" ? { id: arg } : arg;
557
- return request(this.ctx, "DELETE", "/exams/{id}", ["id"], [], false, args, options);
558
- }
559
- duplicate(arg, options) {
560
- const args = arg;
561
- return request(this.ctx, "POST", "/exams/{examId}/duplicate", ["examId"], [], true, args, options);
562
- }
563
- print(arg, options) {
564
- const args = typeof arg === "string" ? { examId: arg } : arg;
565
- return request(this.ctx, "POST", "/exams/{examId}/print", ["examId"], [], false, args, options);
566
- }
567
- startGeneration(arg, options) {
568
- const args = typeof arg === "string" ? { examId: arg } : arg;
569
- return request(this.ctx, "POST", "/exams/{examId}/generate", ["examId"], [], false, args, options);
570
- }
571
- cancelGeneration(arg, options) {
572
- const args = typeof arg === "string" ? { examId: arg } : arg;
573
- return request(this.ctx, "POST", "/exams/{examId}/generate/cancel", ["examId"], [], false, args, options);
574
- }
575
- getContextSuggestions(arg, options) {
576
- const args = typeof arg === "string" ? { examId: arg } : arg;
577
- return request(this.ctx, "GET", "/exams/{examId}/context-suggestions", ["examId"], [], false, args, options);
578
- }
579
- };
580
638
  var PracticeSpacesStudents = class {
581
639
  constructor(ctx) {
582
640
  this.ctx = ctx;
@@ -790,6 +848,7 @@ var Examplary = class {
790
848
  this.library = new Library(this.ctx);
791
849
  this.oauth = new Oauth(this.ctx);
792
850
  this.embedSessions = new EmbedSessions(this.ctx);
851
+ this.exams = new Exams(this.ctx);
793
852
  this.me = new Me(this.ctx);
794
853
  this.media = new Media(this.ctx);
795
854
  this.org = new Org(this.ctx);
@@ -800,7 +859,6 @@ var Examplary = class {
800
859
  this.permissions = new Permissions(this.ctx);
801
860
  this.studentLevels = new StudentLevels(this.ctx);
802
861
  this.users = new Users(this.ctx);
803
- this.exams = new Exams(this.ctx);
804
862
  this.practiceSpaces = new PracticeSpaces(this.ctx);
805
863
  this.sourceMaterials = new SourceMaterials(this.ctx);
806
864
  this.folders = new Folders(this.ctx);