Skip to content

Commit 3f6ceb9

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 729a310 + d5b0478 commit 3f6ceb9

96 files changed

Lines changed: 7955 additions & 6757 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ grammardoc
5858

5959
# Snap tool binary (used for BSON fixture generation)
6060
snap-bson
61+
.playwright-cli/

cmd/mxcli/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"os"
1010
"strings"
1111

12+
"github.com/mendixlabs/mxcli/mdl/backend"
13+
mprbackend "github.com/mendixlabs/mxcli/mdl/backend/mpr"
1214
"github.com/mendixlabs/mxcli/mdl/diaglog"
1315
"github.com/mendixlabs/mxcli/mdl/executor"
1416
"github.com/mendixlabs/mxcli/mdl/repl"
@@ -194,6 +196,7 @@ func resolveFormat(cmd *cobra.Command, defaultFormat string) string {
194196
func newLoggedExecutor(mode string) (*executor.Executor, *diaglog.Logger) {
195197
logger := diaglog.Init(version, mode)
196198
exec := executor.New(os.Stdout)
199+
exec.SetBackendFactory(func() backend.FullBackend { return mprbackend.New() })
197200
exec.SetLogger(logger)
198201
if globalJSONFlag {
199202
exec.SetFormat(executor.FormatJSON)

examples/create_datagrid2_page/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"os"
2323
"strings"
2424

25+
"github.com/mendixlabs/mxcli/mdl/backend"
26+
mprbackend "github.com/mendixlabs/mxcli/mdl/backend/mpr"
2527
"github.com/mendixlabs/mxcli/mdl/executor"
2628
"github.com/mendixlabs/mxcli/mdl/visitor"
2729
)
@@ -51,6 +53,7 @@ func main() {
5153

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

5558
// Define the MDL script to create a page with DataGrid2
5659
// Note: Adjust module name, entity name, and attributes to match your project

mdl/ast/ast_agenteditor.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ package ast
1616
// [, DeepLinkURL: '...']
1717
// );
1818
type CreateModelStmt struct {
19-
Name QualifiedName
20-
Documentation string
21-
Provider string // "MxCloudGenAI" by default
22-
Key *QualifiedName // qualified name of the String constant holding the Portal key
23-
DisplayName string // optional Portal-populated metadata
24-
KeyName string // optional Portal-populated metadata
25-
KeyID string // optional Portal-populated metadata
26-
Environment string // optional Portal-populated metadata
27-
ResourceName string // optional Portal-populated metadata
28-
DeepLinkURL string // optional Portal-populated metadata
19+
Name QualifiedName
20+
Documentation string
21+
Provider string // "MxCloudGenAI" by default
22+
Key *QualifiedName // qualified name of the String constant holding the Portal key
23+
DisplayName string // optional Portal-populated metadata
24+
KeyName string // optional Portal-populated metadata
25+
KeyID string // optional Portal-populated metadata
26+
Environment string // optional Portal-populated metadata
27+
ResourceName string // optional Portal-populated metadata
28+
DeepLinkURL string // optional Portal-populated metadata
2929
}
3030

3131
func (s *CreateModelStmt) isStatement() {}
@@ -93,21 +93,21 @@ func (s *DropKnowledgeBaseStmt) isStatement() {}
9393

9494
// CreateAgentStmt represents CREATE AGENT Module.Name (...) [{ body }].
9595
type CreateAgentStmt struct {
96-
Name QualifiedName
96+
Name QualifiedName
9797
Documentation string
98-
UsageType string // "Task" or "Conversational"
99-
Description string
100-
Model *QualifiedName // reference to a Model document
101-
Entity *QualifiedName // reference to a domain entity
102-
MaxTokens *int
103-
ToolChoice string
104-
Temperature *float64
105-
TopP *float64
106-
SystemPrompt string
107-
UserPrompt string
108-
Variables []AgentVarDef
109-
Tools []AgentToolDef
110-
KBTools []AgentKBToolDef
98+
UsageType string // "Task" or "Conversational"
99+
Description string
100+
Model *QualifiedName // reference to a Model document
101+
Entity *QualifiedName // reference to a domain entity
102+
MaxTokens *int
103+
ToolChoice string
104+
Temperature *float64
105+
TopP *float64
106+
SystemPrompt string
107+
UserPrompt string
108+
Variables []AgentVarDef
109+
Tools []AgentToolDef
110+
KBTools []AgentKBToolDef
111111
}
112112

113113
func (s *CreateAgentStmt) isStatement() {}
@@ -136,10 +136,10 @@ type AgentToolDef struct {
136136

137137
// AgentKBToolDef represents a KNOWLEDGE BASE block in CREATE AGENT body.
138138
type AgentKBToolDef struct {
139-
Name string // per-agent identifier
140-
Source *QualifiedName
141-
Collection string
142-
MaxResults int
143-
Description string
144-
Enabled bool
139+
Name string // per-agent identifier
140+
Source *QualifiedName
141+
Collection string
142+
MaxResults int
143+
Description string
144+
Enabled bool
145145
}

mdl/backend/backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ type FullBackend interface {
3434
PageMutationBackend
3535
WorkflowMutationBackend
3636
WidgetSerializationBackend
37+
WidgetBuilderBackend
3738
}

mdl/backend/connection.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,36 @@ type ConnectionBackend interface {
2525
// ProjectVersion returns the Mendix project version.
2626
ProjectVersion() *types.ProjectVersion
2727
// GetMendixVersion returns the Mendix version string.
28+
// NOTE: uses Get prefix unlike Version()/ProjectVersion() for historical SDK compatibility.
2829
GetMendixVersion() (string, error)
2930
}
3031

3132
// ModuleBackend provides module-level operations.
3233
type ModuleBackend interface {
34+
// ListModules returns all modules in the project.
3335
ListModules() ([]*model.Module, error)
36+
// GetModule returns a module by ID.
3437
GetModule(id model.ID) (*model.Module, error)
38+
// GetModuleByName returns a module by name.
3539
GetModuleByName(name string) (*model.Module, error)
40+
// CreateModule adds a new module to the project.
3641
CreateModule(module *model.Module) error
42+
// UpdateModule persists changes to an existing module.
3743
UpdateModule(module *model.Module) error
44+
// DeleteModule removes a module by ID.
3845
DeleteModule(id model.ID) error
46+
// DeleteModuleWithCleanup removes a module and cleans up associated documents.
3947
DeleteModuleWithCleanup(id model.ID, moduleName string) error
4048
}
4149

4250
// FolderBackend provides folder operations.
4351
type FolderBackend interface {
52+
// ListFolders returns all folders in the project.
4453
ListFolders() ([]*types.FolderInfo, error)
54+
// CreateFolder adds a new folder.
4555
CreateFolder(folder *model.Folder) error
56+
// DeleteFolder removes a folder by ID.
4657
DeleteFolder(id model.ID) error
58+
// MoveFolder moves a folder to a new container.
4759
MoveFolder(id model.ID, newContainerID model.ID) error
4860
}

mdl/backend/infrastructure.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ type RenameBackend interface {
1616
}
1717

1818
// RawUnitBackend provides low-level unit access for operations that
19-
// manipulate raw BSON (e.g. widget patching, alter page/workflow).
19+
// manipulate raw unit contents (e.g. widget patching, alter page/workflow).
2020
type RawUnitBackend interface {
2121
GetRawUnit(id model.ID) (map[string]any, error)
2222
GetRawUnitBytes(id model.ID) ([]byte, error)
2323
ListRawUnitsByType(typePrefix string) ([]*types.RawUnit, error)
2424
ListRawUnits(objectType string) ([]*types.RawUnitInfo, error)
2525
GetRawUnitByName(objectType, qualifiedName string) (*types.RawUnitInfo, error)
2626
GetRawMicroflowByName(qualifiedName string) ([]byte, error)
27+
// UpdateRawUnit replaces the contents of a unit by ID.
28+
// Takes string (not model.ID) to match the SDK writer layer convention.
2729
UpdateRawUnit(unitID string, contents []byte) error
2830
}
2931

@@ -45,6 +47,7 @@ type WidgetBackend interface {
4547
}
4648

4749
// AgentEditorBackend provides agent editor document operations.
50+
// Delete methods take string IDs to match the SDK writer layer convention.
4851
type AgentEditorBackend interface {
4952
ListAgentEditorModels() ([]*agenteditor.Model, error)
5053
ListAgentEditorKnowledgeBases() ([]*agenteditor.KnowledgeBase, error)
@@ -59,3 +62,22 @@ type AgentEditorBackend interface {
5962
CreateAgentEditorAgent(a *agenteditor.Agent) error
6063
DeleteAgentEditorAgent(id string) error
6164
}
65+
66+
// SettingsBackend provides project settings operations.
67+
type SettingsBackend interface {
68+
GetProjectSettings() (*model.ProjectSettings, error)
69+
UpdateProjectSettings(ps *model.ProjectSettings) error
70+
}
71+
72+
// ImageBackend provides image collection operations.
73+
type ImageBackend interface {
74+
ListImageCollections() ([]*types.ImageCollection, error)
75+
CreateImageCollection(ic *types.ImageCollection) error
76+
DeleteImageCollection(id string) error
77+
}
78+
79+
// ScheduledEventBackend provides scheduled event operations.
80+
type ScheduledEventBackend interface {
81+
ListScheduledEvents() ([]*model.ScheduledEvent, error)
82+
GetScheduledEvent(id model.ID) (*model.ScheduledEvent, error)
83+
}

mdl/backend/mapping.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ type MappingBackend interface {
2626
ListJsonStructures() ([]*types.JsonStructure, error)
2727
GetJsonStructureByQualifiedName(moduleName, name string) (*types.JsonStructure, error)
2828
CreateJsonStructure(js *types.JsonStructure) error
29+
// DeleteJsonStructure removes a JSON structure by ID.
30+
// Takes string (not model.ID) to match the SDK writer layer convention.
2931
DeleteJsonStructure(id string) error
3032
}

mdl/backend/microflow.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ type MicroflowBackend interface {
1616
DeleteMicroflow(id model.ID) error
1717
MoveMicroflow(mf *microflows.Microflow) error
1818

19+
// ParseMicroflowFromRaw builds a Microflow from an already-unmarshalled
20+
// map. Used by diff-local and other callers that have raw map data.
21+
ParseMicroflowFromRaw(raw map[string]any, unitID, containerID model.ID) *microflows.Microflow
22+
1923
ListNanoflows() ([]*microflows.Nanoflow, error)
2024
GetNanoflow(id model.ID) (*microflows.Nanoflow, error)
2125
CreateNanoflow(nf *microflows.Nanoflow) error

mdl/backend/mock/backend.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ package mock
77

88
import (
99
"github.com/mendixlabs/mxcli/mdl/backend"
10+
"github.com/mendixlabs/mxcli/mdl/types"
1011
"github.com/mendixlabs/mxcli/model"
1112
"github.com/mendixlabs/mxcli/sdk/agenteditor"
1213
"github.com/mendixlabs/mxcli/sdk/domainmodel"
1314
"github.com/mendixlabs/mxcli/sdk/javaactions"
1415
"github.com/mendixlabs/mxcli/sdk/microflows"
15-
"github.com/mendixlabs/mxcli/mdl/types"
1616
"github.com/mendixlabs/mxcli/sdk/pages"
1717
"github.com/mendixlabs/mxcli/sdk/security"
1818
"github.com/mendixlabs/mxcli/sdk/workflows"
@@ -75,18 +75,19 @@ type MockBackend struct {
7575
UpdateEnumerationRefsInAllDomainModelsFunc func(oldQualifiedName, newQualifiedName string) error
7676

7777
// MicroflowBackend
78-
ListMicroflowsFunc func() ([]*microflows.Microflow, error)
79-
GetMicroflowFunc func(id model.ID) (*microflows.Microflow, error)
80-
CreateMicroflowFunc func(mf *microflows.Microflow) error
81-
UpdateMicroflowFunc func(mf *microflows.Microflow) error
82-
DeleteMicroflowFunc func(id model.ID) error
83-
MoveMicroflowFunc func(mf *microflows.Microflow) error
84-
ListNanoflowsFunc func() ([]*microflows.Nanoflow, error)
85-
GetNanoflowFunc func(id model.ID) (*microflows.Nanoflow, error)
86-
CreateNanoflowFunc func(nf *microflows.Nanoflow) error
87-
UpdateNanoflowFunc func(nf *microflows.Nanoflow) error
88-
DeleteNanoflowFunc func(id model.ID) error
89-
MoveNanoflowFunc func(nf *microflows.Nanoflow) error
78+
ListMicroflowsFunc func() ([]*microflows.Microflow, error)
79+
GetMicroflowFunc func(id model.ID) (*microflows.Microflow, error)
80+
CreateMicroflowFunc func(mf *microflows.Microflow) error
81+
UpdateMicroflowFunc func(mf *microflows.Microflow) error
82+
DeleteMicroflowFunc func(id model.ID) error
83+
MoveMicroflowFunc func(mf *microflows.Microflow) error
84+
ParseMicroflowFromRawFunc func(raw map[string]any, unitID, containerID model.ID) *microflows.Microflow
85+
ListNanoflowsFunc func() ([]*microflows.Nanoflow, error)
86+
GetNanoflowFunc func(id model.ID) (*microflows.Nanoflow, error)
87+
CreateNanoflowFunc func(nf *microflows.Nanoflow) error
88+
UpdateNanoflowFunc func(nf *microflows.Nanoflow) error
89+
DeleteNanoflowFunc func(id model.ID) error
90+
MoveNanoflowFunc func(nf *microflows.Nanoflow) error
9091

9192
// PageBackend
9293
ListPagesFunc func() ([]*pages.Page, error)
@@ -270,6 +271,14 @@ type MockBackend struct {
270271
SerializeDataSourceFunc func(ds pages.DataSource) (any, error)
271272
SerializeWorkflowActivityFunc func(a workflows.WorkflowActivity) (any, error)
272273

274+
// WidgetBuilderBackend
275+
LoadWidgetTemplateFunc func(widgetID string, projectPath string) (backend.WidgetObjectBuilder, error)
276+
SerializeWidgetToOpaqueFunc func(w pages.Widget) any
277+
SerializeDataSourceToOpaqueFunc func(ds pages.DataSource) any
278+
BuildCreateAttributeObjectFunc func(attributePath string, objectTypeID, propertyTypeID, valueTypeID string) (any, error)
279+
BuildDataGrid2WidgetFunc func(id model.ID, name string, spec backend.DataGridSpec, projectPath string) (*pages.CustomWidget, error)
280+
BuildFilterWidgetFunc func(spec backend.FilterWidgetSpec, projectPath string) (pages.Widget, error)
281+
273282
// AgentEditorBackend
274283
ListAgentEditorModelsFunc func() ([]*agenteditor.Model, error)
275284
ListAgentEditorKnowledgeBasesFunc func() ([]*agenteditor.KnowledgeBase, error)

0 commit comments

Comments
 (0)