Skip to content

Commit 3b86546

Browse files
authored
Merge pull request #224 from retran/feature/dispatch-registry
feat: dispatch registry, backend interfaces, and MockBackend
2 parents 9be2604 + 4cb0501 commit 3b86546

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3936
-325
lines changed

mdl/backend/backend.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
// FullBackend composes every domain backend into a single interface.
6+
// Implementations must satisfy all sub-interfaces.
7+
//
8+
// Handler functions receive the specific sub-interface they need via
9+
// ExecContext; FullBackend exists primarily as a construction-time
10+
// constraint on backend implementations.
11+
type FullBackend interface {
12+
ConnectionBackend
13+
ModuleBackend
14+
FolderBackend
15+
DomainModelBackend
16+
MicroflowBackend
17+
PageBackend
18+
EnumerationBackend
19+
ConstantBackend
20+
SecurityBackend
21+
NavigationBackend
22+
ServiceBackend
23+
MappingBackend
24+
JavaBackend
25+
WorkflowBackend
26+
SettingsBackend
27+
ImageBackend
28+
ScheduledEventBackend
29+
RenameBackend
30+
RawUnitBackend
31+
MetadataBackend
32+
WidgetBackend
33+
AgentEditorBackend
34+
}

mdl/backend/connection.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/model"
7+
"github.com/mendixlabs/mxcli/sdk/mpr"
8+
"github.com/mendixlabs/mxcli/sdk/mpr/version"
9+
)
10+
11+
// ConnectionBackend manages the lifecycle of a backend connection.
12+
type ConnectionBackend interface {
13+
// Connect opens a connection to the project at path.
14+
Connect(path string) error
15+
// Disconnect closes the connection, finalizing any pending work.
16+
Disconnect() error
17+
// Commit flushes any pending writes. Implementations that auto-commit
18+
// (e.g. MprBackend) may treat this as a no-op.
19+
Commit() error
20+
// IsConnected reports whether the backend has an active connection.
21+
IsConnected() bool
22+
// Path returns the path of the connected project, or "" if not connected.
23+
Path() string
24+
// Version returns the MPR format version.
25+
Version() mpr.MPRVersion
26+
// ProjectVersion returns the Mendix project version.
27+
ProjectVersion() *version.ProjectVersion
28+
// GetMendixVersion returns the Mendix version string.
29+
GetMendixVersion() (string, error)
30+
}
31+
32+
// ModuleBackend provides module-level operations.
33+
type ModuleBackend interface {
34+
ListModules() ([]*model.Module, error)
35+
GetModule(id model.ID) (*model.Module, error)
36+
GetModuleByName(name string) (*model.Module, error)
37+
CreateModule(module *model.Module) error
38+
UpdateModule(module *model.Module) error
39+
DeleteModule(id model.ID) error
40+
DeleteModuleWithCleanup(id model.ID, moduleName string) error
41+
}
42+
43+
// FolderBackend provides folder operations.
44+
type FolderBackend interface {
45+
ListFolders() ([]*mpr.FolderInfo, error)
46+
CreateFolder(folder *model.Folder) error
47+
DeleteFolder(id model.ID) error
48+
MoveFolder(id model.ID, newContainerID model.ID) error
49+
}

mdl/backend/doc.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
// Package backend defines domain-specific interfaces that decouple the
4+
// executor from concrete storage (e.g. .mpr files). Each interface
5+
// groups related read/write operations by domain concept.
6+
//
7+
// Several method signatures currently reference types from sdk/mpr
8+
// (e.g. NavigationDocument, FolderInfo, ImageCollection, JsonStructure,
9+
// JavaAction, EntityMemberAccess, RenameHit). These should eventually be
10+
// extracted into a shared types package to remove the mpr dependency.
11+
package backend

mdl/backend/domainmodel.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/model"
7+
"github.com/mendixlabs/mxcli/sdk/domainmodel"
8+
)
9+
10+
// DomainModelBackend provides domain model, entity, attribute, and
11+
// association operations.
12+
type DomainModelBackend interface {
13+
// Domain models
14+
ListDomainModels() ([]*domainmodel.DomainModel, error)
15+
GetDomainModel(moduleID model.ID) (*domainmodel.DomainModel, error)
16+
GetDomainModelByID(id model.ID) (*domainmodel.DomainModel, error)
17+
UpdateDomainModel(dm *domainmodel.DomainModel) error
18+
19+
// Entities
20+
CreateEntity(domainModelID model.ID, entity *domainmodel.Entity) error
21+
UpdateEntity(domainModelID model.ID, entity *domainmodel.Entity) error
22+
DeleteEntity(domainModelID model.ID, entityID model.ID) error
23+
MoveEntity(entity *domainmodel.Entity, sourceDMID, targetDMID model.ID, sourceModuleName, targetModuleName string) ([]string, error)
24+
25+
// Attributes
26+
AddAttribute(domainModelID model.ID, entityID model.ID, attr *domainmodel.Attribute) error
27+
UpdateAttribute(domainModelID model.ID, entityID model.ID, attr *domainmodel.Attribute) error
28+
DeleteAttribute(domainModelID model.ID, entityID model.ID, attrID model.ID) error
29+
30+
// Associations
31+
CreateAssociation(domainModelID model.ID, assoc *domainmodel.Association) error
32+
CreateCrossAssociation(domainModelID model.ID, ca *domainmodel.CrossModuleAssociation) error
33+
DeleteAssociation(domainModelID model.ID, assocID model.ID) error
34+
DeleteCrossAssociation(domainModelID model.ID, assocID model.ID) error
35+
36+
// View entities
37+
CreateViewEntitySourceDocument(moduleID model.ID, moduleName, docName, oqlQuery, documentation string) (model.ID, error)
38+
DeleteViewEntitySourceDocument(id model.ID) error
39+
DeleteViewEntitySourceDocumentByName(moduleName, docName string) error
40+
FindViewEntitySourceDocumentID(moduleName, docName string) (model.ID, error)
41+
FindAllViewEntitySourceDocumentIDs(moduleName, docName string) ([]model.ID, error)
42+
MoveViewEntitySourceDocument(sourceModuleName string, targetModuleID model.ID, docName string) error
43+
UpdateOqlQueriesForMovedEntity(oldQualifiedName, newQualifiedName string) (int, error)
44+
UpdateEnumerationRefsInAllDomainModels(oldQualifiedName, newQualifiedName string) error
45+
}

mdl/backend/enumeration.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/model"
7+
)
8+
9+
// EnumerationBackend provides enumeration operations.
10+
type EnumerationBackend interface {
11+
ListEnumerations() ([]*model.Enumeration, error)
12+
GetEnumeration(id model.ID) (*model.Enumeration, error)
13+
CreateEnumeration(enum *model.Enumeration) error
14+
UpdateEnumeration(enum *model.Enumeration) error
15+
MoveEnumeration(enum *model.Enumeration) error
16+
DeleteEnumeration(id model.ID) error
17+
}
18+
19+
// ConstantBackend provides constant operations.
20+
type ConstantBackend interface {
21+
ListConstants() ([]*model.Constant, error)
22+
GetConstant(id model.ID) (*model.Constant, error)
23+
CreateConstant(constant *model.Constant) error
24+
UpdateConstant(constant *model.Constant) error
25+
MoveConstant(constant *model.Constant) error
26+
DeleteConstant(id model.ID) error
27+
}

mdl/backend/infrastructure.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/model"
7+
"github.com/mendixlabs/mxcli/sdk/agenteditor"
8+
"github.com/mendixlabs/mxcli/sdk/mpr"
9+
)
10+
11+
// RenameBackend provides cross-cutting rename and reference-update operations.
12+
type RenameBackend interface {
13+
UpdateQualifiedNameInAllUnits(oldName, newName string) (int, error)
14+
RenameReferences(oldName, newName string, dryRun bool) ([]mpr.RenameHit, error)
15+
RenameDocumentByName(moduleName, oldName, newName string) error
16+
}
17+
18+
// RawUnitBackend provides low-level unit access for operations that
19+
// manipulate raw BSON (e.g. widget patching, alter page/workflow).
20+
type RawUnitBackend interface {
21+
GetRawUnit(id model.ID) (map[string]any, error)
22+
GetRawUnitBytes(id model.ID) ([]byte, error)
23+
ListRawUnitsByType(typePrefix string) ([]*mpr.RawUnit, error)
24+
ListRawUnits(objectType string) ([]*mpr.RawUnitInfo, error)
25+
GetRawUnitByName(objectType, qualifiedName string) (*mpr.RawUnitInfo, error)
26+
GetRawMicroflowByName(qualifiedName string) ([]byte, error)
27+
UpdateRawUnit(unitID string, contents []byte) error
28+
}
29+
30+
// MetadataBackend provides project-level metadata and introspection.
31+
type MetadataBackend interface {
32+
ListAllUnitIDs() ([]string, error)
33+
ListUnits() ([]*mpr.UnitInfo, error)
34+
GetUnitTypes() (map[string]int, error)
35+
GetProjectRootID() (string, error)
36+
ContentsDir() string
37+
ExportJSON() ([]byte, error)
38+
InvalidateCache()
39+
}
40+
41+
// WidgetBackend provides widget introspection operations.
42+
type WidgetBackend interface {
43+
FindCustomWidgetType(widgetID string) (*mpr.RawCustomWidgetType, error)
44+
FindAllCustomWidgetTypes(widgetID string) ([]*mpr.RawCustomWidgetType, error)
45+
}
46+
47+
// AgentEditorBackend provides agent editor document operations.
48+
type AgentEditorBackend interface {
49+
ListAgentEditorModels() ([]*agenteditor.Model, error)
50+
ListAgentEditorKnowledgeBases() ([]*agenteditor.KnowledgeBase, error)
51+
ListAgentEditorConsumedMCPServices() ([]*agenteditor.ConsumedMCPService, error)
52+
ListAgentEditorAgents() ([]*agenteditor.Agent, error)
53+
}

mdl/backend/java.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/model"
7+
"github.com/mendixlabs/mxcli/sdk/javaactions"
8+
"github.com/mendixlabs/mxcli/sdk/mpr"
9+
)
10+
11+
// JavaBackend provides Java and JavaScript action operations.
12+
type JavaBackend interface {
13+
ListJavaActions() ([]*mpr.JavaAction, error)
14+
ListJavaScriptActions() ([]*mpr.JavaScriptAction, error)
15+
ReadJavaActionByName(qualifiedName string) (*javaactions.JavaAction, error)
16+
ReadJavaScriptActionByName(qualifiedName string) (*mpr.JavaScriptAction, error)
17+
CreateJavaAction(ja *javaactions.JavaAction) error
18+
UpdateJavaAction(ja *javaactions.JavaAction) error
19+
DeleteJavaAction(id model.ID) error
20+
WriteJavaSourceFile(moduleName, actionName string, javaCode string, params []*javaactions.JavaActionParameter, returnType javaactions.CodeActionReturnType) error
21+
ReadJavaSourceFile(moduleName, actionName string) (string, error)
22+
}

mdl/backend/mapping.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/model"
7+
"github.com/mendixlabs/mxcli/sdk/mpr"
8+
)
9+
10+
// MappingBackend provides import/export mapping and JSON structure operations.
11+
type MappingBackend interface {
12+
ListImportMappings() ([]*model.ImportMapping, error)
13+
GetImportMappingByQualifiedName(moduleName, name string) (*model.ImportMapping, error)
14+
CreateImportMapping(im *model.ImportMapping) error
15+
UpdateImportMapping(im *model.ImportMapping) error
16+
DeleteImportMapping(id model.ID) error
17+
MoveImportMapping(im *model.ImportMapping) error
18+
19+
ListExportMappings() ([]*model.ExportMapping, error)
20+
GetExportMappingByQualifiedName(moduleName, name string) (*model.ExportMapping, error)
21+
CreateExportMapping(em *model.ExportMapping) error
22+
UpdateExportMapping(em *model.ExportMapping) error
23+
DeleteExportMapping(id model.ID) error
24+
MoveExportMapping(em *model.ExportMapping) error
25+
26+
ListJsonStructures() ([]*mpr.JsonStructure, error)
27+
GetJsonStructureByQualifiedName(moduleName, name string) (*mpr.JsonStructure, error)
28+
CreateJsonStructure(js *mpr.JsonStructure) error
29+
DeleteJsonStructure(id string) error
30+
}

mdl/backend/microflow.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package backend
4+
5+
import (
6+
"github.com/mendixlabs/mxcli/model"
7+
"github.com/mendixlabs/mxcli/sdk/microflows"
8+
)
9+
10+
// MicroflowBackend provides microflow and nanoflow operations.
11+
type MicroflowBackend interface {
12+
ListMicroflows() ([]*microflows.Microflow, error)
13+
GetMicroflow(id model.ID) (*microflows.Microflow, error)
14+
CreateMicroflow(mf *microflows.Microflow) error
15+
UpdateMicroflow(mf *microflows.Microflow) error
16+
DeleteMicroflow(id model.ID) error
17+
MoveMicroflow(mf *microflows.Microflow) error
18+
19+
ListNanoflows() ([]*microflows.Nanoflow, error)
20+
GetNanoflow(id model.ID) (*microflows.Nanoflow, error)
21+
CreateNanoflow(nf *microflows.Nanoflow) error
22+
UpdateNanoflow(nf *microflows.Nanoflow) error
23+
DeleteNanoflow(id model.ID) error
24+
MoveNanoflow(nf *microflows.Nanoflow) error
25+
}

0 commit comments

Comments
 (0)