-
Notifications
You must be signed in to change notification settings - Fork 21
feat: dispatch registry, backend interfaces, and MockBackend #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
99cf0eb
style: apply go fmt to files with pre-existing formatting issues
retran caed015
feat: add typed error system for executor
retran d0870b5
fix: address review feedback on typed errors
retran 98dc2d4
feat: add dispatch registry, backend interfaces, ExecContext, and Mpr…
retran 5d24fe2
feat: wire dispatch registry, replace type-switch, add MockBackend
retran 4cb0501
fix: address PR #224 review feedback
retran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package backend | ||
|
|
||
| // FullBackend composes every domain backend into a single interface. | ||
| // Implementations must satisfy all sub-interfaces. | ||
| // | ||
| // Handler functions receive the specific sub-interface they need via | ||
| // ExecContext; FullBackend exists primarily as a construction-time | ||
| // constraint on backend implementations. | ||
| type FullBackend interface { | ||
| ConnectionBackend | ||
| ModuleBackend | ||
| FolderBackend | ||
| DomainModelBackend | ||
| MicroflowBackend | ||
| PageBackend | ||
| EnumerationBackend | ||
| ConstantBackend | ||
| SecurityBackend | ||
| NavigationBackend | ||
| ServiceBackend | ||
| MappingBackend | ||
| JavaBackend | ||
| WorkflowBackend | ||
| SettingsBackend | ||
| ImageBackend | ||
| ScheduledEventBackend | ||
| RenameBackend | ||
| RawUnitBackend | ||
| MetadataBackend | ||
| WidgetBackend | ||
| AgentEditorBackend | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package backend | ||
|
|
||
| import ( | ||
| "github.com/mendixlabs/mxcli/model" | ||
| "github.com/mendixlabs/mxcli/sdk/mpr" | ||
| "github.com/mendixlabs/mxcli/sdk/mpr/version" | ||
| ) | ||
|
|
||
| // ConnectionBackend manages the lifecycle of a backend connection. | ||
| type ConnectionBackend interface { | ||
| // Connect opens a connection to the project at path. | ||
| Connect(path string) error | ||
| // Disconnect closes the connection, finalizing any pending work. | ||
| Disconnect() error | ||
| // Commit flushes any pending writes. Implementations that auto-commit | ||
| // (e.g. MprBackend) may treat this as a no-op. | ||
| Commit() error | ||
| // IsConnected reports whether the backend has an active connection. | ||
| IsConnected() bool | ||
| // Path returns the path of the connected project, or "" if not connected. | ||
| Path() string | ||
| // Version returns the MPR format version. | ||
| Version() mpr.MPRVersion | ||
| // ProjectVersion returns the Mendix project version. | ||
| ProjectVersion() *version.ProjectVersion | ||
| // GetMendixVersion returns the Mendix version string. | ||
| GetMendixVersion() (string, error) | ||
| } | ||
|
|
||
| // ModuleBackend provides module-level operations. | ||
| type ModuleBackend interface { | ||
| ListModules() ([]*model.Module, error) | ||
| GetModule(id model.ID) (*model.Module, error) | ||
| GetModuleByName(name string) (*model.Module, error) | ||
| CreateModule(module *model.Module) error | ||
| UpdateModule(module *model.Module) error | ||
| DeleteModule(id model.ID) error | ||
| DeleteModuleWithCleanup(id model.ID, moduleName string) error | ||
| } | ||
|
|
||
| // FolderBackend provides folder operations. | ||
| type FolderBackend interface { | ||
| ListFolders() ([]*mpr.FolderInfo, error) | ||
| CreateFolder(folder *model.Folder) error | ||
| DeleteFolder(id model.ID) error | ||
| MoveFolder(id model.ID, newContainerID model.ID) error | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Package backend defines domain-specific interfaces that decouple the | ||
| // executor from concrete storage (e.g. .mpr files). Each interface | ||
| // groups related read/write operations by domain concept. | ||
| // | ||
| // Several method signatures currently reference types from sdk/mpr | ||
| // (e.g. NavigationDocument, FolderInfo, ImageCollection, JsonStructure, | ||
| // JavaAction, EntityMemberAccess, RenameHit). These should eventually be | ||
| // extracted into a shared types package to remove the mpr dependency. | ||
| package backend |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package backend | ||
|
|
||
| import ( | ||
| "github.com/mendixlabs/mxcli/model" | ||
| "github.com/mendixlabs/mxcli/sdk/domainmodel" | ||
| ) | ||
|
|
||
| // DomainModelBackend provides domain model, entity, attribute, and | ||
| // association operations. | ||
| type DomainModelBackend interface { | ||
| // Domain models | ||
| ListDomainModels() ([]*domainmodel.DomainModel, error) | ||
| GetDomainModel(moduleID model.ID) (*domainmodel.DomainModel, error) | ||
| GetDomainModelByID(id model.ID) (*domainmodel.DomainModel, error) | ||
| UpdateDomainModel(dm *domainmodel.DomainModel) error | ||
|
|
||
| // Entities | ||
| CreateEntity(domainModelID model.ID, entity *domainmodel.Entity) error | ||
| UpdateEntity(domainModelID model.ID, entity *domainmodel.Entity) error | ||
| DeleteEntity(domainModelID model.ID, entityID model.ID) error | ||
| MoveEntity(entity *domainmodel.Entity, sourceDMID, targetDMID model.ID, sourceModuleName, targetModuleName string) ([]string, error) | ||
|
|
||
| // Attributes | ||
| AddAttribute(domainModelID model.ID, entityID model.ID, attr *domainmodel.Attribute) error | ||
| UpdateAttribute(domainModelID model.ID, entityID model.ID, attr *domainmodel.Attribute) error | ||
| DeleteAttribute(domainModelID model.ID, entityID model.ID, attrID model.ID) error | ||
|
|
||
| // Associations | ||
| CreateAssociation(domainModelID model.ID, assoc *domainmodel.Association) error | ||
| CreateCrossAssociation(domainModelID model.ID, ca *domainmodel.CrossModuleAssociation) error | ||
| DeleteAssociation(domainModelID model.ID, assocID model.ID) error | ||
| DeleteCrossAssociation(domainModelID model.ID, assocID model.ID) error | ||
|
|
||
| // View entities | ||
| CreateViewEntitySourceDocument(moduleID model.ID, moduleName, docName, oqlQuery, documentation string) (model.ID, error) | ||
| DeleteViewEntitySourceDocument(id model.ID) error | ||
| DeleteViewEntitySourceDocumentByName(moduleName, docName string) error | ||
| FindViewEntitySourceDocumentID(moduleName, docName string) (model.ID, error) | ||
| FindAllViewEntitySourceDocumentIDs(moduleName, docName string) ([]model.ID, error) | ||
| MoveViewEntitySourceDocument(sourceModuleName string, targetModuleID model.ID, docName string) error | ||
| UpdateOqlQueriesForMovedEntity(oldQualifiedName, newQualifiedName string) (int, error) | ||
| UpdateEnumerationRefsInAllDomainModels(oldQualifiedName, newQualifiedName string) error | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package backend | ||
|
|
||
| import ( | ||
| "github.com/mendixlabs/mxcli/model" | ||
| ) | ||
|
|
||
| // EnumerationBackend provides enumeration operations. | ||
| type EnumerationBackend interface { | ||
| ListEnumerations() ([]*model.Enumeration, error) | ||
| GetEnumeration(id model.ID) (*model.Enumeration, error) | ||
| CreateEnumeration(enum *model.Enumeration) error | ||
| UpdateEnumeration(enum *model.Enumeration) error | ||
| MoveEnumeration(enum *model.Enumeration) error | ||
| DeleteEnumeration(id model.ID) error | ||
| } | ||
|
|
||
| // ConstantBackend provides constant operations. | ||
| type ConstantBackend interface { | ||
| ListConstants() ([]*model.Constant, error) | ||
| GetConstant(id model.ID) (*model.Constant, error) | ||
| CreateConstant(constant *model.Constant) error | ||
| UpdateConstant(constant *model.Constant) error | ||
| MoveConstant(constant *model.Constant) error | ||
| DeleteConstant(id model.ID) error | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package backend | ||
|
|
||
| import ( | ||
| "github.com/mendixlabs/mxcli/model" | ||
| "github.com/mendixlabs/mxcli/sdk/agenteditor" | ||
| "github.com/mendixlabs/mxcli/sdk/mpr" | ||
| ) | ||
|
|
||
| // RenameBackend provides cross-cutting rename and reference-update operations. | ||
| type RenameBackend interface { | ||
| UpdateQualifiedNameInAllUnits(oldName, newName string) (int, error) | ||
| RenameReferences(oldName, newName string, dryRun bool) ([]mpr.RenameHit, error) | ||
| RenameDocumentByName(moduleName, oldName, newName string) error | ||
| } | ||
|
|
||
| // RawUnitBackend provides low-level unit access for operations that | ||
| // manipulate raw BSON (e.g. widget patching, alter page/workflow). | ||
| type RawUnitBackend interface { | ||
| GetRawUnit(id model.ID) (map[string]any, error) | ||
| GetRawUnitBytes(id model.ID) ([]byte, error) | ||
| ListRawUnitsByType(typePrefix string) ([]*mpr.RawUnit, error) | ||
| ListRawUnits(objectType string) ([]*mpr.RawUnitInfo, error) | ||
| GetRawUnitByName(objectType, qualifiedName string) (*mpr.RawUnitInfo, error) | ||
| GetRawMicroflowByName(qualifiedName string) ([]byte, error) | ||
| UpdateRawUnit(unitID string, contents []byte) error | ||
| } | ||
|
|
||
| // MetadataBackend provides project-level metadata and introspection. | ||
| type MetadataBackend interface { | ||
| ListAllUnitIDs() ([]string, error) | ||
| ListUnits() ([]*mpr.UnitInfo, error) | ||
| GetUnitTypes() (map[string]int, error) | ||
| GetProjectRootID() (string, error) | ||
| ContentsDir() string | ||
| ExportJSON() ([]byte, error) | ||
| InvalidateCache() | ||
| } | ||
|
|
||
| // WidgetBackend provides widget introspection operations. | ||
| type WidgetBackend interface { | ||
| FindCustomWidgetType(widgetID string) (*mpr.RawCustomWidgetType, error) | ||
| FindAllCustomWidgetTypes(widgetID string) ([]*mpr.RawCustomWidgetType, error) | ||
| } | ||
|
|
||
| // AgentEditorBackend provides agent editor document operations. | ||
| type AgentEditorBackend interface { | ||
| ListAgentEditorModels() ([]*agenteditor.Model, error) | ||
| ListAgentEditorKnowledgeBases() ([]*agenteditor.KnowledgeBase, error) | ||
| ListAgentEditorConsumedMCPServices() ([]*agenteditor.ConsumedMCPService, error) | ||
| ListAgentEditorAgents() ([]*agenteditor.Agent, error) | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package backend | ||
|
|
||
| import ( | ||
| "github.com/mendixlabs/mxcli/model" | ||
| "github.com/mendixlabs/mxcli/sdk/javaactions" | ||
| "github.com/mendixlabs/mxcli/sdk/mpr" | ||
| ) | ||
|
|
||
| // JavaBackend provides Java and JavaScript action operations. | ||
| type JavaBackend interface { | ||
| ListJavaActions() ([]*mpr.JavaAction, error) | ||
| ListJavaScriptActions() ([]*mpr.JavaScriptAction, error) | ||
| ReadJavaActionByName(qualifiedName string) (*javaactions.JavaAction, error) | ||
| ReadJavaScriptActionByName(qualifiedName string) (*mpr.JavaScriptAction, error) | ||
| CreateJavaAction(ja *javaactions.JavaAction) error | ||
| UpdateJavaAction(ja *javaactions.JavaAction) error | ||
| DeleteJavaAction(id model.ID) error | ||
| WriteJavaSourceFile(moduleName, actionName string, javaCode string, params []*javaactions.JavaActionParameter, returnType javaactions.CodeActionReturnType) error | ||
| ReadJavaSourceFile(moduleName, actionName string) (string, error) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.