Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/mxcli/project_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sort"

"github.com/mendixlabs/mxcli/mdl/executor"
"github.com/mendixlabs/mxcli/mdl/types"
"github.com/mendixlabs/mxcli/model"
"github.com/mendixlabs/mxcli/sdk/mpr"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -951,7 +952,7 @@ func buildDatabaseConnectionChildren(dbc *model.DatabaseConnection) []*TreeNode
}

// buildMenuTreeNodes recursively builds tree nodes from navigation menu items.
func buildMenuTreeNodes(parent *TreeNode, items []*mpr.NavMenuItem) {
func buildMenuTreeNodes(parent *TreeNode, items []*types.NavMenuItem) {
for _, item := range items {
label := item.Caption
if label == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/marketplace/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var BaseURL = "https://marketplace-api.mendix.com"
type Content struct {
ContentID int `json:"contentId"`
Publisher string `json:"publisher"`
Type string `json:"type"` // "Module", "Widget", "Theme", "Starter App", ...
Type string `json:"type"` // "Module", "Widget", "Theme", "Starter App", ...
Categories []Category `json:"categories"`
SupportCategory string `json:"supportCategory"` // "Platform", "Community", "Deprecated", ...
LicenseURL string `json:"licenseUrl,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions mdl/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ type FullBackend interface {
MetadataBackend
WidgetBackend
AgentEditorBackend
PageMutationBackend
WorkflowMutationBackend
WidgetSerializationBackend
}
9 changes: 4 additions & 5 deletions mdl/backend/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
package backend

import (
"github.com/mendixlabs/mxcli/mdl/types"
"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.
Expand All @@ -22,9 +21,9 @@ type ConnectionBackend interface {
// Path returns the path of the connected project, or "" if not connected.
Path() string
// Version returns the MPR format version.
Version() mpr.MPRVersion
Version() types.MPRVersion
// ProjectVersion returns the Mendix project version.
ProjectVersion() *version.ProjectVersion
ProjectVersion() *types.ProjectVersion
// GetMendixVersion returns the Mendix version string.
GetMendixVersion() (string, error)
}
Expand All @@ -42,7 +41,7 @@ type ModuleBackend interface {

// FolderBackend provides folder operations.
type FolderBackend interface {
ListFolders() ([]*mpr.FolderInfo, error)
ListFolders() ([]*types.FolderInfo, error)
CreateFolder(folder *model.Folder) error
DeleteFolder(id model.ID) error
MoveFolder(id model.ID, newContainerID model.ID) error
Expand Down
7 changes: 3 additions & 4 deletions mdl/backend/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
// 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.
// Shared value types live in mdl/types to keep this package free of
// sdk/mpr dependencies. Conversion between types.* and sdk/mpr.*
// structs is handled inside mdl/backend/mpr (MprBackend).
package backend
16 changes: 8 additions & 8 deletions mdl/backend/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
package backend

import (
"github.com/mendixlabs/mxcli/mdl/types"
"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)
RenameReferences(oldName, newName string, dryRun bool) ([]types.RenameHit, error)
RenameDocumentByName(moduleName, oldName, newName string) error
}

Expand All @@ -20,17 +20,17 @@ type RenameBackend interface {
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)
ListRawUnitsByType(typePrefix string) ([]*types.RawUnit, error)
ListRawUnits(objectType string) ([]*types.RawUnitInfo, error)
GetRawUnitByName(objectType, qualifiedName string) (*types.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)
ListUnits() ([]*types.UnitInfo, error)
GetUnitTypes() (map[string]int, error)
GetProjectRootID() (string, error)
ContentsDir() string
Expand All @@ -40,8 +40,8 @@ type MetadataBackend interface {

// WidgetBackend provides widget introspection operations.
type WidgetBackend interface {
FindCustomWidgetType(widgetID string) (*mpr.RawCustomWidgetType, error)
FindAllCustomWidgetTypes(widgetID string) ([]*mpr.RawCustomWidgetType, error)
FindCustomWidgetType(widgetID string) (*types.RawCustomWidgetType, error)
FindAllCustomWidgetTypes(widgetID string) ([]*types.RawCustomWidgetType, error)
}

// AgentEditorBackend provides agent editor document operations.
Expand Down
8 changes: 4 additions & 4 deletions mdl/backend/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
package backend

import (
"github.com/mendixlabs/mxcli/mdl/types"
"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)
ListJavaActions() ([]*types.JavaAction, error)
ListJavaActionsFull() ([]*javaactions.JavaAction, error)
ListJavaScriptActions() ([]*mpr.JavaScriptAction, error)
ListJavaScriptActions() ([]*types.JavaScriptAction, error)
ReadJavaActionByName(qualifiedName string) (*javaactions.JavaAction, error)
ReadJavaScriptActionByName(qualifiedName string) (*mpr.JavaScriptAction, error)
ReadJavaScriptActionByName(qualifiedName string) (*types.JavaScriptAction, error)
CreateJavaAction(ja *javaactions.JavaAction) error
UpdateJavaAction(ja *javaactions.JavaAction) error
DeleteJavaAction(id model.ID) error
Expand Down
8 changes: 4 additions & 4 deletions mdl/backend/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
package backend

import (
"github.com/mendixlabs/mxcli/mdl/types"
"github.com/mendixlabs/mxcli/model"
"github.com/mendixlabs/mxcli/sdk/mpr"
)

// MappingBackend provides import/export mapping and JSON structure operations.
Expand All @@ -23,8 +23,8 @@ type MappingBackend interface {
DeleteExportMapping(id model.ID) error
MoveExportMapping(em *model.ExportMapping) error

ListJsonStructures() ([]*mpr.JsonStructure, error)
GetJsonStructureByQualifiedName(moduleName, name string) (*mpr.JsonStructure, error)
CreateJsonStructure(js *mpr.JsonStructure) error
ListJsonStructures() ([]*types.JsonStructure, error)
GetJsonStructureByQualifiedName(moduleName, name string) (*types.JsonStructure, error)
CreateJsonStructure(js *types.JsonStructure) error
DeleteJsonStructure(id string) error
}
75 changes: 47 additions & 28 deletions mdl/backend/mock/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
"github.com/mendixlabs/mxcli/sdk/domainmodel"
"github.com/mendixlabs/mxcli/sdk/javaactions"
"github.com/mendixlabs/mxcli/sdk/microflows"
"github.com/mendixlabs/mxcli/sdk/mpr"
"github.com/mendixlabs/mxcli/sdk/mpr/version"
"github.com/mendixlabs/mxcli/mdl/types"
"github.com/mendixlabs/mxcli/sdk/pages"
"github.com/mendixlabs/mxcli/sdk/security"
"github.com/mendixlabs/mxcli/sdk/workflows"
Expand All @@ -31,8 +30,8 @@ type MockBackend struct {
CommitFunc func() error
IsConnectedFunc func() bool
PathFunc func() string
VersionFunc func() mpr.MPRVersion
ProjectVersionFunc func() *version.ProjectVersion
VersionFunc func() types.MPRVersion
ProjectVersionFunc func() *types.ProjectVersion
GetMendixVersionFunc func() (string, error)

// ModuleBackend
Expand All @@ -45,7 +44,7 @@ type MockBackend struct {
DeleteModuleWithCleanupFunc func(id model.ID, moduleName string) error

// FolderBackend
ListFoldersFunc func() ([]*mpr.FolderInfo, error)
ListFoldersFunc func() ([]*types.FolderInfo, error)
CreateFolderFunc func(folder *model.Folder) error
DeleteFolderFunc func(id model.ID) error
MoveFolderFunc func(id model.ID, newContainerID model.ID) error
Expand Down Expand Up @@ -144,14 +143,14 @@ type MockBackend struct {
RemoveFromAllowedRolesFunc func(unitID model.ID, roleName string) (bool, error)
AddEntityAccessRuleFunc func(params backend.EntityAccessRuleParams) error
RemoveEntityAccessRuleFunc func(unitID model.ID, entityName string, roleNames []string) (int, error)
RevokeEntityMemberAccessFunc func(unitID model.ID, entityName string, roleNames []string, revocation mpr.EntityAccessRevocation) (int, error)
RevokeEntityMemberAccessFunc func(unitID model.ID, entityName string, roleNames []string, revocation types.EntityAccessRevocation) (int, error)
RemoveRoleFromAllEntitiesFunc func(unitID model.ID, roleName string) (int, error)
ReconcileMemberAccessesFunc func(unitID model.ID, moduleName string) (int, error)

// NavigationBackend
ListNavigationDocumentsFunc func() ([]*mpr.NavigationDocument, error)
GetNavigationFunc func() (*mpr.NavigationDocument, error)
UpdateNavigationProfileFunc func(navDocID model.ID, profileName string, spec mpr.NavigationProfileSpec) error
ListNavigationDocumentsFunc func() ([]*types.NavigationDocument, error)
GetNavigationFunc func() (*types.NavigationDocument, error)
UpdateNavigationProfileFunc func(navDocID model.ID, profileName string, spec types.NavigationProfileSpec) error

// ServiceBackend
ListConsumedODataServicesFunc func() ([]*model.ConsumedODataService, error)
Expand Down Expand Up @@ -196,17 +195,17 @@ type MockBackend struct {
UpdateExportMappingFunc func(em *model.ExportMapping) error
DeleteExportMappingFunc func(id model.ID) error
MoveExportMappingFunc func(em *model.ExportMapping) error
ListJsonStructuresFunc func() ([]*mpr.JsonStructure, error)
GetJsonStructureByQualifiedNameFunc func(moduleName, name string) (*mpr.JsonStructure, error)
CreateJsonStructureFunc func(js *mpr.JsonStructure) error
ListJsonStructuresFunc func() ([]*types.JsonStructure, error)
GetJsonStructureByQualifiedNameFunc func(moduleName, name string) (*types.JsonStructure, error)
CreateJsonStructureFunc func(js *types.JsonStructure) error
DeleteJsonStructureFunc func(id string) error

// JavaBackend
ListJavaActionsFunc func() ([]*mpr.JavaAction, error)
ListJavaActionsFunc func() ([]*types.JavaAction, error)
ListJavaActionsFullFunc func() ([]*javaactions.JavaAction, error)
ListJavaScriptActionsFunc func() ([]*mpr.JavaScriptAction, error)
ListJavaScriptActionsFunc func() ([]*types.JavaScriptAction, error)
ReadJavaActionByNameFunc func(qualifiedName string) (*javaactions.JavaAction, error)
ReadJavaScriptActionByNameFunc func(qualifiedName string) (*mpr.JavaScriptAction, error)
ReadJavaScriptActionByNameFunc func(qualifiedName string) (*types.JavaScriptAction, error)
CreateJavaActionFunc func(ja *javaactions.JavaAction) error
UpdateJavaActionFunc func(ja *javaactions.JavaAction) error
DeleteJavaActionFunc func(id model.ID) error
Expand All @@ -224,8 +223,8 @@ type MockBackend struct {
UpdateProjectSettingsFunc func(ps *model.ProjectSettings) error

// ImageBackend
ListImageCollectionsFunc func() ([]*mpr.ImageCollection, error)
CreateImageCollectionFunc func(ic *mpr.ImageCollection) error
ListImageCollectionsFunc func() ([]*types.ImageCollection, error)
CreateImageCollectionFunc func(ic *types.ImageCollection) error
DeleteImageCollectionFunc func(id string) error

// ScheduledEventBackend
Expand All @@ -234,34 +233,54 @@ type MockBackend struct {

// RenameBackend
UpdateQualifiedNameInAllUnitsFunc func(oldName, newName string) (int, error)
RenameReferencesFunc func(oldName, newName string, dryRun bool) ([]mpr.RenameHit, error)
RenameReferencesFunc func(oldName, newName string, dryRun bool) ([]types.RenameHit, error)
RenameDocumentByNameFunc func(moduleName, oldName, newName string) error

// RawUnitBackend
GetRawUnitFunc func(id model.ID) (map[string]any, error)
GetRawUnitBytesFunc func(id model.ID) ([]byte, error)
ListRawUnitsByTypeFunc func(typePrefix string) ([]*mpr.RawUnit, error)
ListRawUnitsFunc func(objectType string) ([]*mpr.RawUnitInfo, error)
GetRawUnitByNameFunc func(objectType, qualifiedName string) (*mpr.RawUnitInfo, error)
ListRawUnitsByTypeFunc func(typePrefix string) ([]*types.RawUnit, error)
ListRawUnitsFunc func(objectType string) ([]*types.RawUnitInfo, error)
GetRawUnitByNameFunc func(objectType, qualifiedName string) (*types.RawUnitInfo, error)
GetRawMicroflowByNameFunc func(qualifiedName string) ([]byte, error)
UpdateRawUnitFunc func(unitID string, contents []byte) error

// MetadataBackend
ListAllUnitIDsFunc func() ([]string, error)
ListUnitsFunc func() ([]*mpr.UnitInfo, error)
ListUnitsFunc func() ([]*types.UnitInfo, error)
GetUnitTypesFunc func() (map[string]int, error)
GetProjectRootIDFunc func() (string, error)
ContentsDirFunc func() string
ExportJSONFunc func() ([]byte, error)
InvalidateCacheFunc func()

// WidgetBackend
FindCustomWidgetTypeFunc func(widgetID string) (*mpr.RawCustomWidgetType, error)
FindAllCustomWidgetTypesFunc func(widgetID string) ([]*mpr.RawCustomWidgetType, error)
FindCustomWidgetTypeFunc func(widgetID string) (*types.RawCustomWidgetType, error)
FindAllCustomWidgetTypesFunc func(widgetID string) ([]*types.RawCustomWidgetType, error)

// PageMutationBackend
OpenPageForMutationFunc func(unitID model.ID) (backend.PageMutator, error)

// WorkflowMutationBackend
OpenWorkflowForMutationFunc func(unitID model.ID) (backend.WorkflowMutator, error)

// WidgetSerializationBackend
SerializeWidgetFunc func(w pages.Widget) (any, error)
SerializeClientActionFunc func(a pages.ClientAction) (any, error)
SerializeDataSourceFunc func(ds pages.DataSource) (any, error)
SerializeWorkflowActivityFunc func(a workflows.WorkflowActivity) (any, error)

// AgentEditorBackend
ListAgentEditorModelsFunc func() ([]*agenteditor.Model, error)
ListAgentEditorKnowledgeBasesFunc func() ([]*agenteditor.KnowledgeBase, error)
ListAgentEditorConsumedMCPServicesFunc func() ([]*agenteditor.ConsumedMCPService, error)
ListAgentEditorAgentsFunc func() ([]*agenteditor.Agent, error)
ListAgentEditorModelsFunc func() ([]*agenteditor.Model, error)
ListAgentEditorKnowledgeBasesFunc func() ([]*agenteditor.KnowledgeBase, error)
ListAgentEditorConsumedMCPServicesFunc func() ([]*agenteditor.ConsumedMCPService, error)
ListAgentEditorAgentsFunc func() ([]*agenteditor.Agent, error)
CreateAgentEditorModelFunc func(m *agenteditor.Model) error
DeleteAgentEditorModelFunc func(id string) error
CreateAgentEditorKnowledgeBaseFunc func(kb *agenteditor.KnowledgeBase) error
DeleteAgentEditorKnowledgeBaseFunc func(id string) error
CreateAgentEditorConsumedMCPServiceFunc func(svc *agenteditor.ConsumedMCPService) error
DeleteAgentEditorConsumedMCPServiceFunc func(id string) error
CreateAgentEditorAgentFunc func(a *agenteditor.Agent) error
DeleteAgentEditorAgentFunc func(id string) error
}
9 changes: 4 additions & 5 deletions mdl/backend/mock/mock_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
package mock

import (
"github.com/mendixlabs/mxcli/sdk/mpr"
"github.com/mendixlabs/mxcli/sdk/mpr/version"
"github.com/mendixlabs/mxcli/mdl/types"
)

func (m *MockBackend) Connect(path string) error {
Expand Down Expand Up @@ -42,15 +41,15 @@ func (m *MockBackend) Path() string {
return ""
}

func (m *MockBackend) Version() mpr.MPRVersion {
func (m *MockBackend) Version() types.MPRVersion {
if m.VersionFunc != nil {
return m.VersionFunc()
}
var zero mpr.MPRVersion
var zero types.MPRVersion
return zero
}

func (m *MockBackend) ProjectVersion() *version.ProjectVersion {
func (m *MockBackend) ProjectVersion() *types.ProjectVersion {
if m.ProjectVersionFunc != nil {
return m.ProjectVersionFunc()
}
Expand Down
Loading