feat(domain): V1-2.2 wasm facade, contract types, module proofs
PreviewBuilder, PreviewSheet and clean_svg on the browser module, the 31 ts-rs types and their index, the glue interface, and the proofs on the shipped module; the module stays under its 600 KB budget.
This commit is contained in:
1 parent
cf37aa265a
commit
8ae756534c
37 files changed
+558
No files matched your search
@@ -57,6 +57,8 @@ export async function trappingCoreRuntime(marker: string) {
|
|||||||
SheetHandle: Trapping,
|
SheetHandle: Trapping,
|
||||||
FileBytes: glue.FileBytes,
|
FileBytes: glue.FileBytes,
|
||||||
ExportSession: glue.ExportSession,
|
ExportSession: glue.ExportSession,
|
||||||
|
PreviewBuilder: glue.PreviewBuilder,
|
||||||
|
clean_svg: glue.clean_svg,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
//! the application behind the sheet and import paths (`packages/core-wasm/src/runtime.ts`).
|
//! the application behind the sheet and import paths (`packages/core-wasm/src/runtime.ts`).
|
||||||
|
|
||||||
use faunosteo_core::domain::sheet::LoadedSheet;
|
use faunosteo_core::domain::sheet::LoadedSheet;
|
||||||
|
use faunosteo_core::domain::sheet::preview::PreviewDrawing;
|
||||||
use faunosteo_core::pdf::read::MAX_PDF_BYTES;
|
use faunosteo_core::pdf::read::MAX_PDF_BYTES;
|
||||||
use wasm_bindgen::prelude::{JsError, wasm_bindgen};
|
use wasm_bindgen::prelude::{JsError, wasm_bindgen};
|
||||||
|
|
||||||
@@ -63,6 +64,85 @@ impl SheetHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A stored sheet version being gathered for preview (V1-2.2, contract §10): the page adds
|
||||||
|
/// each downloaded drawing with the sha256 of its row, then builds the `PreviewSheet` from
|
||||||
|
/// the version's status, document text and stored fingerprint. The bytes are copied once
|
||||||
|
/// into the module's memory by the glue; nothing is read before `build`.
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub struct PreviewBuilder {
|
||||||
|
drawings: Vec<PreviewDrawing>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
impl PreviewBuilder {
|
||||||
|
#[wasm_bindgen(constructor)]
|
||||||
|
pub fn new() -> PreviewBuilder {
|
||||||
|
PreviewBuilder {
|
||||||
|
drawings: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_drawing(&mut self, asset_id: &str, sha256: &str, bytes: &[u8]) {
|
||||||
|
self.drawings.push(PreviewDrawing {
|
||||||
|
asset_id: asset_id.to_owned(),
|
||||||
|
sha256: sha256.to_owned(),
|
||||||
|
bytes: bytes.to_vec(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Consumes the builder; throws an `Error` worded `<kind>: <detail>` (`invalid_document`,
|
||||||
|
/// `drawing_missing`, `drawing_hash_mismatch`, `fingerprint_mismatch`, `caps`, or
|
||||||
|
/// `invalid_shape` / `invalid_json` for the input).
|
||||||
|
pub fn build(self, input: &str) -> Result<PreviewSheet, JsError> {
|
||||||
|
faunosteo_core::facade::load_preview(input, self.drawings)
|
||||||
|
.map(|sheet| PreviewSheet { sheet })
|
||||||
|
.map_err(|failure| JsError::new(&format!("{}: {}", failure.kind, failure.detail)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for PreviewBuilder {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A stored version loaded for the catalogue, the admin preview and the editor: no report
|
||||||
|
/// migration map, never a report session.
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub struct PreviewSheet {
|
||||||
|
sheet: faunosteo_core::domain::sheet::preview::PreviewSheet,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
impl PreviewSheet {
|
||||||
|
/// `preview.state` or `view.canvas`; the envelope of `call`.
|
||||||
|
pub fn call(&self, op: &str, input: &str) -> String {
|
||||||
|
faunosteo_core::facade::call_with_preview(&self.sheet, op, input)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A draft's document after an edit; the drawings are not read again.
|
||||||
|
pub fn replace_document(&mut self, text: &str) -> String {
|
||||||
|
faunosteo_core::facade::replace_preview_document(&mut self.sheet, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A drawing uploaded while the draft is open.
|
||||||
|
pub fn add_drawing(&mut self, asset_id: &str, sha256: &str, bytes: &[u8]) -> String {
|
||||||
|
let drawing = PreviewDrawing {
|
||||||
|
asset_id: asset_id.to_owned(),
|
||||||
|
sha256: sha256.to_owned(),
|
||||||
|
bytes: bytes.to_vec(),
|
||||||
|
};
|
||||||
|
faunosteo_core::facade::add_preview_drawing(&mut self.sheet, drawing)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The cleaning answer for a file picked for upload (contract §9.2): the envelope of `call`
|
||||||
|
/// with an `SvgCleaning` value.
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn clean_svg(bytes: &[u8]) -> String {
|
||||||
|
faunosteo_core::facade::clean_svg(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
/// The incremental PDF export (R4.6, plan §B.1.4, OD-2): the application opens a session on
|
/// The incremental PDF export (R4.6, plan §B.1.4, OD-2): the application opens a session on
|
||||||
/// its `ExportInput` JSON, then alternates `next()` (the rasters the next step needs) with
|
/// its `ExportInput` JSON, then alternates `next()` (the rasters the next step needs) with
|
||||||
/// `add_raster` or `raster_failed` per key, and closes with `finish()`. Every answer is the
|
/// `add_raster` or `raster_failed` per key, and closes with `finish()`. Every answer is the
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ export {
|
|||||||
type GlueExportSession,
|
type GlueExportSession,
|
||||||
type GlueFileBytes,
|
type GlueFileBytes,
|
||||||
type GlueModule,
|
type GlueModule,
|
||||||
|
type GluePreviewBuilder,
|
||||||
|
type GluePreviewSheet,
|
||||||
type GlueSheetHandle,
|
type GlueSheetHandle,
|
||||||
} from './runtime'
|
} from './runtime'
|
||||||
export { CoreExportSession, openExportSession } from './export'
|
export { CoreExportSession, openExportSession } from './export'
|
||||||
|
|||||||
@@ -26,6 +26,30 @@ export interface GlueModule {
|
|||||||
FileBytes: new (expected: number) => GlueFileBytes
|
FileBytes: new (expected: number) => GlueFileBytes
|
||||||
/** R4.6: the incremental export; the constructor throws `<kind>: <detail>` on a refused input. */
|
/** R4.6: the incremental export; the constructor throws `<kind>: <detail>` on a refused input. */
|
||||||
ExportSession: new (inputJson: string) => GlueExportSession
|
ExportSession: new (inputJson: string) => GlueExportSession
|
||||||
|
/** V1-2.2: a stored version gathered for preview (drawings first, then `build`). */
|
||||||
|
PreviewBuilder: new () => GluePreviewBuilder
|
||||||
|
/** V1-2.2: the cleaning answer for a file picked for upload (`SvgCleaning` envelope). */
|
||||||
|
clean_svg(bytes: Uint8Array): string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A stored version being gathered (crates/wasm `PreviewBuilder`). */
|
||||||
|
export interface GluePreviewBuilder {
|
||||||
|
add_drawing(assetId: string, sha256: string, bytes: Uint8Array): void
|
||||||
|
/** Consumes the builder; throws `<kind>: <detail>` (`invalid_document`, `drawing_missing`,
|
||||||
|
* `drawing_hash_mismatch`, `fingerprint_mismatch`, `caps`, `invalid_shape`, `invalid_json`). */
|
||||||
|
build(inputJson: string): GluePreviewSheet
|
||||||
|
free(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A stored version loaded for the catalogue, the preview and the editor (crates/wasm
|
||||||
|
* `PreviewSheet`): no report migration map, never a report session. */
|
||||||
|
export interface GluePreviewSheet {
|
||||||
|
/** `preview.state` or `view.canvas`; outcome envelopes out. */
|
||||||
|
call(op: string, input: string): string
|
||||||
|
/** A draft's document after an edit, the drawings kept as read. */
|
||||||
|
replace_document(text: string): string
|
||||||
|
add_drawing(assetId: string, sha256: string, bytes: Uint8Array): string
|
||||||
|
free(): void
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The export session of the module (crates/wasm `ExportSession`): outcome envelopes out. */
|
/** The export session of the module (crates/wasm `ExportSession`): outcome envelopes out. */
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
/**
|
||||||
|
* V1-2.2 on the shipped module (contract §8.1, §9.2, §10): the equine draft previews with the
|
||||||
|
* index, the fingerprint and the canvases of the bundled sheet; hash and fingerprint
|
||||||
|
* mismatches refuse the build with their closed kind; a draft's document is replaced and
|
||||||
|
* redrawn; the edit commands run through `call`; every hostile SVG and flood gets a closed
|
||||||
|
* cleaning answer with no trap. The Rust suites hold the rules; this proves the facade.
|
||||||
|
*/
|
||||||
|
import { readFileSync, readdirSync } from 'node:fs'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
||||||
|
import type { GlueModule } from '../src/index'
|
||||||
|
import { nodeCoreSource } from '../src/node'
|
||||||
|
|
||||||
|
const ROOT = '../../../'
|
||||||
|
const SEED = `${ROOT}supabase/seed/anatomical-sheets/equine/draft/`
|
||||||
|
const HOSTILE = `${ROOT}crates/core/tests/fixtures/svg/hostile/`
|
||||||
|
const HORSE_ID = '7f767f74-3b36-51a7-8465-52dd7e2ead4a'
|
||||||
|
const HORSE_SHA = '0ea5202fa3b95bac167b87c12ee969ab0272e085b60c2d34dbca6202c5f08541'
|
||||||
|
const FINGERPRINT = '12d788727c1e532641bd5b3a7ecf39dbdd25e70350f8a76be5ca917b262874e2'
|
||||||
|
const path = (p: string) => fileURLToPath(new URL(p, import.meta.url))
|
||||||
|
const text = (p: string) => readFileSync(path(p), 'utf8')
|
||||||
|
|
||||||
|
const documentText = text(`${SEED}document.json`)
|
||||||
|
const horse = new Uint8Array(readFileSync(path(`${SEED}assets/horse.svg`)))
|
||||||
|
|
||||||
|
let glue: GlueModule
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
const source = nodeCoreSource('pkg')
|
||||||
|
glue = await source.importGlue(0)
|
||||||
|
await glue.default({ module_or_path: await source.compile() })
|
||||||
|
})
|
||||||
|
|
||||||
|
const value = (envelope: string) => {
|
||||||
|
const outcome = JSON.parse(envelope)
|
||||||
|
expect(outcome.ok).toBe(true)
|
||||||
|
return outcome.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function build(status: string, drawing: Uint8Array | null, fingerprint?: string, doc = documentText) {
|
||||||
|
const builder = new glue.PreviewBuilder()
|
||||||
|
if (drawing) builder.add_drawing(HORSE_ID, HORSE_SHA, drawing)
|
||||||
|
return builder.build(JSON.stringify({ status, document: doc, fingerprint }))
|
||||||
|
}
|
||||||
|
|
||||||
|
function refusal(run: () => unknown): string {
|
||||||
|
try {
|
||||||
|
run()
|
||||||
|
} catch (error) {
|
||||||
|
return (error as Error).message
|
||||||
|
}
|
||||||
|
throw new Error('no refusal')
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('PreviewSheet through the shipped module', () => {
|
||||||
|
it('previews the equine draft as the bundled sheet', () => {
|
||||||
|
const preview = build('published', horse, FINGERPRINT)
|
||||||
|
const state = value(preview.call('preview.state', '{}'))
|
||||||
|
expect(state.fingerprint).toBe(FINGERPRINT)
|
||||||
|
expect(state.report.groups).toHaveLength(30)
|
||||||
|
const handle = new glue.SheetHandle(
|
||||||
|
JSON.stringify({
|
||||||
|
status: 'draft',
|
||||||
|
ref: JSON.parse(text(`${SEED}sheet-ref.json`)),
|
||||||
|
document: JSON.parse(documentText),
|
||||||
|
migrationMap: JSON.parse(text(`${SEED}report-migration-map.json`)),
|
||||||
|
assets: { [HORSE_ID]: new TextDecoder().decode(horse) },
|
||||||
|
assetHashes: { [HORSE_ID]: HORSE_SHA },
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
const index = value(handle.call('index_data', '{}'))
|
||||||
|
expect(state.index.main_view_id).toBe(index.mainViewId)
|
||||||
|
expect(state.index.view_by_id).toEqual(index.viewById)
|
||||||
|
expect(state.index.annotation_by_id).toEqual(index.annotationById)
|
||||||
|
expect(state.index.finding_zone_by_id).toEqual(index.findingZoneById)
|
||||||
|
expect(state.index.names).toEqual(index.names)
|
||||||
|
expect(state.index.node_keys).toEqual(index.nodeKeys)
|
||||||
|
for (const viewId of ['main', 'head']) {
|
||||||
|
const input = JSON.stringify({ viewId })
|
||||||
|
expect(preview.call('view.canvas', input)).toBe(handle.call('view.canvas', input))
|
||||||
|
}
|
||||||
|
handle.free()
|
||||||
|
preview.free()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('refuses a hash or a fingerprint mismatch with its closed kind', () => {
|
||||||
|
const altered = horse.slice()
|
||||||
|
altered[200] ^= 1
|
||||||
|
expect(refusal(() => build('draft', altered))).toBe(`drawing_hash_mismatch: ${HORSE_ID}`)
|
||||||
|
expect(refusal(() => build('published', horse, 'a'.repeat(64)))).toBe('fingerprint_mismatch: ')
|
||||||
|
expect(refusal(() => build('deprecated', null, FINGERPRINT))).toBe(`drawing_missing: ${HORSE_ID}`)
|
||||||
|
expect(refusal(() => build('draft', horse, undefined, '{'))).toMatch(/^invalid_document: /)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('replaces a draft document and redraws it', () => {
|
||||||
|
const draft = build('draft', horse)
|
||||||
|
const before = draft.call('view.canvas', '{"viewId":"main"}')
|
||||||
|
const edited = JSON.parse(documentText)
|
||||||
|
edited.annotations = edited.annotations.slice(0, 2)
|
||||||
|
expect(draft.replace_document(JSON.stringify(edited))).toBe('{"ok":true,"value":null}')
|
||||||
|
const after = draft.call('view.canvas', '{"viewId":"main"}')
|
||||||
|
expect(value(after).svg).not.toBe(value(before).svg)
|
||||||
|
expect(value(draft.call('preview.state', '{}')).document.annotations).toHaveLength(2)
|
||||||
|
const published = build('published', horse, FINGERPRINT)
|
||||||
|
expect(JSON.parse(published.replace_document(documentText)).kind).toBe('read_only')
|
||||||
|
draft.free()
|
||||||
|
published.free()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('runs the edit commands and lists dependents', () => {
|
||||||
|
const document = JSON.parse(documentText)
|
||||||
|
const id = document.annotations[0].id
|
||||||
|
const command = { op: 'remove', key: { kind: 'annotation', id } }
|
||||||
|
const edited = value(glue.call('sheet.edit', JSON.stringify({ document, command })))
|
||||||
|
expect(edited.document.annotations).toHaveLength(document.annotations.length - 1)
|
||||||
|
const unknown = JSON.parse(
|
||||||
|
glue.call('sheet.edit', JSON.stringify({ document, command: { op: 'remove', key: { kind: 'annotation', id: 'zz' } } })),
|
||||||
|
)
|
||||||
|
expect(unknown.kind).toBe('unknown_key')
|
||||||
|
const head = value(
|
||||||
|
glue.call('sheet.dependents', JSON.stringify({ document, key: { kind: 'view', id: 'head' } })),
|
||||||
|
)
|
||||||
|
expect(head.dependents.length).toBeGreaterThan(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('clean_svg through the shipped module', () => {
|
||||||
|
it('answers every hostile file and flood with a closed outcome, no trap', () => {
|
||||||
|
const encoder = new TextEncoder()
|
||||||
|
const files = readdirSync(path(HOSTILE)).filter((f) => f.endsWith('.svg'))
|
||||||
|
const floods = {
|
||||||
|
'deep 99,000 levels': `<svg xmlns="http://www.w3.org/2000/svg">${'<g>'.repeat(99_000)}`,
|
||||||
|
'nodes 20,001': `<svg xmlns="http://www.w3.org/2000/svg">${'<path/>'.repeat(20_000)}</svg>`,
|
||||||
|
'bytes 2 MiB + 1': `<svg xmlns="http://www.w3.org/2000/svg"><!--${'x'.repeat(2 * 1024 * 1024)}--></svg>`,
|
||||||
|
}
|
||||||
|
const inputs: [string, Uint8Array][] = [
|
||||||
|
...files.map((f): [string, Uint8Array] => [f, new Uint8Array(readFileSync(path(`${HOSTILE}${f}`)))]),
|
||||||
|
...Object.entries(floods).map(([name, svg]): [string, Uint8Array] => [name, encoder.encode(svg)]),
|
||||||
|
]
|
||||||
|
let slowest = 0
|
||||||
|
for (const [name, bytes] of inputs) {
|
||||||
|
const started = performance.now()
|
||||||
|
const cleaning = value(glue.clean_svg(bytes))
|
||||||
|
slowest = Math.max(slowest, performance.now() - started)
|
||||||
|
expect(['clean', 'cleanable', 'rejected'], name).toContain(cleaning.outcome)
|
||||||
|
}
|
||||||
|
expect(value(glue.clean_svg(new Uint8Array(readFileSync(path(`${HOSTILE}script.svg`))))).reason).toBe(
|
||||||
|
'svg_active_content',
|
||||||
|
)
|
||||||
|
expect(value(glue.clean_svg(horse)).outcome).toBe('clean')
|
||||||
|
console.info(`[core-wasm] clean_svg: ${inputs.length} inputs, slowest ${slowest.toFixed(1)} ms`)
|
||||||
|
expect(glue.core_version()).toMatch(/^\d+\.\d+\.\d+$/)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -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 cap, by name.
|
||||||
|
*/
|
||||||
|
export type CapName = "views" | "annotations" | "finding_nodes" | "finding_depth" | "label_length" | "drawings" | "drawing_bytes" | "drawings_total_bytes" | "document_bytes";
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { CapName } from "./CapName";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the sheet holds against each cap, and the caps it passes.
|
||||||
|
*/
|
||||||
|
export type CapsReport = { views: number, annotations: number,
|
||||||
|
/**
|
||||||
|
* Finding categories and nodes, categories counted.
|
||||||
|
*/
|
||||||
|
finding_nodes: number,
|
||||||
|
/**
|
||||||
|
* Deepest finding level, a category at 1.
|
||||||
|
*/
|
||||||
|
finding_depth: number,
|
||||||
|
/**
|
||||||
|
* Longest `name` label, `fr` or `en`, in UTF-16 units.
|
||||||
|
*/
|
||||||
|
longest_label: number,
|
||||||
|
/**
|
||||||
|
* Distinct drawings the views reference.
|
||||||
|
*/
|
||||||
|
drawings: number, largest_drawing_bytes: number, drawings_total_bytes: number,
|
||||||
|
/**
|
||||||
|
* The server's measure of the document (`octet_length(content::text)`).
|
||||||
|
*/
|
||||||
|
document_bytes: number, exceeded: Array<CapName>, };
|
||||||
@@ -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 ChangeKind = "added" | "removed" | "changed" | "status_changed";
|
||||||
@@ -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 CleaningOutcome = "clean" | "cleanable" | "rejected";
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { StatusCounts } from "./StatusCounts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shown, never blocking (§6.7): the markings, the vet referral nodes, and the finding
|
||||||
|
* categories and nodes that cite no reference.
|
||||||
|
*/
|
||||||
|
export type Completeness = { statuses: StatusCounts, vet_referrals: number, uncited: number, };
|
||||||
@@ -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 { ElementKey } from "./ElementKey";
|
||||||
|
import type { Relation } from "./Relation";
|
||||||
|
|
||||||
|
export type Dependent = { element: ElementKey, relation: Relation, };
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { DrawingResult } from "./DrawingResult";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One drawing the views reference, as the verdict found it.
|
||||||
|
*/
|
||||||
|
export type DrawingCheck = { asset_id: string,
|
||||||
|
/**
|
||||||
|
* The row's sha256; absent when no row was given.
|
||||||
|
*/
|
||||||
|
sha256: string | null,
|
||||||
|
/**
|
||||||
|
* The row's byte size; absent when no row was given.
|
||||||
|
*/
|
||||||
|
byte_size: number | null, result: DrawingResult, detail: string | null, };
|
||||||
@@ -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 DrawingResult = "ok" | "missing" | "size_mismatch" | "hash_mismatch" | "svg_rejected" | "svg_removal";
|
||||||
@@ -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 { ElementKey } from "./ElementKey";
|
||||||
|
import type { Marking } from "./Marking";
|
||||||
|
import type { NewElement } from "./NewElement";
|
||||||
|
|
||||||
|
export type EditCommand = { "op": "insert", element: NewElement, parent?: ElementKey, position?: number, } | { "op": "update", key: ElementKey, element: NewElement, } | { "op": "remove", key: ElementKey, } | { "op": "move", key: ElementKey, position: number, } | { "op": "set_status", key: ElementKey, status: Marking, } | { "op": "mark_reviewed", key: ElementKey, };
|
||||||
@@ -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 { ChangeKind } from "./ChangeKind";
|
||||||
|
import type { ElementKey } from "./ElementKey";
|
||||||
|
import type { ReviewStatus } from "./ReviewStatus";
|
||||||
|
|
||||||
|
export type ElementChange = { group: string, element: ElementKey, change: ChangeKind, status_before: ReviewStatus | null, status_after: ReviewStatus | null, };
|
||||||
@@ -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 ElementKey = { "kind": "sheet" } | { "kind": "reference", id: string, } | { "kind": "region", code: string, } | { "kind": "category", id: string, } | { "kind": "view", id: string, } | { "kind": "annotation", id: string, } | { "kind": "zone", id: string, } | { "kind": "finding", zone_id: string, path: Array<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 two markings an editor sets by hand.
|
||||||
|
*/
|
||||||
|
export type Marking = "to_confirm" | "reviewed";
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { Annotation } from "./Annotation";
|
||||||
|
import type { AnnotationCategory } from "./AnnotationCategory";
|
||||||
|
import type { FindingCategory } from "./FindingCategory";
|
||||||
|
import type { FindingNode } from "./FindingNode";
|
||||||
|
import type { FindingZone } from "./FindingZone";
|
||||||
|
import type { Reference } from "./Reference";
|
||||||
|
import type { SheetTexts } from "./SheetTexts";
|
||||||
|
import type { SheetView } from "./SheetView";
|
||||||
|
import type { VertebralRegion } from "./VertebralRegion";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An element as the editor writes it, by kind.
|
||||||
|
*/
|
||||||
|
export type NewElement = { "kind": "sheet", "value": SheetTexts } | { "kind": "reference", "value": Reference } | { "kind": "region", "value": VertebralRegion } | { "kind": "category", "value": AnnotationCategory } | { "kind": "view", "value": SheetView } | { "kind": "annotation", "value": Annotation } | { "kind": "zone", "value": FindingZone } | { "kind": "finding_category", "value": FindingCategory } | { "kind": "finding_node", "value": FindingNode };
|
||||||
@@ -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 { PreviewDrawingStatus } from "./PreviewDrawingStatus";
|
||||||
|
|
||||||
|
export type PreviewDrawingState = { asset_id: string, state: PreviewDrawingStatus, detail: string | null, };
|
||||||
@@ -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 PreviewDrawingStatus = "ok" | "missing" | "rejected";
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { LocalizedText } from "./LocalizedText";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The lookups the canvas and the catalogue read (the `SheetIndexData` tables), present when
|
||||||
|
* the document has a main view.
|
||||||
|
*/
|
||||||
|
export type PreviewIndex = { main_view_id: string, view_by_id: { [key in string]: number }, annotation_by_id: { [key in string]: number }, finding_zone_by_id: { [key in string]: number }, names: { [key in string]: LocalizedText }, spine_ids: Array<string>, node_keys: Array<string>, };
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { PreviewStatus } from "./PreviewStatus";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version as `get_sheet_version` gives it: status, document text, stored fingerprint
|
||||||
|
* (published and deprecated versions).
|
||||||
|
*/
|
||||||
|
export type PreviewInput = { status: PreviewStatus, document: string, fingerprint?: string, };
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// 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 { PreviewDrawingState } from "./PreviewDrawingState";
|
||||||
|
import type { PreviewIndex } from "./PreviewIndex";
|
||||||
|
import type { PreviewStatus } from "./PreviewStatus";
|
||||||
|
import type { SheetReport } from "./SheetReport";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What a page reads of a loaded version, after load and after each replacement.
|
||||||
|
*/
|
||||||
|
export type PreviewState = { status: PreviewStatus,
|
||||||
|
/**
|
||||||
|
* Recomputed; absent when the document has an integrity error.
|
||||||
|
*/
|
||||||
|
fingerprint: string | null, report: SheetReport, drawings: Array<PreviewDrawingState>, index: PreviewIndex | null,
|
||||||
|
/**
|
||||||
|
* The document as read (defaults filled in).
|
||||||
|
*/
|
||||||
|
document: AnatomicalSheetDocument, };
|
||||||
@@ -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 PreviewStatus = "draft" | "published" | "deprecated";
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How a dependent relates to the element about to be removed.
|
||||||
|
*/
|
||||||
|
export type Relation = "drawn_in" | "child_view" | "opens" | "uses_category" | "links_zone" | "cites" | "uses_region" | "descendant";
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { StatusCounts } from "./StatusCounts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One review group of a verdict (the shape `acknowledge_sheet_review_group` reads).
|
||||||
|
*/
|
||||||
|
export type ReviewGroup = { key: string, digest: string, coverable: boolean,
|
||||||
|
/**
|
||||||
|
* A base view or zone the version no longer has.
|
||||||
|
*/
|
||||||
|
removed: boolean, statuses: StatusCounts, };
|
||||||
@@ -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 { Dependent } from "./Dependent";
|
||||||
|
|
||||||
|
export type SheetDependents = { dependents: Array<Dependent>, };
|
||||||
@@ -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 { AnatomicalSheetDocument } from "./AnatomicalSheetDocument";
|
||||||
|
import type { ElementKey } from "./ElementKey";
|
||||||
|
|
||||||
|
export type SheetDependentsInput = { document: AnatomicalSheetDocument, key: ElementKey, };
|
||||||
@@ -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 { AnatomicalSheetDocument } from "./AnatomicalSheetDocument";
|
||||||
|
import type { EditCommand } from "./EditCommand";
|
||||||
|
|
||||||
|
export type SheetEditInput = { document: AnatomicalSheetDocument, command: EditCommand, };
|
||||||
@@ -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 { AnatomicalSheetDocument } from "./AnatomicalSheetDocument";
|
||||||
|
|
||||||
|
export type SheetEditOutput = { document: AnatomicalSheetDocument, };
|
||||||
@@ -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 { CapsReport } from "./CapsReport";
|
||||||
|
import type { Completeness } from "./Completeness";
|
||||||
|
import type { ReviewGroup } from "./ReviewGroup";
|
||||||
|
import type { SheetIssue } from "./SheetIssue";
|
||||||
|
|
||||||
|
export type SheetReport = { document_bytes: number, issues: Array<SheetIssue>, caps: CapsReport, completeness: Completeness, groups: Array<ReviewGroup>, };
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { Attribution } from "./Attribution";
|
||||||
|
import type { LocalizedOptionalText } from "./LocalizedOptionalText";
|
||||||
|
import type { LocalizedText } from "./LocalizedText";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sheet's own texts, set as one element.
|
||||||
|
*/
|
||||||
|
export type SheetTexts = { name: LocalizedText, description: LocalizedOptionalText, scope_disclaimer: LocalizedOptionalText, attribution: Attribution, };
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Elements per review marking.
|
||||||
|
*/
|
||||||
|
export type StatusCounts = { to_confirm: number, reviewed: number, inherited: number, };
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { CleaningOutcome } from "./CleaningOutcome";
|
||||||
|
|
||||||
|
export type SvgCleaning = { outcome: CleaningOutcome,
|
||||||
|
/**
|
||||||
|
* Rejected: the reader's reason, `malformed`, `too_large` or `svg_active_content`.
|
||||||
|
*/
|
||||||
|
reason: string | null,
|
||||||
|
/**
|
||||||
|
* Every removal, `tag` or `tag@attribute`, in document order.
|
||||||
|
*/
|
||||||
|
removed: Array<string>,
|
||||||
|
/**
|
||||||
|
* The removals that carried active or external content.
|
||||||
|
*/
|
||||||
|
active: Array<string>,
|
||||||
|
/**
|
||||||
|
* A `<style>` element was removed: the classes it styled render unstyled.
|
||||||
|
*/
|
||||||
|
style_removed: boolean,
|
||||||
|
/**
|
||||||
|
* The drawing as the core reads it (sanitised, serialised).
|
||||||
|
*/
|
||||||
|
preview: string | null,
|
||||||
|
/**
|
||||||
|
* Cleanable only: the text to upload.
|
||||||
|
*/
|
||||||
|
cleaned: string | null,
|
||||||
|
/**
|
||||||
|
* SHA-256 and size of the bytes to upload: the original (clean) or the cleaned text.
|
||||||
|
*/
|
||||||
|
sha256: string | null, byte_size: number | null, };
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
import type { CapsReport } from "./CapsReport";
|
||||||
|
import type { Completeness } from "./Completeness";
|
||||||
|
import type { DrawingCheck } from "./DrawingCheck";
|
||||||
|
import type { ElementChange } from "./ElementChange";
|
||||||
|
import type { ReviewGroup } from "./ReviewGroup";
|
||||||
|
import type { SheetIssue } from "./SheetIssue";
|
||||||
|
import type { VerdictOutcome } from "./VerdictOutcome";
|
||||||
|
|
||||||
|
export type Verdict = { format: number, outcome: VerdictOutcome,
|
||||||
|
/**
|
||||||
|
* The first failure, as the round records it.
|
||||||
|
*/
|
||||||
|
failure_code: string | null, failures: Array<string>, sheet_id: string, version_id: string, revision: number, review_id: string, verified_with: string,
|
||||||
|
/**
|
||||||
|
* `sha256-rfc8785-validated-v1`; absent when the document has an integrity error.
|
||||||
|
*/
|
||||||
|
fingerprint: string | null, drawings: Array<DrawingCheck>, document_bytes: number, issues: Array<SheetIssue>, caps: CapsReport | null, completeness: Completeness | null, groups: Array<ReviewGroup>,
|
||||||
|
/**
|
||||||
|
* Against the base; absent when the version has none.
|
||||||
|
*/
|
||||||
|
changes: Array<ElementChange> | null, };
|
||||||
@@ -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 VerdictOutcome = "passed" | "failed";
|
||||||
@@ -13,13 +13,24 @@ export type { Attribution } from './Attribution'
|
|||||||
export type { Branding } from './Branding'
|
export type { Branding } from './Branding'
|
||||||
export type { CanvasView } from './CanvasView'
|
export type { CanvasView } from './CanvasView'
|
||||||
export type { CanvasViewInput } from './CanvasViewInput'
|
export type { CanvasViewInput } from './CanvasViewInput'
|
||||||
|
export type { CapName } from './CapName'
|
||||||
|
export type { CapsReport } from './CapsReport'
|
||||||
|
export type { ChangeKind } from './ChangeKind'
|
||||||
export type { Circle } from './Circle'
|
export type { Circle } from './Circle'
|
||||||
|
export type { CleaningOutcome } from './CleaningOutcome'
|
||||||
|
export type { Completeness } from './Completeness'
|
||||||
export type { CountRange } from './CountRange'
|
export type { CountRange } from './CountRange'
|
||||||
export type { Credit } from './Credit'
|
export type { Credit } from './Credit'
|
||||||
|
export type { Dependent } from './Dependent'
|
||||||
export type { DetailTriggerAnnotation } from './DetailTriggerAnnotation'
|
export type { DetailTriggerAnnotation } from './DetailTriggerAnnotation'
|
||||||
export type { DetailView } from './DetailView'
|
export type { DetailView } from './DetailView'
|
||||||
export type { DraftRestore } from './DraftRestore'
|
export type { DraftRestore } from './DraftRestore'
|
||||||
export type { DraftRestoreInput } from './DraftRestoreInput'
|
export type { DraftRestoreInput } from './DraftRestoreInput'
|
||||||
|
export type { DrawingCheck } from './DrawingCheck'
|
||||||
|
export type { DrawingResult } from './DrawingResult'
|
||||||
|
export type { EditCommand } from './EditCommand'
|
||||||
|
export type { ElementChange } from './ElementChange'
|
||||||
|
export type { ElementKey } from './ElementKey'
|
||||||
export type { ExportErrorKind } from './ExportErrorKind'
|
export type { ExportErrorKind } from './ExportErrorKind'
|
||||||
export type { ExportInput } from './ExportInput'
|
export type { ExportInput } from './ExportInput'
|
||||||
export type { ExportStep } from './ExportStep'
|
export type { ExportStep } from './ExportStep'
|
||||||
@@ -40,9 +51,11 @@ export type { LocalizedOptionalText } from './LocalizedOptionalText'
|
|||||||
export type { LocalizedText } from './LocalizedText'
|
export type { LocalizedText } from './LocalizedText'
|
||||||
export type { LogoSlot } from './LogoSlot'
|
export type { LogoSlot } from './LogoSlot'
|
||||||
export type { MainView } from './MainView'
|
export type { MainView } from './MainView'
|
||||||
|
export type { Marking } from './Marking'
|
||||||
export type { MigrationOutcome } from './MigrationOutcome'
|
export type { MigrationOutcome } from './MigrationOutcome'
|
||||||
export type { MoveDirection } from './MoveDirection'
|
export type { MoveDirection } from './MoveDirection'
|
||||||
export type { MoveObservationInput } from './MoveObservationInput'
|
export type { MoveObservationInput } from './MoveObservationInput'
|
||||||
|
export type { NewElement } from './NewElement'
|
||||||
export type { NewReportDraft } from './NewReportDraft'
|
export type { NewReportDraft } from './NewReportDraft'
|
||||||
export type { NewReportInput } from './NewReportInput'
|
export type { NewReportInput } from './NewReportInput'
|
||||||
export type { NextAppointment } from './NextAppointment'
|
export type { NextAppointment } from './NextAppointment'
|
||||||
@@ -61,31 +74,49 @@ export type { PngAsset } from './PngAsset'
|
|||||||
export type { Point } from './Point'
|
export type { Point } from './Point'
|
||||||
export type { Polygon } from './Polygon'
|
export type { Polygon } from './Polygon'
|
||||||
export type { Practitioner } from './Practitioner'
|
export type { Practitioner } from './Practitioner'
|
||||||
|
export type { PreviewDrawingState } from './PreviewDrawingState'
|
||||||
|
export type { PreviewDrawingStatus } from './PreviewDrawingStatus'
|
||||||
|
export type { PreviewIndex } from './PreviewIndex'
|
||||||
|
export type { PreviewInput } from './PreviewInput'
|
||||||
|
export type { PreviewState } from './PreviewState'
|
||||||
|
export type { PreviewStatus } from './PreviewStatus'
|
||||||
export type { RasterRequest } from './RasterRequest'
|
export type { RasterRequest } from './RasterRequest'
|
||||||
export type { RebaseOutcome } from './RebaseOutcome'
|
export type { RebaseOutcome } from './RebaseOutcome'
|
||||||
export type { Reference } from './Reference'
|
export type { Reference } from './Reference'
|
||||||
export type { ReferenceType } from './ReferenceType'
|
export type { ReferenceType } from './ReferenceType'
|
||||||
|
export type { Relation } from './Relation'
|
||||||
export type { Report } from './Report'
|
export type { Report } from './Report'
|
||||||
export type { ReportArchiveEnvelope } from './ReportArchiveEnvelope'
|
export type { ReportArchiveEnvelope } from './ReportArchiveEnvelope'
|
||||||
export type { ReportIdInput } from './ReportIdInput'
|
export type { ReportIdInput } from './ReportIdInput'
|
||||||
export type { ReportIndexInput } from './ReportIndexInput'
|
export type { ReportIndexInput } from './ReportIndexInput'
|
||||||
export type { ReportZone } from './ReportZone'
|
export type { ReportZone } from './ReportZone'
|
||||||
|
export type { ReviewGroup } from './ReviewGroup'
|
||||||
export type { ReviewStatus } from './ReviewStatus'
|
export type { ReviewStatus } from './ReviewStatus'
|
||||||
export type { SessionRefusal } from './SessionRefusal'
|
export type { SessionRefusal } from './SessionRefusal'
|
||||||
export type { Severity } from './Severity'
|
export type { Severity } from './Severity'
|
||||||
export type { SheetCheck } from './SheetCheck'
|
export type { SheetCheck } from './SheetCheck'
|
||||||
|
export type { SheetDependents } from './SheetDependents'
|
||||||
|
export type { SheetDependentsInput } from './SheetDependentsInput'
|
||||||
|
export type { SheetEditInput } from './SheetEditInput'
|
||||||
|
export type { SheetEditOutput } from './SheetEditOutput'
|
||||||
export type { SheetIndexData } from './SheetIndexData'
|
export type { SheetIndexData } from './SheetIndexData'
|
||||||
export type { SheetIssue } from './SheetIssue'
|
export type { SheetIssue } from './SheetIssue'
|
||||||
export type { SheetIssueSeverity } from './SheetIssueSeverity'
|
export type { SheetIssueSeverity } from './SheetIssueSeverity'
|
||||||
export type { SheetRef } from './SheetRef'
|
export type { SheetRef } from './SheetRef'
|
||||||
|
export type { SheetReport } from './SheetReport'
|
||||||
export type { SheetSnapshot } from './SheetSnapshot'
|
export type { SheetSnapshot } from './SheetSnapshot'
|
||||||
export type { SheetSnapshotAsset } from './SheetSnapshotAsset'
|
export type { SheetSnapshotAsset } from './SheetSnapshotAsset'
|
||||||
export type { SheetSnapshotRef } from './SheetSnapshotRef'
|
export type { SheetSnapshotRef } from './SheetSnapshotRef'
|
||||||
export type { SheetStatus } from './SheetStatus'
|
export type { SheetStatus } from './SheetStatus'
|
||||||
|
export type { SheetTexts } from './SheetTexts'
|
||||||
export type { SheetView } from './SheetView'
|
export type { SheetView } from './SheetView'
|
||||||
export type { SnapshotInput } from './SnapshotInput'
|
export type { SnapshotInput } from './SnapshotInput'
|
||||||
export type { SnapshotRejection } from './SnapshotRejection'
|
export type { SnapshotRejection } from './SnapshotRejection'
|
||||||
|
export type { StatusCounts } from './StatusCounts'
|
||||||
export type { SvgAsset } from './SvgAsset'
|
export type { SvgAsset } from './SvgAsset'
|
||||||
|
export type { SvgCleaning } from './SvgCleaning'
|
||||||
|
export type { Verdict } from './Verdict'
|
||||||
|
export type { VerdictOutcome } from './VerdictOutcome'
|
||||||
export type { Vertebra } from './Vertebra'
|
export type { Vertebra } from './Vertebra'
|
||||||
export type { VertebraAction } from './VertebraAction'
|
export type { VertebraAction } from './VertebraAction'
|
||||||
export type { VertebraSelectInput } from './VertebraSelectInput'
|
export type { VertebraSelectInput } from './VertebraSelectInput'
|
||||||
|
|||||||
Reference in new issue
Block a user