Skip to content
Merged
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
8 changes: 4 additions & 4 deletions cmd/mxcli/docker/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// CDN downloads are the primary source for mxbuild and runtime.
//
// Resolution priority (all platforms):
// 1. Explicit path (--mxbuild-path)
// 2. PATH lookup
// 3. OS-specific known locations (Studio Pro on Windows)
// 4. Cached CDN downloads (~/.mxcli/mxbuild/)
// 1. Explicit path (--mxbuild-path)
// 2. PATH lookup
// 3. OS-specific known locations (Studio Pro on Windows)
// 4. Cached CDN downloads (~/.mxcli/mxbuild/)
//
// Path discovery on Windows must NOT hardcode drive letters. Use environment
// variables (PROGRAMFILES, PROGRAMW6432, SystemDrive) to locate install dirs.
Expand Down
62 changes: 31 additions & 31 deletions mdl/ast/ast_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ func (k EntityKind) String() string {

// CreateEntityStmt represents: CREATE [OR MODIFY] PERSISTENT|NON-PERSISTENT ENTITY Module.Name [EXTENDS Parent] (attributes) ...
type CreateEntityStmt struct {
Name QualifiedName
Kind EntityKind
Generalization *QualifiedName // Parent entity for inheritance (e.g., System.Image)
Attributes []Attribute
Indexes []Index
EventHandlers []EventHandlerDef // ON BEFORE/AFTER CREATE/COMMIT/DELETE/ROLLBACK CALL ...
Position *Position
Documentation string
Comment string
Name QualifiedName
Kind EntityKind
Generalization *QualifiedName // Parent entity for inheritance (e.g., System.Image)
Attributes []Attribute
Indexes []Index
EventHandlers []EventHandlerDef // ON BEFORE/AFTER CREATE/COMMIT/DELETE/ROLLBACK CALL ...
Position *Position
Documentation string
Comment string
CreateOrModify bool // true for CREATE OR MODIFY
}

Expand All @@ -58,17 +58,17 @@ func (s *DropEntityStmt) isStatement() {}
type AlterEntityOp int

const (
AlterEntityAddAttribute AlterEntityOp = iota // ADD ATTRIBUTE / ADD COLUMN
AlterEntityRenameAttribute // RENAME ATTRIBUTE / RENAME COLUMN
AlterEntityModifyAttribute // MODIFY ATTRIBUTE / MODIFY COLUMN
AlterEntityDropAttribute // DROP ATTRIBUTE / DROP COLUMN
AlterEntitySetDocumentation // SET DOCUMENTATION
AlterEntitySetComment // SET COMMENT
AlterEntityAddIndex // ADD INDEX
AlterEntityDropIndex // DROP INDEX
AlterEntitySetPosition // SET POSITION (x, y)
AlterEntityAddEventHandler // ADD EVENT HANDLER ON BEFORE/AFTER CREATE/COMMIT/DELETE/ROLLBACK CALL Mod.MF
AlterEntityDropEventHandler // DROP EVENT HANDLER ON BEFORE/AFTER CREATE/COMMIT/DELETE/ROLLBACK
AlterEntityAddAttribute AlterEntityOp = iota // ADD ATTRIBUTE / ADD COLUMN
AlterEntityRenameAttribute // RENAME ATTRIBUTE / RENAME COLUMN
AlterEntityModifyAttribute // MODIFY ATTRIBUTE / MODIFY COLUMN
AlterEntityDropAttribute // DROP ATTRIBUTE / DROP COLUMN
AlterEntitySetDocumentation // SET DOCUMENTATION
AlterEntitySetComment // SET COMMENT
AlterEntityAddIndex // ADD INDEX
AlterEntityDropIndex // DROP INDEX
AlterEntitySetPosition // SET POSITION (x, y)
AlterEntityAddEventHandler // ADD EVENT HANDLER ON BEFORE/AFTER CREATE/COMMIT/DELETE/ROLLBACK CALL Mod.MF
AlterEntityDropEventHandler // DROP EVENT HANDLER ON BEFORE/AFTER CREATE/COMMIT/DELETE/ROLLBACK
)

// EventHandlerDef represents an event handler in CREATE/ALTER ENTITY syntax.
Expand All @@ -84,17 +84,17 @@ type EventHandlerDef struct {
type AlterEntityStmt struct {
Name QualifiedName
Operation AlterEntityOp
Attribute *Attribute // For ADD ATTRIBUTE
AttributeName string // For RENAME/MODIFY/DROP ATTRIBUTE
NewName string // For RENAME ATTRIBUTE
DataType DataType // For MODIFY ATTRIBUTE
Calculated bool // For MODIFY ATTRIBUTE with CALCULATED
CalculatedMicroflow *QualifiedName // For MODIFY ATTRIBUTE with CALCULATED microflow
Documentation string // For SET DOCUMENTATION
Comment string // For SET COMMENT
Index *Index // For ADD INDEX
IndexName string // For DROP INDEX
Position *Position // For SET POSITION
Attribute *Attribute // For ADD ATTRIBUTE
AttributeName string // For RENAME/MODIFY/DROP ATTRIBUTE
NewName string // For RENAME ATTRIBUTE
DataType DataType // For MODIFY ATTRIBUTE
Calculated bool // For MODIFY ATTRIBUTE with CALCULATED
CalculatedMicroflow *QualifiedName // For MODIFY ATTRIBUTE with CALCULATED microflow
Documentation string // For SET DOCUMENTATION
Comment string // For SET COMMENT
Index *Index // For ADD INDEX
IndexName string // For DROP INDEX
Position *Position // For SET POSITION
EventHandler *EventHandlerDef // For ADD/DROP EVENT HANDLER
}

Expand Down
10 changes: 5 additions & 5 deletions mdl/ast/ast_microflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,11 @@ func (s *ExportToMappingStmt) isMicroflowStatement() {}

// TransformJsonStmt represents: $Result = TRANSFORM $Input WITH Module.Transformer
type TransformJsonStmt struct {
OutputVariable string // Result string variable (without $)
InputVariable string // Source JSON string variable (without $)
Transformation QualifiedName // Data transformer qualified name
ErrorHandling *ErrorHandlingClause // Optional ON ERROR clause
Annotations *ActivityAnnotations // Optional @position, @caption, @color, @annotation
OutputVariable string // Result string variable (without $)
InputVariable string // Source JSON string variable (without $)
Transformation QualifiedName // Data transformer qualified name
ErrorHandling *ErrorHandlingClause // Optional ON ERROR clause
Annotations *ActivityAnnotations // Optional @position, @caption, @color, @annotation
}

func (s *TransformJsonStmt) isMicroflowStatement() {}
2 changes: 1 addition & 1 deletion mdl/ast/ast_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const (
ShowImageCollections // SHOW IMAGE COLLECTIONS [IN module]
ShowRestClients // SHOW REST CLIENTS [IN module]
ShowPublishedRestServices // SHOW PUBLISHED REST SERVICES [IN module]
ShowDataTransformers // LIST DATA TRANSFORMERS [IN module]
ShowDataTransformers // LIST DATA TRANSFORMERS [IN module]
ShowConstantValues // SHOW CONSTANT VALUES [IN module]
ShowContractEntities // SHOW CONTRACT ENTITIES FROM Module.Service
ShowContractActions // SHOW CONTRACT ACTIONS FROM Module.Service
Expand Down
18 changes: 9 additions & 9 deletions mdl/ast/ast_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ type RestOperationDef struct {
Documentation string
Method string // "GET", "POST", "PUT", "PATCH", "DELETE"
Path string
Parameters []RestParamDef // path parameters
QueryParameters []RestParamDef // query parameters
Headers []RestHeaderDef // HTTP headers
BodyType string // "JSON", "FILE", "TEMPLATE", "MAPPING", "" (none)
BodyVariable string // e.g. "$ItemData" or template string
BodyMapping *RestMappingDef // for MAPPING body
ResponseType string // "JSON", "STRING", "FILE", "STATUS", "NONE", "MAPPING"
ResponseVariable string // e.g. "$CreatedItem"
ResponseMapping *RestMappingDef // for MAPPING response
Parameters []RestParamDef // path parameters
QueryParameters []RestParamDef // query parameters
Headers []RestHeaderDef // HTTP headers
BodyType string // "JSON", "FILE", "TEMPLATE", "MAPPING", "" (none)
BodyVariable string // e.g. "$ItemData" or template string
BodyMapping *RestMappingDef // for MAPPING body
ResponseType string // "JSON", "STRING", "FILE", "STATUS", "NONE", "MAPPING"
ResponseVariable string // e.g. "$CreatedItem"
ResponseMapping *RestMappingDef // for MAPPING response
Timeout int
}

Expand Down
34 changes: 34 additions & 0 deletions mdl/backend/backend.go
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
}
49 changes: 49 additions & 0 deletions mdl/backend/connection.go
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
}
11 changes: 11 additions & 0 deletions mdl/backend/doc.go
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
45 changes: 45 additions & 0 deletions mdl/backend/domainmodel.go
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
}
27 changes: 27 additions & 0 deletions mdl/backend/enumeration.go
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
}
53 changes: 53 additions & 0 deletions mdl/backend/infrastructure.go
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
}
Comment thread
retran marked this conversation as resolved.

// 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)
}
22 changes: 22 additions & 0 deletions mdl/backend/java.go
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)
}
Loading
Loading