ICRAR / EAGLE

Editor for the Astronomical Graph Language Environment
GNU Lesser General Public License v3.0
0 stars 1 forks source link

Eagle 1269 - Remove keys from EAGLE #735

Closed james-strauss-uwa closed 2 months ago

james-strauss-uwa commented 2 months ago

This work removes keys from EAGLE, and uses ids (uuidv4) everywhere instead. It touches many systems, but simplifies the code a lot, particularly when loading data from JSON.

Edge now contains: id, srcNodeId, destNodeId instead of _id, srcNodeKey, destNodeKey Field now contains: nodeId instead of nodeKey Node now contains: id, parentId, embedId instead of _id, key, parentKey, embedKey

The ids have been given more specific types (defined in main.ts). Instead of all ids being of type "string", they are now "NodeId", "FieldId" or "EdgeId". New ids can be generated using Utils.generateNodeId(), Utils.generateFieldId() or Utils.generateEdgeId(). This prevents using the wrong type of id in a function.

This change modifies the JSON format significantly, so a new function, updateKeysToIds(), is added to GraphUpdater, and called whenever EAGLE loads JSON.

It would be useful if you could load any test graphs that you're familiar with, to check that they load correctly.

Summary by Sourcery

Transition from using keys to UUIDs for nodes, fields, and edges across the system to enhance data integrity and type safety. Update JSON format and utility functions to support the new ID system, and adjust tests and documentation accordingly.

Enhancements:

Documentation:

Tests:

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request removes the use of keys from the EAGLE project and replaces them with UUIDs (ids) throughout the codebase. This change simplifies the code, particularly when loading data from JSON, and introduces more specific types for different kinds of ids (NodeId, FieldId, EdgeId). The changes touch many systems and files, modifying the data structure of Nodes, Edges, and Fields, as well as updating related functions and UI components.

File-Level Changes

Files Changes
src/Node.ts
src/Edge.ts
src/Field.ts
Replaced 'key' with 'id' in Node, Edge, and Field classes, using more specific types (NodeId, EdgeId, FieldId)
src/Utils.ts
src/LogicalGraph.ts
src/GraphRenderer.ts
src/Eagle.ts
Updated functions to use new id types instead of keys
src/GraphUpdater.ts
src/Node.ts
src/Edge.ts
src/Field.ts
Modified JSON parsing and serialization to work with ids instead of keys
templates/node_inspector.html
templates/edge_inspector.html
static/components/hierarchy-node.html
templates/modals/edit_edge.html
Updated UI components and templates to display and use ids instead of keys
src/Setting.ts
src/Eagle.ts
Removed key-related settings and functions
src/Utils.ts Added new utility functions for generating typed ids
tests/page-model.js
tests/edit-edge.js
Updated tests and page models to work with new id system
src/main.ts Added type declarations for NodeId, FieldId, and EdgeId
src/GraphUpdater.ts Implemented a function to update old graphs using keys to the new id system

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.