feat(examples): add comprehensive editV2 operation examples#33
Open
hnshah wants to merge 2 commits intoEveryInc:mainfrom
Open
feat(examples): add comprehensive editV2 operation examples#33hnshah wants to merge 2 commits intoEveryInc:mainfrom
hnshah wants to merge 2 commits intoEveryInc:mainfrom
Conversation
Fixes EveryInc#22 The editV2() method was missing from the agent bridge client, and there was a field name mismatch between what developers might expect and what the server actually accepts. Server expects: - baseRevision (number) - operations (array of ops) This adds: - EditV2Input interface with correct field names - EditV2BlockOp union type covering all 6 operation types - editV2() client method that POSTs to /documents/:slug/edit/v2 - Idempotency-Key header support (automatically set from input.idempotencyKey) All field names now match the server implementation in server/agent-edit-v2.ts.
Adds two new example scripts demonstrating all editV2 capabilities: 1. multi-step-workflow.ts - Shows sequential document building - Demonstrates revision tracking - Batch operations (multiple blocks in one request) - Real-world use case (project plan creation) 2. editv2-operations.ts - Comprehensive test of all 6 block operations - replace_block, insert_after, insert_before - delete_block, find_replace_in_block, replace_range - Error handling for each operation - Validates final document state Benefits: - Currently only 1 example exists (basic bridge usage) - These show recommended editV2 approach in practice - TypeScript examples using the bridge client - Proper idempotency and error handling patterns - Can be run as validation tests Run with: npm run demo:workflow npm run demo:operations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The directory currently has only one example () showing basic bridge usage with comments. There are no examples demonstrating:
Solution
This PR adds two comprehensive TypeScript examples that demonstrate all editV2 capabilities.
1.
multi-step-workflow.tsWhat it shows:
baseRevisiontrackingRun with:
Output:
2.
editv2-operations.tsWhat it tests:
replace_block- Update single blockinsert_after- Add blocks after referenceinsert_before- Add blocks before referencedelete_block- Remove blockfind_replace_in_block- Text replacement in a blockreplace_range- Replace multiple consecutive blocksRun with:
Output:
Benefits
For developers:
For contributors:
For documentation:
Testing
Both examples run successfully against a local Proof SDK server:
Files Changed
apps/proof-example/examples/multi-step-workflow.ts(+169 lines)apps/proof-example/examples/editv2-operations.ts(+230 lines)apps/proof-example/package.json(added 2 new scripts)apps/proof-example/README.md(documented new examples)Related