refactor: Renamed updateAsset to mergeData#72
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the updateAsset method to mergeData to better reflect its merge semantics, and introduces a breaking API change where null values (instead of undefined) are used to delete properties. The refactor also improves CLI efficiency by eliminating the need to fetch entire assets before updating individual properties.
Changes:
- Renamed
updateAssettomergeDataacross the codebase (interface, implementation, tests, CLI tools) - Changed property deletion mechanism from
undefinedtonull(breaking API change) - Refactored CLI
set-propertycommand to use direct merge instead of fetch-modify-update pattern
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/keymaster/src/types.ts | Updated interface to rename method from updateAsset to mergeData |
| packages/keymaster/src/keymaster.ts | Implemented mergeData with null-based deletion logic; updated all internal calls |
| packages/keymaster/src/keymaster-client.ts | Updated client method name to match interface |
| packages/keymaster/src/cli.ts | Refactored set-property to use direct merge with single-key objects |
| scripts/archon-cli.js | Applied same refactoring as cli.ts |
| services/keymaster/server/src/keymaster-api.ts | Updated API endpoint to use mergeData |
| services/mediators/hyperswarm/src/hyperswarm-mediator.ts | Updated method call to mergeData |
| tests/keymaster/asset.test.ts | Updated test suite and added null deletion test |
| tests/keymaster/client.test.ts | Updated test suite with new method name |
| tests/keymaster/vault.test.ts | Updated test to use mergeData |
| tests/hypr-confirm.js | Updated integration test to use mergeData |
Comments suppressed due to low confidence (1)
tests/keymaster/asset.test.ts:412
- Missing test coverage for the behavior when a property is set to undefined. The implementation only deletes properties when set to null (line 1294), but there's no test verifying that undefined values are preserved (not deleted). This could lead to confusion about the API contract. Consider adding a test that verifies setting a property to undefined preserves it with an undefined value.
it('should remove a property when set to null', async () => {
await keymaster.createId('Bob');
const mockAsset1 = { key1: 'val1', key2: 'val2' };
const mockAsset2 = { key2: null };
const did = await keymaster.createAsset(mockAsset1);
const ok = await keymaster.mergeData(did, mockAsset2);
const asset = await keymaster.resolveAsset(did);
expect(ok).toBe(true);
expect(asset).toStrictEqual({ key1: 'val1' });
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.