@edpire/sdk 0.15.0 → 0.16.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/react.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { RuntimeAnswer, AssessmentAnswers, QuestionRuntimeProps, AssessmentContent } from '@youssefalmia/edpire-runtime';
3
- export { RuntimeAnswer } from '@youssefalmia/edpire-runtime';
2
+ import { RuntimeAnswer, AssessmentAnswers, QuestionRuntimeProps, AssessmentContent, RuntimeAnswerSheetHandler } from '@youssefalmia/edpire-runtime';
3
+ export { PageTurn, ReadingErrorCode, RuntimeAnswer } from '@youssefalmia/edpire-runtime';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { RichContent, ContentAST } from '@youssefalmia/edpire-schema/authoring';
6
- import { AnswerPhoto, RichContent as RichContent$1 } from '@youssefalmia/edpire-schema';
6
+ import { AnswerPhoto, RichContent as RichContent$1, ReadingLine } from '@youssefalmia/edpire-schema';
7
7
 
8
8
  /**
9
9
  * EdpireQuestion — public React component for rendering a single question.
@@ -534,6 +534,13 @@ interface AssessmentShellProps {
534
534
  * typed text and formulas only.
535
535
  */
536
536
  answerSheetHandler?: QuestionRuntimeProps["answerSheetHandler"];
537
+ /**
538
+ * "Photograph my copy" beside Submit (0.16.0+): the learner photographs every page of a paper
539
+ * copy once and each part goes into its question. Needs an `answerSheetHandler` that stores
540
+ * photos first and an answer that takes photos. Off by default (Edpire turns it on per
541
+ * workspace while it is tried).
542
+ */
543
+ wholeCopy?: boolean;
537
544
  /**
538
545
  * "Report a marking mistake" under each automatically marked question once the paper is
539
546
  * submitted (T189): the host sends the learner's reason to the teacher. Without it, no button.
@@ -555,28 +562,78 @@ interface AssessmentShellProps {
555
562
  */
556
563
  fallbackLogoUrl?: string;
557
564
  }
558
- declare function AssessmentShell({ assessment, meta, scoreHidden: scoreHiddenProp, isForm: isFormProp, requiredQuestionIds, locale, branding, timeLimitMinutes, startedAt, initialAnswers, onAnswersChange, saveState, resumed, onSubmit, review, onViewReport, reportLabel, onBack, backLabel, allowReset, onReset, overlayConfig, contained, layout, onClose, mediaHandler, answerSheetHandler, onReportGrade, onAddAnnex, fallbackLogoUrl, }: AssessmentShellProps): react_jsx_runtime.JSX.Element;
565
+ declare function AssessmentShell({ assessment, meta, scoreHidden: scoreHiddenProp, isForm: isFormProp, requiredQuestionIds, locale, branding, timeLimitMinutes, startedAt, initialAnswers, onAnswersChange, saveState, resumed, onSubmit, review, onViewReport, reportLabel, onBack, backLabel, allowReset, onReset, overlayConfig, contained, layout, onClose, mediaHandler, answerSheetHandler, wholeCopy, onReportGrade, onAddAnnex, fallbackLogoUrl, }: AssessmentShellProps): react_jsx_runtime.JSX.Element;
559
566
 
560
567
  /**
561
- * The answer sheet's reader (T189), built from two calls a host makes to Edpire: read photos of
562
- * the paper copy, read a handwritten formula. Used by the Edpire app (its own attempt routes) and
563
- * by the embed (POST /api/v1/embed/read with the embed token); a host can pass its own instead.
568
+ * The answer sheet's reader (T189), built from the calls a host makes to Edpire: store a photo of
569
+ * the paper copy, read stored photos, read a handwritten formula. Used by the Edpire app (its own
570
+ * attempt routes) and by the embed (POST /api/v1/embed/read with the embed token); a host can pass
571
+ * its own instead.
572
+ *
573
+ * Stored first (step 43, D28): with `signPhoto`, every photo is uploaded to storage before it is
574
+ * read, and the readers get stored photos only. The pad's small PNG is the one image sent inline.
575
+ * Streamed (step 44): with `streamPhotos`, lines reach the sheet as they are read, and a sideways
576
+ * page comes back as `turns` for the panel to turn and read again.
564
577
  */
565
578
 
566
- type AnswerSheetHandler = NonNullable<QuestionRuntimeProps["answerSheetHandler"]>;
579
+ /**
580
+ * The runtime's answer sheet handler (3.24.0): `uploadPhoto` and `readPages` when photos are
581
+ * stored first; `readPages` throws an `Error` whose message is a `ReadingErrorCode`.
582
+ */
583
+ type AnswerSheetHandler = RuntimeAnswerSheetHandler;
567
584
  interface AnswerSheetReader {
585
+ /**
586
+ * Reads photos of the copy into the sheet's content. With `signPhoto` (0.16.0+), every photo is
587
+ * stored first: `images` is then always empty, `photos` are the stored photos, and the result
588
+ * carries `lines` (what was read, line by line). Without it, `images` are the photos as JPEG
589
+ * data URLs, as before.
590
+ */
568
591
  readPhotos(input: {
569
592
  images: string[];
570
593
  photos: AnswerPhoto[];
571
594
  nodeId?: string;
595
+ /** `copy`: the whole copy, each line placed in its question (0.16.0+). Absent = one answer. */
596
+ purpose?: "answer" | "copy";
572
597
  }): Promise<{
573
598
  content: RichContent$1[];
599
+ lines?: ReadingLine[];
574
600
  }>;
575
- readHandwriting(image: string): Promise<{
601
+ /**
602
+ * A handwritten formula (a PNG data URL of the pad's ink, cropped) as LaTeX. `signal` aborts
603
+ * when a new stroke starts (0.16.0+): pass it to the request (a reader that ignores it still
604
+ * works; its answer is simply not shown).
605
+ */
606
+ readHandwriting(image: string, options?: {
607
+ signal?: AbortSignal;
608
+ }): Promise<{
576
609
  latex: string;
577
610
  }>;
578
- /** The phone hand-off (optional): a link and its QR code for the phone, an id to poll with. */
579
- startCapture?(nodeId: string): Promise<{
611
+ /**
612
+ * Stored photos read line by line (0.16.0+): the host posts them to its streamed reading route
613
+ * and hands back the response, NDJSON `ReadingEvent`s; the handler reads it. Errors before the
614
+ * stream are a JSON `{ error }` with a status (429 `limit`, 503 `ai_busy`...). Without it,
615
+ * `readPhotos` answers whole.
616
+ */
617
+ streamPhotos?(input: {
618
+ photos: AnswerPhoto[];
619
+ nodeId?: string;
620
+ purpose: "answer" | "copy";
621
+ upright?: boolean;
622
+ }, signal: AbortSignal): Promise<Response>;
623
+ /** A signed upload for one photo (0.16.0+): PUT it to `uploadUrl`, then read it by `url`. */
624
+ signPhoto?(input: {
625
+ mime: string;
626
+ sizeBytes: number;
627
+ }): Promise<{
628
+ uploadUrl: string;
629
+ contentType: string;
630
+ url: string;
631
+ }>;
632
+ /**
633
+ * The phone hand-off (optional): a link and its QR code for the phone, an id to poll with. No
634
+ * `nodeId`: the whole copy (0.16.0+), up to 12 photos.
635
+ */
636
+ startCapture?(nodeId?: string): Promise<{
580
637
  captureId: string;
581
638
  url: string;
582
639
  qrImage: string;
@@ -587,7 +644,11 @@ interface AnswerSheetReader {
587
644
  } | null>;
588
645
  }
589
646
  declare function createAnswerSheetHandler(reader: AnswerSheetReader): AnswerSheetHandler;
590
- /** The embed's reader: the embed token authorises the reading, it is not consumed. */
647
+ /**
648
+ * The embed's reader: the embed token authorises the reading, it is not consumed. Photos are
649
+ * stored under the embed session first, read line by line (0.16.0+), and on a computer the QR
650
+ * code opens Edpire's phone page, whose photos come back to the embed (0.16.0+).
651
+ */
591
652
  declare function embedAnswerSheetHandler(baseUrl: string, token: string): AnswerSheetHandler;
592
653
 
593
654
  export { type AiFeedbackLine, type AnswerSheetHandler, type AnswerSheetReader, AssessmentShell, type AssessmentShellProps, EdpireAssessmentPlayer, type EdpireAssessmentPlayerProps, EdpireQuestion, type EdpireQuestionProps, type ExerciseFeedbackData, type NodeDetail, type NodeFeedback, type OverlayConfig, type QuestionFeedback, type ShellLayout, type ShellLocale, type ShellReview, type ShellSaveState, type SpinnerTheme, type SubmitResult, type TakeBranding, createAnswerSheetHandler, embedAnswerSheetHandler };