feat(models): add full JSON model export/import workflow with UI support#182
Merged
krystianbajno merged 2 commits intomainfrom Mar 18, 2026
Merged
feat(models): add full JSON model export/import workflow with UI support#182krystianbajno merged 2 commits intomainfrom
krystianbajno merged 2 commits intomainfrom
Conversation
Tyouxik
approved these changes
Mar 18, 2026
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.
JSON Import/Export Feature
Goal Delivered
Implemented full model JSON transfer so a Gram model can be:
This includes backend APIs, core transfer logic, frontend UI actions, auth/authz enforcement, and test coverage.
What Is New
1) Versioned JSON Transfer Contract
Introduced a dedicated contract for model transfer:
core/src/data/models/ModelTransfer.tsKey additions:
MODEL_TRANSFER_SCHEMA_VERSIONModelExportPayloadwith full model-bound data:metadatamodelmodelData(components,dataFlows)threats,controls,mitigationssuggestions(now exported empty intentionally)links,flows,resourceMatchings,reviewImportMode:create-newandin-placeModelImportOptionsandModelImportResultAI-friendly metadata support:
metadata.aiInstructionsis exported for deterministic external editing guidance.2) Core Transfer Service (Export + Import)
Created/extended transfer orchestration in:
core/src/data/models/ModelTransferService.tsExport behavior:
threat.suggestionIdandcontrol.suggestionIdas unset to avoid stale/fake bindings.Import behavior:
create-new: imports into a newly created model.in-place: replaces target model content.dataFlow.bidirectionaltofalsefor compatibility with older payloads.DAL wiring:
core/src/data/dal.tsnow exposesmodelTransferService.3) Backend API Endpoints
Added model JSON transfer endpoints under v1 models router:
GET /api/v1/models/:id/export-jsonPOST /api/v1/models/import-jsonFiles:
api/src/resources/gram/v1/models/exportJson.tsapi/src/resources/gram/v1/models/importJson.tsapi/src/resources/gram/v1/models/router.tsValidation:
api/src/resources/gram/v1/models/jsonTransferSchema.tsseverity,description,reason,shouldReviewActionItems,bidirectional).Security:
413on oversized payloads).4) Frontend Buttons + Modals
Added user-facing import/export actions in model board UI.
API integration:
app/src/api/gram/model.jsexportModelJsonqueryimportModelJsonmutationModals:
app/src/components/model/modals/ExportModelJson.jsapp/src/components/model/modals/ImportModelJson.jsModal registration:
app/src/components/elements/modal/ModalManager.jsToolbar buttons:
app/src/components/model/board/components/ControlsToolBar.js5) Tests
Added endpoint-level tests for JSON transfer:
api/src/resources/gram/v1/models/jsonTransfer.spec.tsCoverage includes:
create-newimport modein-placeimport modeBuild Status
Validated after changes:
@gram/corebuild passes@gram/apibuild passes@gram/configbuild passesPractical Usage
create-newto create a new model from JSON.in-placeto overwrite current model content.Notes