Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions cmd/mxcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"os"
"strings"

"github.com/mendixlabs/mxcli/mdl/backend"
mprbackend "github.com/mendixlabs/mxcli/mdl/backend/mpr"
"github.com/mendixlabs/mxcli/mdl/diaglog"
"github.com/mendixlabs/mxcli/mdl/executor"
"github.com/mendixlabs/mxcli/mdl/repl"
Expand Down Expand Up @@ -194,6 +196,7 @@ func resolveFormat(cmd *cobra.Command, defaultFormat string) string {
func newLoggedExecutor(mode string) (*executor.Executor, *diaglog.Logger) {
logger := diaglog.Init(version, mode)
exec := executor.New(os.Stdout)
exec.SetBackendFactory(func() backend.FullBackend { return mprbackend.New() })
exec.SetLogger(logger)
if globalJSONFlag {
exec.SetFormat(executor.FormatJSON)
Expand Down
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
3 changes: 3 additions & 0 deletions examples/create_datagrid2_page/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"os"
"strings"

"github.com/mendixlabs/mxcli/mdl/backend"
mprbackend "github.com/mendixlabs/mxcli/mdl/backend/mpr"
"github.com/mendixlabs/mxcli/mdl/executor"
"github.com/mendixlabs/mxcli/mdl/visitor"
)
Expand Down Expand Up @@ -51,6 +53,7 @@ func main() {

// Create the MDL executor with stdout for output
exec := executor.New(os.Stdout)
exec.SetBackendFactory(func() backend.FullBackend { return mprbackend.New() })

// Define the MDL script to create a page with DataGrid2
// Note: Adjust module name, entity name, and attributes to match your project
Expand Down
60 changes: 30 additions & 30 deletions mdl/ast/ast_agenteditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ package ast
// [, DeepLinkURL: '...']
// );
type CreateModelStmt struct {
Name QualifiedName
Documentation string
Provider string // "MxCloudGenAI" by default
Key *QualifiedName // qualified name of the String constant holding the Portal key
DisplayName string // optional Portal-populated metadata
KeyName string // optional Portal-populated metadata
KeyID string // optional Portal-populated metadata
Environment string // optional Portal-populated metadata
ResourceName string // optional Portal-populated metadata
DeepLinkURL string // optional Portal-populated metadata
Name QualifiedName
Documentation string
Provider string // "MxCloudGenAI" by default
Key *QualifiedName // qualified name of the String constant holding the Portal key
DisplayName string // optional Portal-populated metadata
KeyName string // optional Portal-populated metadata
KeyID string // optional Portal-populated metadata
Environment string // optional Portal-populated metadata
ResourceName string // optional Portal-populated metadata
DeepLinkURL string // optional Portal-populated metadata
}

func (s *CreateModelStmt) isStatement() {}
Expand Down Expand Up @@ -93,21 +93,21 @@ func (s *DropKnowledgeBaseStmt) isStatement() {}

// CreateAgentStmt represents CREATE AGENT Module.Name (...) [{ body }].
type CreateAgentStmt struct {
Name QualifiedName
Name QualifiedName
Documentation string
UsageType string // "Task" or "Conversational"
Description string
Model *QualifiedName // reference to a Model document
Entity *QualifiedName // reference to a domain entity
MaxTokens *int
ToolChoice string
Temperature *float64
TopP *float64
SystemPrompt string
UserPrompt string
Variables []AgentVarDef
Tools []AgentToolDef
KBTools []AgentKBToolDef
UsageType string // "Task" or "Conversational"
Description string
Model *QualifiedName // reference to a Model document
Entity *QualifiedName // reference to a domain entity
MaxTokens *int
ToolChoice string
Temperature *float64
TopP *float64
SystemPrompt string
UserPrompt string
Variables []AgentVarDef
Tools []AgentToolDef
KBTools []AgentKBToolDef
}

func (s *CreateAgentStmt) isStatement() {}
Expand Down Expand Up @@ -136,10 +136,10 @@ type AgentToolDef struct {

// AgentKBToolDef represents a KNOWLEDGE BASE block in CREATE AGENT body.
type AgentKBToolDef struct {
Name string // per-agent identifier
Source *QualifiedName
Collection string
MaxResults int
Description string
Enabled bool
Name string // per-agent identifier
Source *QualifiedName
Collection string
MaxResults int
Description string
Enabled bool
}
4 changes: 4 additions & 0 deletions mdl/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ type FullBackend interface {
MetadataBackend
WidgetBackend
AgentEditorBackend
PageMutationBackend
WorkflowMutationBackend
WidgetSerializationBackend
WidgetBuilderBackend
}
21 changes: 16 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,28 +21,40 @@ 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.
// NOTE: uses Get prefix unlike Version()/ProjectVersion() for historical SDK compatibility.
GetMendixVersion() (string, error)
}

// ModuleBackend provides module-level operations.
type ModuleBackend interface {
// ListModules returns all modules in the project.
ListModules() ([]*model.Module, error)
// GetModule returns a module by ID.
GetModule(id model.ID) (*model.Module, error)
// GetModuleByName returns a module by name.
GetModuleByName(name string) (*model.Module, error)
// CreateModule adds a new module to the project.
CreateModule(module *model.Module) error
// UpdateModule persists changes to an existing module.
UpdateModule(module *model.Module) error
// DeleteModule removes a module by ID.
DeleteModule(id model.ID) error
// DeleteModuleWithCleanup removes a module and cleans up associated documents.
DeleteModuleWithCleanup(id model.ID, moduleName string) error
}

// FolderBackend provides folder operations.
type FolderBackend interface {
ListFolders() ([]*mpr.FolderInfo, error)
// ListFolders returns all folders in the project.
ListFolders() ([]*types.FolderInfo, error)
// CreateFolder adds a new folder.
CreateFolder(folder *model.Folder) error
// DeleteFolder removes a folder by ID.
DeleteFolder(id model.ID) error
// MoveFolder moves a folder to a new container.
MoveFolder(id model.ID, newContainerID model.ID) error
}
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
40 changes: 31 additions & 9 deletions mdl/backend/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,36 @@
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
}

// RawUnitBackend provides low-level unit access for operations that
// manipulate raw BSON (e.g. widget patching, alter page/workflow).
// manipulate raw unit contents (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)
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 replaces the contents of a unit by ID.
// Takes string (not model.ID) to match the SDK writer layer convention.
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,11 +42,12 @@ 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.
// Delete methods take string IDs to match the SDK writer layer convention.
type AgentEditorBackend interface {
ListAgentEditorModels() ([]*agenteditor.Model, error)
ListAgentEditorKnowledgeBases() ([]*agenteditor.KnowledgeBase, error)
Expand All @@ -59,3 +62,22 @@ type AgentEditorBackend interface {
CreateAgentEditorAgent(a *agenteditor.Agent) error
DeleteAgentEditorAgent(id string) error
}

// SettingsBackend provides project settings operations.
type SettingsBackend interface {
GetProjectSettings() (*model.ProjectSettings, error)
UpdateProjectSettings(ps *model.ProjectSettings) error
}

// ImageBackend provides image collection operations.
type ImageBackend interface {
ListImageCollections() ([]*types.ImageCollection, error)
CreateImageCollection(ic *types.ImageCollection) error
DeleteImageCollection(id string) error
}

// ScheduledEventBackend provides scheduled event operations.
type ScheduledEventBackend interface {
ListScheduledEvents() ([]*model.ScheduledEvent, error)
GetScheduledEvent(id model.ID) (*model.ScheduledEvent, error)
}
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
10 changes: 6 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,10 @@ 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 removes a JSON structure by ID.
// Takes string (not model.ID) to match the SDK writer layer convention.
DeleteJsonStructure(id string) error
}
4 changes: 4 additions & 0 deletions mdl/backend/microflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ type MicroflowBackend interface {
DeleteMicroflow(id model.ID) error
MoveMicroflow(mf *microflows.Microflow) error

// ParseMicroflowFromRaw builds a Microflow from an already-unmarshalled
// map. Used by diff-local and other callers that have raw map data.
ParseMicroflowFromRaw(raw map[string]any, unitID, containerID model.ID) *microflows.Microflow

ListNanoflows() ([]*microflows.Nanoflow, error)
GetNanoflow(id model.ID) (*microflows.Nanoflow, error)
CreateNanoflow(nf *microflows.Nanoflow) error
Expand Down
Loading
Loading