Rust Session Protocol — 28 команд
Полный перечень команд документной сессии: параметры, предусловия и результат каждой из 28 команд.
| cmd | изм. | params | предусловие | result |
|---|---|---|---|---|
| apply-composition | да | request: json (required) | open | CompositionReceipt |
| apply-text-transaction | да | request: json (required) | open | AcceptedEditTerminal { dirty, receipt, model_delta, model_projection_patch, owner_state, typing_attributes } |
| commit-snapshot | да | document_id: string (required); path: string (required); transaction_order: integer (required); transition_kind: string (required) | open | legacy commit/history receipt |
| commit-structural-snapshot | да | path: string (required); request: json (required) | open | structural edit terminal/receipt |
| compatibility-inspect | нет | — | open | fastdoc.docx-compatibility-command.v1 |
| compose | нет | — | open | ParagraphCompositionSnapshot[] |
| model | нет | — | open | CanonicalDocument |
| mutate | да | after_caret_slot_index: integer-or-null (optional); before_caret_slot_index: integer-or-null (optional); before_selection_end_slot_index: integer-or-null (optional); before_selection_start_slot_index: integer-or-null (optional); delete_count: integer (optional, default=0); document_id: string-or-null (optional); offset: integer (optional, default=0); operation_kind: string (required); paragraph_index: integer (required); revision_author: string-or-null (optional); revision_date: string-or-null (optional); revision_date_utc: string-or-null (optional); text: string-or-null (optional); transaction_order: integer (optional, default=0); transition_kind: string-or-null (optional) | open | { mutation: BodyTextMutationSnapshot, mutation_count, history } |
| open | да | document_id: string-or-null (optional); path: string (required) | нет | { opened, byte_count, digital_signature_present, session_id, document_id, revision, accepted_revision, dirty, history, open_stage_timings_ms } |
| paginate | нет | — | open | PaginationSnapshot |
| ping | нет | — | нет | { pong: true } |
| нет | tracked_change_markup_mode: string-or-null (optional) | open | PrintParitySnapshot | |
| print-delta | нет | known_fingerprints: json-array (optional); tracked_change_markup_mode: string-or-null (optional) | open | snapshot metadata + changed_pages[] + unchanged_page_indexes[] |
| print-summary | нет | — | open | { page_count, line_item_count, scene_fingerprints[] } |
| print-window | нет | include_page_stack: boolean (optional); page_indexes: json-array (required) | open | Print window + materialized pages; optional page_stack/windowed model |
| redo | да | document_id: string-or-null (optional); transaction_order: integer (optional, default=0) | open | history + transition + redone=true + receipt |
| report | нет | — | open | SupportReport |
| review | нет | — | open | ReviewSnapshot |
| save | да | path: string-or-null (optional) | open | { saved, saved_document_itself?, byte_count, history_preserved, history } |
| save-checkpoint | да | expected_revision: integer (required); request_id: string (required); session_id: string (required); target: json (required) | open | fastdoc.persistent-save-checkpoint-receipt.v1 |
| set-selection | да | request: json (required) | open | SelectionUpdateReceipt |
| shutdown | да | — | нет | { id, ok:true, shutdown:true } |
| simple-field-inventory | нет | — | open | SimpleFieldInventorySnapshot |
| squash-history | да | base_undo_depth: integer (required); document_id: string (required); transition_kind: string-or-null (optional) | open | history state |
| status | нет | — | open | session/path/cache/history/revision/dirty/model_hash state |
| style | нет | — | open | StyleSnapshot |
| track-revisions-state | нет | — | open | TrackRevisionsStateSnapshot |
| undo | да | document_id: string-or-null (optional); transaction_order: integer (optional, default=0) | open | history + transition + undone=true + receipt |
2.1. apply-composition
Заголовок раздела «2.1. apply-composition»Параметры: request: json (required)
Результат: CompositionReceipt
{ "id": "req-1", "cmd": "apply-composition", "request": { "...": "typed DTO; см. раздел 4" }}Concurrency. expected_revision и expected_selection_revision обязательны; stale request отклоняется.
2.2. apply-text-transaction
Заголовок раздела «2.2. apply-text-transaction»Параметры: request: json (required)
Результат: AcceptedEditTerminal { dirty, receipt, model_delta, model_projection_patch, owner_state, typing_attributes }
{ "id": "req-1", "cmd": "apply-text-transaction", "request": { "...": "typed DTO; см. раздел 4" }}Concurrency. expected_revision и expected_selection_revision обязательны; stale request отклоняется.
2.3. commit-snapshot
Заголовок раздела «2.3. commit-snapshot»Параметры: document_id: string (required); path: string (required); transaction_order: integer (required); transition_kind: string (required)
Результат: legacy commit/history receipt
{ "id": "req-1", "cmd": "commit-snapshot", "document_id": "document_id-1", "path": "/absolute/document.docx", "transaction_order": 1, "transition_kind": "transition_kind-1"}2.4. commit-structural-snapshot
Заголовок раздела «2.4. commit-structural-snapshot»Параметры: path: string (required); request: json (required)
Результат: structural edit terminal/receipt
{ "id": "req-1", "cmd": "commit-structural-snapshot", "path": "/absolute/document.docx", "request": { "...": "typed DTO; см. раздел 4" }}2.5. compatibility-inspect
Заголовок раздела «2.5. compatibility-inspect»Параметры: —
Результат: fastdoc.docx-compatibility-command.v1
{ "id": "req-1", "cmd": "compatibility-inspect"}2.6. compose
Заголовок раздела «2.6. compose»Параметры: —
Результат: ParagraphCompositionSnapshot[]
{ "id": "req-1", "cmd": "compose"}2.7. model
Заголовок раздела «2.7. model»Параметры: —
Результат: CanonicalDocument
{ "id": "req-1", "cmd": "model"}2.8. mutate
Заголовок раздела «2.8. mutate»Параметры: after_caret_slot_index: integer-or-null (optional); before_caret_slot_index: integer-or-null (optional); before_selection_end_slot_index: integer-or-null (optional); before_selection_start_slot_index: integer-or-null (optional); delete_count: integer (optional, default=0); document_id: string-or-null (optional); offset: integer (optional, default=0); operation_kind: string (required); paragraph_index: integer (required); revision_author: string-or-null (optional); revision_date: string-or-null (optional); revision_date_utc: string-or-null (optional); text: string-or-null (optional); transaction_order: integer (optional, default=0); transition_kind: string-or-null (optional)
Результат: { mutation: BodyTextMutationSnapshot, mutation_count, history }
{ "id": "req-1", "cmd": "mutate", "operation_kind": "insert-text", "paragraph_index": 0}Единицы. offset/delete_count — Unicode scalar indexes. Для JS используйте Array.from(text).length, не string.length.
2.9. open
Заголовок раздела «2.9. open»Параметры: document_id: string-or-null (optional); path: string (required)
Результат: { opened, byte_count, digital_signature_present, session_id, document_id, revision, accepted_revision, dirty, history, open_stage_timings_ms }
{ "id": "req-1", "cmd": "open", "path": "/absolute/document.docx"}2.10. paginate
Заголовок раздела «2.10. paginate»Параметры: —
Результат: PaginationSnapshot
{ "id": "req-1", "cmd": "paginate"}2.11. ping
Заголовок раздела «2.11. ping»Параметры: —
Результат: { pong: true }
{ "id": "req-1", "cmd": "ping"}2.12. print
Заголовок раздела «2.12. print»Параметры: tracked_change_markup_mode: string-or-null (optional)
Результат: PrintParitySnapshot
{ "id": "req-1", "cmd": "print"}2.13. print-delta
Заголовок раздела «2.13. print-delta»Параметры: known_fingerprints: json-array (optional); tracked_change_markup_mode: string-or-null (optional)
Результат: snapshot metadata + changed_pages[] + unchanged_page_indexes[]
{ "id": "req-1", "cmd": "print-delta"}2.14. print-summary
Заголовок раздела «2.14. print-summary»Параметры: —
Результат: { page_count, line_item_count, scene_fingerprints[] }
{ "id": "req-1", "cmd": "print-summary"}2.15. print-window
Заголовок раздела «2.15. print-window»Параметры: include_page_stack: boolean (optional); page_indexes: json-array (required)
Результат: Print window + materialized pages; optional page_stack/windowed model
{ "id": "req-1", "cmd": "print-window", "page_indexes": [ 0 ]}2.16. redo
Заголовок раздела «2.16. redo»Параметры: document_id: string-or-null (optional); transaction_order: integer (optional, default=0)
Результат: history + transition + redone=true + receipt
{ "id": "req-1", "cmd": "redo"}2.17. report
Заголовок раздела «2.17. report»Параметры: —
Результат: SupportReport
{ "id": "req-1", "cmd": "report"}2.18. review
Заголовок раздела «2.18. review»Параметры: —
Результат: ReviewSnapshot
{ "id": "req-1", "cmd": "review"}2.19. save
Заголовок раздела «2.19. save»Параметры: path: string-or-null (optional)
Результат: { saved, saved_document_itself?, byte_count, history_preserved, history }
{ "id": "req-1", "cmd": "save"}2.20. save-checkpoint
Заголовок раздела «2.20. save-checkpoint»Параметры: expected_revision: integer (required); request_id: string (required); session_id: string (required); target: json (required)
Результат: fastdoc.persistent-save-checkpoint-receipt.v1
{ "id": "req-1", "cmd": "save-checkpoint", "expected_revision": 1, "request_id": "request_id-1", "session_id": "session_id-1", "target": { "path": "/absolute/document.docx", "expected_hash": "sha256:..." }}2.21. set-selection
Заголовок раздела «2.21. set-selection»Параметры: request: json (required)
Результат: SelectionUpdateReceipt
{ "id": "req-1", "cmd": "set-selection", "request": { "...": "typed DTO; см. раздел 4" }}Concurrency. expected_revision и expected_selection_revision обязательны; stale request отклоняется.
2.22. shutdown
Заголовок раздела «2.22. shutdown»Параметры: —
Результат: { id, ok:true, shutdown:true }
{ "id": "req-1", "cmd": "shutdown"}2.23. simple-field-inventory
Заголовок раздела «2.23. simple-field-inventory»Параметры: —
Результат: SimpleFieldInventorySnapshot
{ "id": "req-1", "cmd": "simple-field-inventory"}2.24. squash-history
Заголовок раздела «2.24. squash-history»Параметры: base_undo_depth: integer (required); document_id: string (required); transition_kind: string-or-null (optional)
Результат: history state
{ "id": "req-1", "cmd": "squash-history", "base_undo_depth": 1, "document_id": "document_id-1"}2.25. status
Заголовок раздела «2.25. status»Параметры: —
Результат: session/path/cache/history/revision/dirty/model_hash state
{ "id": "req-1", "cmd": "status"}2.26. style
Заголовок раздела «2.26. style»Параметры: —
Результат: StyleSnapshot
{ "id": "req-1", "cmd": "style"}2.27. track-revisions-state
Заголовок раздела «2.27. track-revisions-state»Параметры: —
Результат: TrackRevisionsStateSnapshot
{ "id": "req-1", "cmd": "track-revisions-state"}2.28. undo
Заголовок раздела «2.28. undo»Параметры: document_id: string-or-null (optional); transaction_order: integer (optional, default=0)
Результат: history + transition + undone=true + receipt
{ "id": "req-1", "cmd": "undo"}