Skip to content

Commit 321c7fd

Browse files
authored
Merge pull request #229 from retran/feature/context-isolation
Context & catalog isolation — ExecContext gains Backend, handlers decoupled from mpr
2 parents 35fdd35 + 7fe3fb5 commit 321c7fd

81 files changed

Lines changed: 1243 additions & 1140 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.

mdl/backend/java.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
// JavaBackend provides Java and JavaScript action operations.
1212
type JavaBackend interface {
1313
ListJavaActions() ([]*mpr.JavaAction, error)
14+
ListJavaActionsFull() ([]*javaactions.JavaAction, error)
1415
ListJavaScriptActions() ([]*mpr.JavaScriptAction, error)
1516
ReadJavaActionByName(qualifiedName string) (*javaactions.JavaAction, error)
1617
ReadJavaScriptActionByName(qualifiedName string) (*mpr.JavaScriptAction, error)

mdl/backend/mock/backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ type MockBackend struct {
203203

204204
// JavaBackend
205205
ListJavaActionsFunc func() ([]*mpr.JavaAction, error)
206+
ListJavaActionsFullFunc func() ([]*javaactions.JavaAction, error)
206207
ListJavaScriptActionsFunc func() ([]*mpr.JavaScriptAction, error)
207208
ReadJavaActionByNameFunc func(qualifiedName string) (*javaactions.JavaAction, error)
208209
ReadJavaScriptActionByNameFunc func(qualifiedName string) (*mpr.JavaScriptAction, error)

mdl/backend/mock/mock_java.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ func (m *MockBackend) ListJavaActions() ([]*mpr.JavaAction, error) {
1515
return nil, nil
1616
}
1717

18+
func (m *MockBackend) ListJavaActionsFull() ([]*javaactions.JavaAction, error) {
19+
if m.ListJavaActionsFullFunc != nil {
20+
return m.ListJavaActionsFullFunc()
21+
}
22+
return nil, nil
23+
}
24+
1825
func (m *MockBackend) ListJavaScriptActions() ([]*mpr.JavaScriptAction, error) {
1926
if m.ListJavaScriptActionsFunc != nil {
2027
return m.ListJavaScriptActionsFunc()

mdl/backend/mpr/backend.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ type MprBackend struct {
3434
path string
3535
}
3636

37+
// Wrap creates an MprBackend that wraps an existing Writer (and its Reader).
38+
// This is used during migration when the Executor already owns the Writer
39+
// and we want to expose it through the Backend interface without opening
40+
// a second connection.
41+
func Wrap(writer *mpr.Writer, path string) *MprBackend {
42+
return &MprBackend{
43+
reader: writer.Reader(),
44+
writer: writer,
45+
path: path,
46+
}
47+
}
48+
3749
// ---------------------------------------------------------------------------
3850
// ConnectionBackend
3951
// ---------------------------------------------------------------------------
@@ -526,6 +538,9 @@ func (b *MprBackend) DeleteJsonStructure(id string) error {
526538
func (b *MprBackend) ListJavaActions() ([]*mpr.JavaAction, error) {
527539
return b.reader.ListJavaActions()
528540
}
541+
func (b *MprBackend) ListJavaActionsFull() ([]*javaactions.JavaAction, error) {
542+
return b.reader.ListJavaActionsFull()
543+
}
529544
func (b *MprBackend) ListJavaScriptActions() ([]*mpr.JavaScriptAction, error) {
530545
return b.reader.ListJavaScriptActions()
531546
}

mdl/catalog/builder.go

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,72 @@ import (
1010

1111
"github.com/mendixlabs/mxcli/model"
1212
"github.com/mendixlabs/mxcli/sdk/domainmodel"
13+
"github.com/mendixlabs/mxcli/sdk/javaactions"
1314
"github.com/mendixlabs/mxcli/sdk/microflows"
1415
"github.com/mendixlabs/mxcli/sdk/mpr"
1516
"github.com/mendixlabs/mxcli/sdk/pages"
17+
"github.com/mendixlabs/mxcli/sdk/security"
1618
"github.com/mendixlabs/mxcli/sdk/workflows"
1719
)
1820

21+
// CatalogReader defines the read-only backend surface used by the catalog builder.
22+
// Both *mpr.Reader and backend.FullBackend satisfy this interface.
23+
type CatalogReader interface {
24+
// Infrastructure
25+
GetRawUnit(id model.ID) (map[string]any, error)
26+
ListRawUnitsByType(typePrefix string) ([]*mpr.RawUnit, error)
27+
ListUnits() ([]*mpr.UnitInfo, error)
28+
ListFolders() ([]*mpr.FolderInfo, error)
29+
30+
// Modules
31+
ListModules() ([]*model.Module, error)
32+
33+
// Settings & security
34+
GetProjectSettings() (*model.ProjectSettings, error)
35+
GetProjectSecurity() (*security.ProjectSecurity, error)
36+
GetNavigation() (*mpr.NavigationDocument, error)
37+
38+
// Domain models & enumerations
39+
ListDomainModels() ([]*domainmodel.DomainModel, error)
40+
ListEnumerations() ([]*model.Enumeration, error)
41+
ListConstants() ([]*model.Constant, error)
42+
43+
// Microflows & nanoflows
44+
ListMicroflows() ([]*microflows.Microflow, error)
45+
ListNanoflows() ([]*microflows.Nanoflow, error)
46+
47+
// Pages, layouts & snippets
48+
ListPages() ([]*pages.Page, error)
49+
ListLayouts() ([]*pages.Layout, error)
50+
ListSnippets() ([]*pages.Snippet, error)
51+
52+
// Workflows
53+
ListWorkflows() ([]*workflows.Workflow, error)
54+
55+
// Java actions
56+
ListJavaActionsFull() ([]*javaactions.JavaAction, error)
57+
58+
// Services
59+
ListConsumedODataServices() ([]*model.ConsumedODataService, error)
60+
ListPublishedODataServices() ([]*model.PublishedODataService, error)
61+
ListConsumedRestServices() ([]*model.ConsumedRestService, error)
62+
ListPublishedRestServices() ([]*model.PublishedRestService, error)
63+
ListBusinessEventServices() ([]*model.BusinessEventService, error)
64+
ListDatabaseConnections() ([]*model.DatabaseConnection, error)
65+
66+
// Mappings & JSON structures
67+
ListImportMappings() ([]*model.ImportMapping, error)
68+
ListExportMappings() ([]*model.ExportMapping, error)
69+
ListJsonStructures() ([]*mpr.JsonStructure, error)
70+
}
71+
1972
// DescribeFunc generates MDL source for a given object type and qualified name.
2073
type DescribeFunc func(objectType string, qualifiedName string) (string, error)
2174

2275
// Builder populates catalog tables from MPR data.
2376
type Builder struct {
2477
catalog *Catalog
25-
reader *mpr.Reader
78+
reader CatalogReader
2679
snapshot *Snapshot
2780
progress ProgressFunc
2881
hierarchy *hierarchy
@@ -148,7 +201,7 @@ func (h *hierarchy) buildFolderPath(containerID model.ID) string {
148201
}
149202

150203
// NewBuilder creates a new catalog builder.
151-
func NewBuilder(catalog *Catalog, reader *mpr.Reader) *Builder {
204+
func NewBuilder(catalog *Catalog, reader CatalogReader) *Builder {
152205
return &Builder{
153206
catalog: catalog,
154207
reader: reader,

0 commit comments

Comments
 (0)