feat(domain): sheet.empty free op for a new sheet's document (V1-2.5 C)
Wraps create_empty_sheet_document; refusals invalid_shape / invalid_json; ts-rs SheetEmptyInput, core-wasm proof, app wrapper emptySheetDocument.
This commit is contained in:
1 parent
b0a4cbe588
commit
bbab0e61cb
8 files changed
+159
-4
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import type { CoreOutcome } from '@faunosteo/core-wasm'
|
||||
import type {
|
||||
AnatomicalSheetDocument,
|
||||
LocalizedText,
|
||||
SheetEmptyInput,
|
||||
} from '@faunosteo/core-wasm/types'
|
||||
import { coreRuntime } from './runtime'
|
||||
|
||||
/**
|
||||
* The sheet document rules that need no loaded sheet (V1-2.5): the document a new sheet
|
||||
* starts from. The slug is not part of it; it goes to `create_official_sheet` beside it.
|
||||
*/
|
||||
|
||||
export interface EmptySheetInput {
|
||||
speciesId: string
|
||||
name: LocalizedText
|
||||
}
|
||||
|
||||
/** Failure: `invalid_shape` for an invalid species id or an empty label. */
|
||||
export function emptySheetDocument(
|
||||
input: EmptySheetInput,
|
||||
): CoreOutcome<AnatomicalSheetDocument> {
|
||||
const payload: SheetEmptyInput = {
|
||||
species_id: input.speciesId,
|
||||
name: input.name,
|
||||
}
|
||||
return coreRuntime().call<AnatomicalSheetDocument>(
|
||||
'sheet.empty',
|
||||
JSON.stringify(payload),
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user