feat(workspace): R2 facade operations for the editor rules, the publish check and the sheet index data
Free ops: sheet.check, report.new, report.add_observation, report.remove_observation, report.move_observation, vertebra.select. Sheet ops: index_data, zone.click, zone.add_sides, zone.remove_at, vertebra.initial, vertebra.sync, finding.toggle. Input contracts exported to TypeScript; a JavaScript index that names no position removes nothing in the filters and is refused by the move (the TypeScript swap would have written a hole). Shipped module 999 KB raw, 319 KB gzip (budget 600 KB).
This commit is contained in:
1 parent
3639c8778e
commit
6c0533c1da
25 files changed
+470
-11
No files matched your search
@@ -87,18 +87,18 @@ describe('core runtime', () => {
|
||||
const runtime = new CoreRuntime(countingSource())
|
||||
await runtime.ready()
|
||||
const sheet = runtime.sheet(BUNDLE)
|
||||
expect(sheet.call('sheet.ref', '')).toMatchObject({
|
||||
expect(sheet.call('index_data', '')).toMatchObject({
|
||||
ok: true,
|
||||
value: { sheetId: 'sheet', versionId: null },
|
||||
value: { ref: { sheetId: 'sheet', versionId: null } },
|
||||
})
|
||||
trap(runtime)
|
||||
expect(sheet.call('sheet.ref', '')).toMatchObject({
|
||||
expect(sheet.call('index_data', '')).toMatchObject({
|
||||
kind: 'core_unavailable',
|
||||
})
|
||||
await runtime.ready()
|
||||
// A call through the stack-trapped instance would fail in its allocator and poison
|
||||
// again: one generation more and a ready runtime prove the handle was rebuilt.
|
||||
expect(sheet.call('sheet.ref', '')).toMatchObject({ ok: true })
|
||||
expect(sheet.call('index_data', '')).toMatchObject({ ok: true })
|
||||
expect(runtime.generation).toBe(2)
|
||||
expect(runtime.status).toBe('ready')
|
||||
})
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { LateralSide } from "./LateralSide";
|
||||
import type { Observation } from "./Observation";
|
||||
|
||||
export type AddSidesInput = { observation: Observation, annotationId: string, sides: Array<LateralSide>, };
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { JsIndex } from "./JsIndex";
|
||||
import type { LateralSide } from "./LateralSide";
|
||||
import type { Observation } from "./Observation";
|
||||
|
||||
export type FindingToggleInput = { observation: Observation, findingZoneId: string, path: Array<string>, leafPosition: JsIndex, side?: LateralSide, };
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* An index as JavaScript sent it: a number. Only a non-negative integer names a position.
|
||||
*/
|
||||
export type JsIndex = number;
|
||||
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type MoveDirection = "up" | "down";
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { JsIndex } from "./JsIndex";
|
||||
import type { MoveDirection } from "./MoveDirection";
|
||||
import type { Report } from "./Report";
|
||||
|
||||
export type MoveObservationInput = { report: Report, index: JsIndex, direction: MoveDirection, };
|
||||
@@ -0,0 +1,12 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Animal } from "./Animal";
|
||||
import type { NextAppointment } from "./NextAppointment";
|
||||
import type { Observation } from "./Observation";
|
||||
import type { Owner } from "./Owner";
|
||||
import type { Practitioner } from "./Practitioner";
|
||||
|
||||
/**
|
||||
* What a new report needs before version, id, dates and the sheet are stamped
|
||||
* (`Omit<Report, 'version' | 'id' | 'createdAt' | 'sheet' | 'localAnnotations'>`).
|
||||
*/
|
||||
export type NewReportDraft = { date: string, practitioner: Practitioner, animal: Animal, owner: Owner, observations: Array<Observation>, conclusion: string, recommendations: string, nextAppointment?: NextAppointment, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { NewReportDraft } from "./NewReportDraft";
|
||||
import type { SheetRef } from "./SheetRef";
|
||||
|
||||
export type NewReportInput = { draft: NewReportDraft, sheet: SheetRef, id: string, createdAt: string, observationId: string, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { JsIndex } from "./JsIndex";
|
||||
import type { Observation } from "./Observation";
|
||||
|
||||
export type ObservationIndexInput = { observation: Observation, index: JsIndex, };
|
||||
@@ -0,0 +1,4 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Report } from "./Report";
|
||||
|
||||
export type ReportIdInput = { report: Report, id: string, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { JsIndex } from "./JsIndex";
|
||||
import type { Report } from "./Report";
|
||||
|
||||
export type ReportIndexInput = { report: Report, index: JsIndex, };
|
||||
@@ -0,0 +1,7 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { SheetIssue } from "./SheetIssue";
|
||||
|
||||
/**
|
||||
* The issues of a shape-valid document and whether they allow publication.
|
||||
*/
|
||||
export type SheetCheck = { issues: Array<SheetIssue>, publishable: boolean, };
|
||||
@@ -0,0 +1,39 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { AnatomicalSheetDocument } from "./AnatomicalSheetDocument";
|
||||
import type { LocalizedText } from "./LocalizedText";
|
||||
import type { SheetRef } from "./SheetRef";
|
||||
import type { SheetStatus } from "./SheetStatus";
|
||||
|
||||
export type SheetIndexData = { status: SheetStatus, ref: SheetRef, speciesId: string, schemaVersion: number,
|
||||
/**
|
||||
* The first `main` view of the document.
|
||||
*/
|
||||
mainViewId: string,
|
||||
/**
|
||||
* The document as parsed (defaults filled in).
|
||||
*/
|
||||
document: AnatomicalSheetDocument,
|
||||
/**
|
||||
* Position in `document.views` by id; the last duplicate wins.
|
||||
*/
|
||||
viewById: { [key in string]: number },
|
||||
/**
|
||||
* Position in `document.annotations` by id; the last duplicate wins.
|
||||
*/
|
||||
annotationById: { [key in string]: number },
|
||||
/**
|
||||
* Position in `document.finding_zones` by id; the last duplicate wins.
|
||||
*/
|
||||
findingZoneById: { [key in string]: number },
|
||||
/**
|
||||
* Display name of every annotation id (a trigger: its own, else its view's).
|
||||
*/
|
||||
names: { [key in string]: LocalizedText },
|
||||
/**
|
||||
* Ids that open the vertebra picker, in document order, each once.
|
||||
*/
|
||||
spineIds: Array<string>,
|
||||
/**
|
||||
* Every finding path the sheet holds, as the JSON text of `[zoneId, ...path]`.
|
||||
*/
|
||||
nodeKeys: Array<string>, };
|
||||
@@ -0,0 +1,4 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { SheetIssueSeverity } from "./SheetIssueSeverity";
|
||||
|
||||
export type SheetIssue = { code: string, severity: SheetIssueSeverity, path: string, message: string, };
|
||||
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type SheetIssueSeverity = "error" | "warning";
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* One tap of the picker.
|
||||
*/
|
||||
export type VertebraAction = { "kind": "toggle", region: string, index: number, } | { "kind": "all", region: string, count: number, } | { "kind": "none", region: string, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Vertebra } from "./Vertebra";
|
||||
import type { VertebraAction } from "./VertebraAction";
|
||||
|
||||
export type VertebraSelectInput = { selection: Array<Vertebra>, action: VertebraAction, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Observation } from "./Observation";
|
||||
import type { Vertebra } from "./Vertebra";
|
||||
|
||||
export type VertebraSyncInput = { observation: Observation, selection: Array<Vertebra>, viewId: string, };
|
||||
@@ -0,0 +1,30 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { LateralSide } from "./LateralSide";
|
||||
import type { Observation } from "./Observation";
|
||||
import type { Vertebra } from "./Vertebra";
|
||||
import type { ZoneClickKind } from "./ZoneClickKind";
|
||||
|
||||
/**
|
||||
* What a click on an annotation did, with what the editor needs to follow it up.
|
||||
*/
|
||||
export type ZoneClick = { kind: ZoneClickKind,
|
||||
/**
|
||||
* `open_view`: the detail view to open.
|
||||
*/
|
||||
viewId?: string,
|
||||
/**
|
||||
* The active observation after the click, when the click changed it.
|
||||
*/
|
||||
observation?: Observation,
|
||||
/**
|
||||
* `open_vertebra_picker`: the zone the picker edits.
|
||||
*/
|
||||
zoneIndex?: number,
|
||||
/**
|
||||
* `open_laterality_picker`: the sides already recorded.
|
||||
*/
|
||||
sidesPresent?: Array<LateralSide>,
|
||||
/**
|
||||
* `open_vertebra_picker`: the picker's initial selection.
|
||||
*/
|
||||
vertebrae?: Array<Vertebra>, };
|
||||
@@ -0,0 +1,4 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Observation } from "./Observation";
|
||||
|
||||
export type ZoneClickInput = { observation: Observation | null, annotationId: string, };
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* The kind of a click decision (`ZoneClickDecision.kind`).
|
||||
*/
|
||||
export type ZoneClickKind = "ignore" | "open_view" | "activate_fallback" | "open_vertebra_picker" | "open_laterality_picker" | "remove_both_sides" | "toggle";
|
||||
@@ -1,6 +1,7 @@
|
||||
// Types of the core contracts, generated by ts-rs from crates/core (`pnpm rust:check`
|
||||
// regenerates them; the drift gate fails when the committed files differ from the Rust structs).
|
||||
// This index lists every generated file: tests/types-index.test.ts keeps it complete.
|
||||
export type { AddSidesInput } from './AddSidesInput'
|
||||
export type { AnatomicalSheetDocument } from './AnatomicalSheetDocument'
|
||||
export type { Animal } from './Animal'
|
||||
export type { AnnotationCategory } from './AnnotationCategory'
|
||||
@@ -15,21 +16,28 @@ export type { DetailView } from './DetailView'
|
||||
export type { FindingCategoryKind } from './FindingCategoryKind'
|
||||
export type { FindingCategory } from './FindingCategory'
|
||||
export type { FindingNode } from './FindingNode'
|
||||
export type { FindingToggleInput } from './FindingToggleInput'
|
||||
export type { Finding } from './Finding'
|
||||
export type { FindingZone } from './FindingZone'
|
||||
export type { Geometry } from './Geometry'
|
||||
export type { ImageAsset } from './ImageAsset'
|
||||
export type { JsIndex } from './JsIndex'
|
||||
export type { Laterality } from './Laterality'
|
||||
export type { LateralSide } from './LateralSide'
|
||||
export type { Locale } from './Locale'
|
||||
export type { LocalizedOptionalText } from './LocalizedOptionalText'
|
||||
export type { LocalizedText } from './LocalizedText'
|
||||
export type { MainView } from './MainView'
|
||||
export type { MoveDirection } from './MoveDirection'
|
||||
export type { MoveObservationInput } from './MoveObservationInput'
|
||||
export type { NewReportDraft } from './NewReportDraft'
|
||||
export type { NewReportInput } from './NewReportInput'
|
||||
export type { NextAppointmentDate } from './NextAppointmentDate'
|
||||
export type { NextAppointmentPeriod } from './NextAppointmentPeriod'
|
||||
export type { NextAppointment } from './NextAppointment'
|
||||
export type { ObservableAnnotation } from './ObservableAnnotation'
|
||||
export type { ObservableKind } from './ObservableKind'
|
||||
export type { ObservationIndexInput } from './ObservationIndexInput'
|
||||
export type { Observation } from './Observation'
|
||||
export type { Owner } from './Owner'
|
||||
export type { PathGeometry } from './PathGeometry'
|
||||
@@ -42,10 +50,16 @@ export type { Practitioner } from './Practitioner'
|
||||
export type { Reference } from './Reference'
|
||||
export type { ReferenceType } from './ReferenceType'
|
||||
export type { ReportArchiveEnvelope } from './ReportArchiveEnvelope'
|
||||
export type { ReportIdInput } from './ReportIdInput'
|
||||
export type { ReportIndexInput } from './ReportIndexInput'
|
||||
export type { Report } from './Report'
|
||||
export type { ReportZone } from './ReportZone'
|
||||
export type { ReviewStatus } from './ReviewStatus'
|
||||
export type { Severity } from './Severity'
|
||||
export type { SheetCheck } from './SheetCheck'
|
||||
export type { SheetIndexData } from './SheetIndexData'
|
||||
export type { SheetIssueSeverity } from './SheetIssueSeverity'
|
||||
export type { SheetIssue } from './SheetIssue'
|
||||
export type { SheetRef } from './SheetRef'
|
||||
export type { SheetSnapshotAsset } from './SheetSnapshotAsset'
|
||||
export type { SheetSnapshotRef } from './SheetSnapshotRef'
|
||||
@@ -53,7 +67,13 @@ export type { SheetSnapshot } from './SheetSnapshot'
|
||||
export type { SheetStatus } from './SheetStatus'
|
||||
export type { SheetView } from './SheetView'
|
||||
export type { SvgAsset } from './SvgAsset'
|
||||
export type { VertebraAction } from './VertebraAction'
|
||||
export type { VertebralConfig } from './VertebralConfig'
|
||||
export type { VertebralRegion } from './VertebralRegion'
|
||||
export type { VertebraSelectInput } from './VertebraSelectInput'
|
||||
export type { VertebraSyncInput } from './VertebraSyncInput'
|
||||
export type { Vertebra } from './Vertebra'
|
||||
export type { ViewBox } from './ViewBox'
|
||||
export type { ZoneClickInput } from './ZoneClickInput'
|
||||
export type { ZoneClickKind } from './ZoneClickKind'
|
||||
export type { ZoneClick } from './ZoneClick'
|
||||
Reference in new issue
Block a user