跳转到内容
EN

Read one unit with its blocks and Markdown

Code Mode: praxis.studio.works.units.retrieve

HTTP: GET /studio/v1/works/{work}/units/{unit}

Read one unit: its intent, its status, its revision, its links to reference entries, and its body as both blocks and Markdown. The Markdown carries each block identifier inline as an anchor comment, so a rewrite can keep the identifiers of the blocks it keeps. Read this before writing the body, because the revision it returns is the precondition that write has to carry.

签名

praxis.studio.works.units.retrieve(args:{path:{/** e.g. "wu-gang" */ work:string;/** e.g. "12" */ unit:string};query?:{/** e.g. "full" */ view?:"full"|"basic"}}):Promise<({/** Unit identifier, stable when units are moved or renamed. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** Work this unit belongs to; it is the same value the work path segment carries. e.g. "wk_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ work?:string;/** Draft this unit belongs to; units never move between drafts. e.g. "drf_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ draft?:string;/** In-work number assigned in creation order, never reused and unchanged by a move; it is what the unit path segment takes. e.g. 12 */ number:number;/** Unit this one sits under, or null at the top level of the tree. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ parent?:string;/** Sort key among siblings; it is opaque, and moving a unit rewrites only its own row. e.g. "0|hzzzzz:" */ position?:string;/** Structural kind of this unit, which must be one the genre allows at this position of the tree. e.g. "chapter" */ kind:string;/** Structure name used by people and agents to manage the tree, such as the second scene of a chapter; it is not the published heading. e.g. "第二章 · 排字房" */ name:string;/** Heading the finished piece shows for this unit, or null when it shows none; a genre may require it or forbid it. e.g. "第二章 排字房" */ heading?:string;intent:{/** What this unit has to accomplish, written as the story so far for later units; it is what a reader of the outline sees. e.g. "主角在排字房看到通缉令,第一次动摇了立场。" */ synopsis:string;/** Points this unit hits, called beats, arguments or selling points depending on the genre. */ points:Array<string>;/** Keys of the brief points this unit claims, which is how the requirement coverage check knows a point landed. */ brief_points:Array<string>;/** Intent revision, moved whenever the synopsis or the points change; a body written against an older value is behind. e.g. 4 */ revision:number;/** Whether the writer confirmed the synopsis matches what the body actually says, rather than what was planned. */ synopsis_from_body:boolean};/** How far this unit has come, moving forward as intent and body are written; a unit marked final refuses changes without confirmation. */ status:"idea"|"outlined"|"writing"|"drafted"|"revised"|"final";/** Intent revision the current body was written against, or null when there is no body; an older value means the intent moved on. e.g. 4 */ body_from_intent?:number;/** Unit of the upstream draft this one was written from, present when the draft derives from another; a serial of a novel records it per section. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ source_unit?:string;/** Reference entries this unit is tied to, including the mentions detected in its text. */ links?:Array<{/** Identifier of the reference entry this unit is tied to. e.g. "ent_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ entry?:string;/** How the tie came about, which decides whether the entry reaches the context pack for this unit. */ kind?:"mention"|"attached"|"excluded";/** Role of the entry inside this genre, such as point-of-view character or main product; it lifts the entry's priority in the pack. e.g. "视角人物" */ role?:string}>;/** Characters in the body with whitespace removed, which is what the length checks measure. e.g. 2680 */ chars:number;/** Duration in seconds for units of a video genre, or null for a written unit. e.g. 42 */ seconds?:number;/** Unit revision, moved by any change to the unit; pass it as expected_revision when writing the body. e.g. 6 */ revision:number;last_editor?:{/** Whether the change came from a person, an agent or the platform itself; an agent session through the API is recorded as an agent. */ kind?:"user"|"agent"|"system";/** Identifier of that actor, such as a user identifier or an agent session identifier. e.g. "usr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id?:string;/** Display name of the actor when one is known, shown beside the change. e.g. "张三" */ label?:string};/** Body blocks, present only when the unit was read with its content; writing block by block needs their identifiers. */ blocks?:Array<{/** Block identifier, carried inline in Markdown as an anchor comment so an edit can address one block without rewriting the body. e.g. "blk_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** Unit revision at which this block was last changed; it decides whether an older precondition still allows a block edit. e.g. 6 */ revision:number;/** Element kind of this block, from the set the genre allows; it decides how the block is rendered in a rendition. */ type:"paragraph"|"heading"|"list"|"quote"|"code"|"image"|"video"|"divider"|"scene_break"|"callout"|"hashtags"|"link"|"cut"|"canvas";/** Markdown text of this block, empty for blocks that carry a reference instead of words. e.g. "排字房的铅字盘上,压着一张通缉令。" */ text:string;/** File this block shows, for image and video blocks, referenced by its file identifier. e.g. "file_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ file?:string;/** Caption shown with a media block and carried into renditions that keep captions. e.g. "1935 年的排字房" */ caption?:string;/** Heading depth for a heading block, one to four, which decides the outline level in the finished piece. e.g. 2 */ level?:number}>})&({/** Whole body as Markdown with block anchors kept inline, so a rewrite can round-trip the block identifiers. e.g. "第一段。<!-- blk_01JQ8Z3M9K4V7B2N6C5X0YTRHW -->" */ markdown?:string;intent_diff?:{/** Intent revision the current body was written against. e.g. 4 */ from_revision?:number;/** Synopsis at that revision, shown beside the newer one so a writer can see what moved. e.g. "主角在报馆第一次见到通缉令。" */ synopsis?:string;/** Intent points at that revision, in the order they were written. */ points?:Array<string>}})>;

参数

名称位置类型必填说明
workpathstring是The work being addressed, either its organization-unique slug or its wk_ identifier; a slug case is what a person would say, and a renamed slug still resolves through its old value.
unitpathstring是Unit being addressed, written as its in-work number such as 12, as #12, or as its unt_ identifier; the number never changes when the unit is moved.
viewquery“full” | “basic”否How much of the unit to return: full includes the blocks and the Markdown body, and basic returns the unit row without the body for a cheap status check.

响应

状态码内容类型说明
200application/jsonThe unit with its intent, status and revisions, and its blocks and Markdown unless a basic view was asked for.
400application/jsonINVALID_PARAMS means a field is missing, malformed or not allowed for this resource; correct the named field and repeat the call.
401application/jsonThe API key is missing, invalid or carries no organization; send a valid organization key in the Authorization header.
404application/jsonWORK_NOT_FOUND, DRAFT_NOT_FOUND or UNIT_NOT_FOUND means one address in the path names nothing reachable; use the numbers and keys from the outline rather than a remembered one, since a unit that was deleted never returns.
500application/jsonINTERNAL means the request could not complete; re-read the resource before retrying a write, because the write may already have landed.