Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/cli/scripts/export-sdk-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ const INTENT_NAMES = {
'doc.tables.get': 'get_table',
'doc.tables.getCells': 'get_table_cells',
'doc.tables.getProperties': 'get_table_properties',
'doc.history.get': 'get_history',
'doc.history.undo': 'undo',
'doc.history.redo': 'redo',
} as const satisfies Record<DocBackedCliOpId, string>;

// ---------------------------------------------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions apps/cli/src/__tests__/conformance/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,26 @@ export const SUCCESS_SCENARIOS = {
'doc.tables.get': tableReadScenario('tables.get'),
'doc.tables.getCells': tableReadScenario('tables.getCells'),
'doc.tables.getProperties': tableReadScenario('tables.getProperties'),

// ---------------------------------------------------------------------------
// History operations
// ---------------------------------------------------------------------------

'doc.history.get': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
const stateDir = await harness.createStateDir('doc-history-get-success');
await harness.openSessionFixture(stateDir, 'doc-history-get', 'history-get-session');
return { stateDir, args: ['history', 'get', '--session', 'history-get-session'] };
},
'doc.history.undo': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
const stateDir = await harness.createStateDir('doc-history-undo-success');
await harness.openSessionFixture(stateDir, 'doc-history-undo', 'history-undo-session');
return { stateDir, args: ['history', 'undo', '--session', 'history-undo-session'] };
},
'doc.history.redo': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
const stateDir = await harness.createStateDir('doc-history-redo-success');
await harness.openSessionFixture(stateDir, 'doc-history-redo', 'history-redo-session');
return { stateDir, args: ['history', 'redo', '--session', 'history-redo-session'] };
},
} as const satisfies Record<CliOperationId, (harness: ConformanceHarness) => Promise<ScenarioInvocation>>;

export const OPERATION_SCENARIOS = (Object.keys(SUCCESS_SCENARIOS) as CliOperationId[]).map((operationId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ describe('contract response conformance', () => {

const success = envelope as SuccessEnvelope;
validateOperationResponseData(scenario.operationId, success.data, commandKey);

// Regression guard: history operations must serialize payload under `result`,
// never under an "undefined" key from missing envelope metadata.
if (scenario.operationId.startsWith('doc.history.')) {
const data = success.data as Record<string, unknown>;
expect(Object.prototype.hasOwnProperty.call(data, 'result')).toBe(true);
expect(Object.prototype.hasOwnProperty.call(data, 'undefined')).toBe(false);
}
});

test(`failure envelope conforms for ${scenario.operationId}`, async () => {
Expand Down
12 changes: 12 additions & 0 deletions apps/cli/src/cli/operation-hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export const SUCCESS_VERB: Record<CliExposedOperationId, string> = {
'tables.get': 'resolved table',
'tables.getCells': 'listed cells',
'tables.getProperties': 'resolved table properties',
'history.get': 'retrieved history state',
'history.undo': 'undid last change',
'history.redo': 'redid last change',
};

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -267,6 +270,9 @@ export const OUTPUT_FORMAT: Record<CliExposedOperationId, OutputFormat> = {
'tables.get': 'tableInfo',
'tables.getCells': 'tableCellList',
'tables.getProperties': 'tablePropertiesInfo',
'history.get': 'plain',
'history.undo': 'plain',
'history.redo': 'plain',
};

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -364,6 +370,9 @@ export const RESPONSE_ENVELOPE_KEY: Record<CliExposedOperationId, string | null>
'tables.get': 'result',
'tables.getCells': 'result',
'tables.getProperties': 'result',
'history.get': 'result',
'history.undo': 'result',
'history.redo': 'result',
};

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -489,4 +498,7 @@ export const OPERATION_FAMILY: Record<CliExposedOperationId, OperationFamily> =
'tables.get': 'tables',
'tables.getCells': 'tables',
'tables.getProperties': 'tables',
'history.get': 'query',
'history.undo': 'general',
'history.redo': 'general',
};
1 change: 1 addition & 0 deletions apps/cli/src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export type CliCategory =
| 'comments'
| 'trackChanges'
| 'capabilities'
| 'history'
| 'lifecycle'
| 'session'
| 'introspection';
Expand Down
4 changes: 4 additions & 0 deletions apps/docs/document-api/available-operations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Use the tables below to see what operations are available and where each one is
| Core | 8 | 0 | 8 | [Reference](/document-api/reference/core/index) |
| Create | 5 | 0 | 5 | [Reference](/document-api/reference/create/index) |
| Format | 44 | 1 | 45 | [Reference](/document-api/reference/format/index) |
| History | 3 | 0 | 3 | [Reference](/document-api/reference/history/index) |
| Lists | 8 | 0 | 8 | [Reference](/document-api/reference/lists/index) |
| Mutations | 2 | 0 | 2 | [Reference](/document-api/reference/mutations/index) |
| Paragraph Formatting | 17 | 0 | 17 | [Reference](/document-api/reference/format/paragraph/index) |
Expand Down Expand Up @@ -98,6 +99,9 @@ Use the tables below to see what operations are available and where each one is
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.stylisticSets(...)</code></span> | [`format.stylisticSets`](/document-api/reference/format/stylistic-sets) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.contextualAlternates(...)</code></span> | [`format.contextualAlternates`](/document-api/reference/format/contextual-alternates) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.strikethrough(...)</code></span> | [`format.strike`](/document-api/reference/format/strike) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.history.get(...)</code></span> | [`history.get`](/document-api/reference/history/get) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.history.undo(...)</code></span> | [`history.undo`](/document-api/reference/history/undo) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.history.redo(...)</code></span> | [`history.redo`](/document-api/reference/history/redo) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.lists.list(...)</code></span> | [`lists.list`](/document-api/reference/lists/list) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.lists.get(...)</code></span> | [`lists.get`](/document-api/reference/lists/get) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.lists.insert(...)</code></span> | [`lists.insert`](/document-api/reference/lists/insert) |
Expand Down
13 changes: 12 additions & 1 deletion apps/docs/document-api/reference/_generated-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
"apps/docs/document-api/reference/get-node-by-id.mdx",
"apps/docs/document-api/reference/get-node.mdx",
"apps/docs/document-api/reference/get-text.mdx",
"apps/docs/document-api/reference/history/get.mdx",
"apps/docs/document-api/reference/history/index.mdx",
"apps/docs/document-api/reference/history/redo.mdx",
"apps/docs/document-api/reference/history/undo.mdx",
"apps/docs/document-api/reference/index.mdx",
"apps/docs/document-api/reference/info.mdx",
"apps/docs/document-api/reference/insert.mdx",
Expand Down Expand Up @@ -423,6 +427,13 @@
"pagePath": "apps/docs/document-api/reference/tables/index.mdx",
"title": "Tables"
},
{
"aliasMemberPaths": [],
"key": "history",
"operationIds": ["history.get", "history.undo", "history.redo"],
"pagePath": "apps/docs/document-api/reference/history/index.mdx",
"title": "History"
},
{
"aliasMemberPaths": [],
"key": "toc",
Expand All @@ -432,5 +443,5 @@
}
],
"marker": "{/* GENERATED FILE: DO NOT EDIT. Regenerate via `pnpm run docapi:sync`. */}",
"sourceHash": "98ac639d0837d66b0d968f4a0811a0bac22f407a989caeda784326e40f337e68"
"sourceHash": "c5cf08d833b08c281a2bb18ec03caa6d95d20f69defe7897b30a9b903774705c"
}
170 changes: 168 additions & 2 deletions apps/docs/document-api/reference/capabilities/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ _No fields._
"COMMAND_UNAVAILABLE"
]
},
"history": {
"enabled": true,
"reasons": [
"COMMAND_UNAVAILABLE"
]
},
"lists": {
"enabled": true,
"reasons": [
Expand Down Expand Up @@ -960,6 +966,30 @@ _No fields._
],
"tracked": true
},
"history.get": {
"available": true,
"dryRun": true,
"reasons": [
"COMMAND_UNAVAILABLE"
],
"tracked": true
},
"history.redo": {
"available": true,
"dryRun": true,
"reasons": [
"COMMAND_UNAVAILABLE"
],
"tracked": true
},
"history.undo": {
"available": true,
"dryRun": true,
"reasons": [
"COMMAND_UNAVAILABLE"
],
"tracked": true
},
"info": {
"available": true,
"dryRun": true,
Expand Down Expand Up @@ -3195,6 +3225,33 @@ _No fields._
],
"type": "object"
},
"history": {
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean"
},
"reasons": {
"items": {
"enum": [
"COMMAND_UNAVAILABLE",
"HELPER_UNAVAILABLE",
"OPERATION_UNAVAILABLE",
"TRACKED_MODE_UNAVAILABLE",
"DRY_RUN_UNAVAILABLE",
"NAMESPACE_UNAVAILABLE",
"STYLES_PART_MISSING",
"COLLABORATION_ACTIVE"
]
},
"type": "array"
}
},
"required": [
"enabled"
],
"type": "object"
},
"lists": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -3254,7 +3311,8 @@ _No fields._
"trackChanges",
"comments",
"lists",
"dryRun"
"dryRun",
"history"
],
"type": "object"
},
Expand Down Expand Up @@ -5991,6 +6049,111 @@ _No fields._
],
"type": "object"
},
"history.get": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"dryRun": {
"type": "boolean"
},
"reasons": {
"items": {
"enum": [
"COMMAND_UNAVAILABLE",
"HELPER_UNAVAILABLE",
"OPERATION_UNAVAILABLE",
"TRACKED_MODE_UNAVAILABLE",
"DRY_RUN_UNAVAILABLE",
"NAMESPACE_UNAVAILABLE",
"STYLES_PART_MISSING",
"COLLABORATION_ACTIVE"
]
},
"type": "array"
},
"tracked": {
"type": "boolean"
}
},
"required": [
"available",
"tracked",
"dryRun"
],
"type": "object"
},
"history.redo": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"dryRun": {
"type": "boolean"
},
"reasons": {
"items": {
"enum": [
"COMMAND_UNAVAILABLE",
"HELPER_UNAVAILABLE",
"OPERATION_UNAVAILABLE",
"TRACKED_MODE_UNAVAILABLE",
"DRY_RUN_UNAVAILABLE",
"NAMESPACE_UNAVAILABLE",
"STYLES_PART_MISSING",
"COLLABORATION_ACTIVE"
]
},
"type": "array"
},
"tracked": {
"type": "boolean"
}
},
"required": [
"available",
"tracked",
"dryRun"
],
"type": "object"
},
"history.undo": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"dryRun": {
"type": "boolean"
},
"reasons": {
"items": {
"enum": [
"COMMAND_UNAVAILABLE",
"HELPER_UNAVAILABLE",
"OPERATION_UNAVAILABLE",
"TRACKED_MODE_UNAVAILABLE",
"DRY_RUN_UNAVAILABLE",
"NAMESPACE_UNAVAILABLE",
"STYLES_PART_MISSING",
"COLLABORATION_ACTIVE"
]
},
"type": "array"
},
"tracked": {
"type": "boolean"
}
},
"required": [
"available",
"tracked",
"dryRun"
],
"type": "object"
},
"info": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -9022,7 +9185,10 @@ _No fields._
"toc.get",
"toc.configure",
"toc.update",
"toc.remove"
"toc.remove",
"history.get",
"history.undo",
"history.redo"
],
"type": "object"
},
Expand Down
Loading
Loading