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
25 changes: 16 additions & 9 deletions mdl/executor/cmd_pages_create_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,23 @@ func (e *Executor) execCreatePageV3(s *ast.CreatePageStmtV3) error {
return fmt.Errorf("failed to build page: %w", err)
}

// Delete old pages only after successful build
for _, id := range pagesToDelete {
if err := e.writer.DeletePage(id); err != nil {
return fmt.Errorf("failed to delete existing page: %w", err)
// Replace or create the page in the MPR
if len(pagesToDelete) > 0 {
// Reuse first existing page's UUID to avoid git delete+add (which crashes Studio Pro RevStatusCache)
page.ID = pagesToDelete[0]
if err := e.writer.UpdatePage(page); err != nil {
return fmt.Errorf("failed to update page: %w", err)
}
// Delete any additional duplicates
for _, id := range pagesToDelete[1:] {
if err := e.writer.DeletePage(id); err != nil {
return fmt.Errorf("failed to delete duplicate page: %w", err)
}
}
} else {
if err := e.writer.CreatePage(page); err != nil {
return fmt.Errorf("failed to create page: %w", err)
}
}

// Create the page in the MPR
if err := e.writer.CreatePage(page); err != nil {
return fmt.Errorf("failed to create page: %w", err)
}

// Track the created page so it can be resolved by subsequent page references
Expand Down
Binary file not shown.
Binary file added sdk/mpr/testdata/microflows/ChangePassword.mxunit
Binary file not shown.
Binary file added sdk/mpr/testdata/pages/Account_Overview.mxunit
Binary file not shown.
Binary file added sdk/mpr/testdata/pages/WidgetDemo_Showcase.mxunit
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/mpr/writer_dbconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func serializeDBQuery(q *model.DatabaseQuery) bson.M {
"$Type": "DatabaseConnector$DatabaseQuery",
"Name": q.Name,
"Query": q.SQL,
"QueryType": int32(q.QueryType),
"QueryType": int64(q.QueryType),
}
if q.ID != "" {
qDoc["$ID"] = idToBsonBinary(string(q.ID))
Expand Down
16 changes: 8 additions & 8 deletions sdk/mpr/writer_microflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func serializeSequenceFlow(flow *microflows.SequenceFlow) bson.D {
{Key: "$ID", Value: idToBsonBinary(string(flow.ID))},
{Key: "$Type", Value: "Microflows$SequenceFlow"},
{Key: "CaseValues", Value: caseValues},
{Key: "DestinationConnectionIndex", Value: int32(flow.DestinationConnectionIndex)},
{Key: "DestinationConnectionIndex", Value: int64(flow.DestinationConnectionIndex)},
{Key: "DestinationPointer", Value: idToBsonBinary(string(flow.DestinationID))},
{Key: "IsErrorHandler", Value: flow.IsErrorHandler},
{Key: "Line", Value: bson.D{
Expand All @@ -187,7 +187,7 @@ func serializeSequenceFlow(flow *microflows.SequenceFlow) bson.D {
{Key: "DestinationControlVector", Value: "0;0"},
{Key: "OriginControlVector", Value: "0;0"},
}},
{Key: "OriginConnectionIndex", Value: int32(flow.OriginConnectionIndex)},
{Key: "OriginConnectionIndex", Value: int64(flow.OriginConnectionIndex)},
{Key: "OriginPointer", Value: idToBsonBinary(string(flow.OriginID))},
}
}
Expand All @@ -197,15 +197,15 @@ func serializeAnnotationFlow(af *microflows.AnnotationFlow) bson.D {
return bson.D{
{Key: "$ID", Value: idToBsonBinary(string(af.ID))},
{Key: "$Type", Value: "Microflows$AnnotationFlow"},
{Key: "DestinationConnectionIndex", Value: int32(0)},
{Key: "DestinationConnectionIndex", Value: int64(0)},
{Key: "DestinationPointer", Value: idToBsonBinary(string(af.DestinationID))},
{Key: "Line", Value: bson.D{
{Key: "$ID", Value: idToBsonBinary(generateUUID())},
{Key: "$Type", Value: "Microflows$BezierCurve"},
{Key: "DestinationControlVector", Value: "0;0"},
{Key: "OriginControlVector", Value: "0;0"},
}},
{Key: "OriginConnectionIndex", Value: int32(0)},
{Key: "OriginConnectionIndex", Value: int64(0)},
{Key: "OriginPointer", Value: idToBsonBinary(string(af.OriginID))},
}
}
Expand Down Expand Up @@ -527,17 +527,17 @@ func serializeMicroflowObject(obj microflows.MicroflowObject) bson.D {
func serializePoint(pt model.Point) bson.D {
return bson.D{
{Key: "$Type", Value: "Common$Point"},
{Key: "X", Value: int32(pt.X)},
{Key: "Y", Value: int32(pt.Y)},
{Key: "X", Value: int64(pt.X)},
{Key: "Y", Value: int64(pt.Y)},
}
}

// serializeSize serializes a Size to BSON (nested object format).
func serializeSize(sz model.Size) bson.D {
return bson.D{
{Key: "$Type", Value: "Common$Size"},
{Key: "Width", Value: int32(sz.Width)},
{Key: "Height", Value: int32(sz.Height)},
{Key: "Width", Value: int64(sz.Width)},
{Key: "Height", Value: int64(sz.Height)},
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/mpr/writer_microflow_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func serializeMicroflowAction(action microflows.MicroflowAction) bson.D {
{Key: "$ID", Value: idToBsonBinary(string(a.ID))},
{Key: "$Type", Value: "Microflows$CloseFormAction"},
{Key: "ErrorHandlingType", Value: "Rollback"},
{Key: "NumberOfPagesToClose", Value: int32(a.NumberOfPages)},
{Key: "NumberOfPagesToClose", Value: int64(a.NumberOfPages)},
}
return doc

Expand Down
2 changes: 1 addition & 1 deletion sdk/mpr/writer_modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (w *Writer) serializeModule(module *model.Module) ([]byte, error) {
"AppStoreVersionGuid": "",
"IsThemeModule": false,
"IsReusableComponent": module.IsReusableComponent,
"NewSortIndex": int32(0),
"NewSortIndex": int64(0),
}
return bson.Marshal(doc)
}
2 changes: 1 addition & 1 deletion sdk/mpr/writer_odata.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func serializePublishedEntitySet(es *model.PublishedEntitySet, entityTypeID stri
"$Type": "ODataPublish$EntitySet",
"ExposedName": es.ExposedName,
"UsePaging": es.UsePaging,
"PageSize": int32(es.PageSize),
"PageSize": int64(es.PageSize),
}

// EntityTypePointer is a BY_ID reference
Expand Down
12 changes: 6 additions & 6 deletions sdk/mpr/writer_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func (w *Writer) serializePage(page *pages.Page) ([]byte, error) {
{Key: "Style", Value: ""},
}},
{Key: "Autofocus", Value: "DesktopOnly"},
{Key: "CanvasHeight", Value: int32(600)},
{Key: "CanvasWidth", Value: int32(1200)},
{Key: "CanvasHeight", Value: int64(600)},
{Key: "CanvasWidth", Value: int64(1200)},
{Key: "Documentation", Value: page.Documentation},
{Key: "Excluded", Value: page.Excluded},
{Key: "ExportLevel", Value: "Hidden"},
Expand Down Expand Up @@ -209,9 +209,9 @@ func (w *Writer) serializePage(page *pages.Page) ([]byte, error) {
doc = append(doc, bson.E{Key: "Parameters", Value: params})

doc = append(doc, bson.E{Key: "PopupCloseAction", Value: ""})
doc = append(doc, bson.E{Key: "PopupHeight", Value: int32(600)})
doc = append(doc, bson.E{Key: "PopupHeight", Value: int64(600)})
doc = append(doc, bson.E{Key: "PopupResizable", Value: false})
doc = append(doc, bson.E{Key: "PopupWidth", Value: int32(600)})
doc = append(doc, bson.E{Key: "PopupWidth", Value: int64(600)})

// Add Title
// Mendix uses [3] for empty arrays, [2, item1, item2, ...] for non-empty arrays
Expand Down Expand Up @@ -267,8 +267,8 @@ func (w *Writer) serializeSnippet(snippet *pages.Snippet) ([]byte, error) {
doc := bson.D{
{Key: "$ID", Value: idToBsonBinary(string(snippet.ID))},
{Key: "$Type", Value: "Forms$Snippet"},
{Key: "CanvasHeight", Value: int32(600)},
{Key: "CanvasWidth", Value: int32(800)},
{Key: "CanvasHeight", Value: int64(600)},
{Key: "CanvasWidth", Value: int64(800)},
{Key: "Documentation", Value: snippet.Documentation},
{Key: "ExportLevel", Value: "Hidden"},
{Key: "Name", Value: snippet.Name},
Expand Down
2 changes: 1 addition & 1 deletion sdk/mpr/writer_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func serializeRestOperation(op *model.RestClientOperation) bson.M {
}

if op.Timeout > 0 {
doc["Timeout"] = int32(op.Timeout)
doc["Timeout"] = int64(op.Timeout)
}

// Method: polymorphic (WithBody or WithoutBody)
Expand Down
2 changes: 1 addition & 1 deletion sdk/mpr/writer_rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestSerializeRestOperationGetWithParams(t *testing.T) {
assertField(t, result, "Name", "GetPet")

// Timeout
if v, ok := result["Timeout"].(int32); !ok || v != 30 {
if v, ok := result["Timeout"].(int64); !ok || v != 30 {
t.Errorf("Timeout: expected 30, got %v", result["Timeout"])
}

Expand Down
27 changes: 10 additions & 17 deletions sdk/mpr/writer_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,15 @@ package mpr

import (
"fmt"
"math"

"github.com/mendixlabs/mxcli/model"

"go.mongodb.org/mongo-driver/bson"
)

// safeInt32 converts an int to int32 with clamping to prevent silent overflow.
func safeInt32(v int) int32 {
if v > math.MaxInt32 {
return math.MaxInt32
}
if v < math.MinInt32 {
return math.MinInt32
}
return int32(v)
// safeInt64 converts an int to int64.
func safeInt64(v int) int64 {
return int64(v)
}

// UpdateProjectSettings updates the project settings document.
Expand Down Expand Up @@ -89,12 +82,12 @@ func serializeModelSettings(ms *model.ModelSettings, raw map[string]any) map[str
raw["HealthCheckMicroflow"] = ms.HealthCheckMicroflow
raw["AllowUserMultipleSessions"] = ms.AllowUserMultipleSessions
raw["HashAlgorithm"] = ms.HashAlgorithm
raw["BcryptCost"] = safeInt32(ms.BcryptCost)
raw["BcryptCost"] = safeInt64(ms.BcryptCost)
raw["JavaVersion"] = ms.JavaVersion
raw["RoundingMode"] = ms.RoundingMode
raw["ScheduledEventTimeZoneCode"] = ms.ScheduledEventTimeZoneCode
raw["FirstDayOfWeek"] = ms.FirstDayOfWeek
raw["DecimalScale"] = safeInt32(ms.DecimalScale)
raw["DecimalScale"] = safeInt64(ms.DecimalScale)
raw["EnableDataStorageOptimisticLocking"] = ms.EnableDataStorageOptimisticLocking
raw["UseDatabaseForeignKeyConstraints"] = ms.UseDatabaseForeignKeyConstraints
return raw
Expand All @@ -120,10 +113,10 @@ func serializeServerConfiguration(cfg *model.ServerConfiguration) bson.M {
"DatabaseUserName": cfg.DatabaseUserName,
"DatabasePassword": cfg.DatabasePassword,
"DatabaseUseIntegratedSecurity": cfg.DatabaseUseIntegratedSecurity,
"HttpPortNumber": safeInt32(cfg.HttpPortNumber),
"ServerPortNumber": safeInt32(cfg.ServerPortNumber),
"HttpPortNumber": safeInt64(cfg.HttpPortNumber),
"ServerPortNumber": safeInt64(cfg.ServerPortNumber),
"ApplicationRootUrl": cfg.ApplicationRootUrl,
"MaxJavaHeapSize": safeInt32(cfg.MaxJavaHeapSize),
"MaxJavaHeapSize": safeInt64(cfg.MaxJavaHeapSize),
"ExtraJvmParameters": cfg.ExtraJvmParameters,
"OpenAdminPort": cfg.OpenAdminPort,
"OpenHttpPort": cfg.OpenHttpPort,
Expand Down Expand Up @@ -167,7 +160,7 @@ func serializeLanguageSettings(ls *model.LanguageSettings, raw map[string]any) m
// serializeWorkflowsSettings updates the raw BSON map with modified workflow settings.
func serializeWorkflowsSettings(ws *model.WorkflowsSettings, raw map[string]any) map[string]any {
raw["UserEntity"] = ws.UserEntity
raw["DefaultTaskParallelism"] = safeInt32(ws.DefaultTaskParallelism)
raw["WorkflowEngineParallelism"] = safeInt32(ws.WorkflowEngineParallelism)
raw["DefaultTaskParallelism"] = safeInt64(ws.DefaultTaskParallelism)
raw["WorkflowEngineParallelism"] = safeInt64(ws.WorkflowEngineParallelism)
return raw
}
4 changes: 2 additions & 2 deletions sdk/mpr/writer_widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func serializeFormattingInfo() bson.D {
{Key: "$Type", Value: "Forms$FormattingInfo"},
{Key: "CustomDateFormat", Value: ""},
{Key: "DateFormat", Value: "Date"},
{Key: "DecimalPrecision", Value: int32(2)},
{Key: "DecimalPrecision", Value: int64(2)},
{Key: "EnumFormat", Value: "Text"},
{Key: "GroupDigits", Value: false},
}
Expand Down Expand Up @@ -557,7 +557,7 @@ func serializeClientTemplateParameter(param *pages.ClientTemplateParameter) bson
{Key: "$Type", Value: "Forms$FormattingInfo"},
{Key: "CustomDateFormat", Value: ""},
{Key: "DateFormat", Value: "Date"},
{Key: "DecimalPrecision", Value: int32(2)},
{Key: "DecimalPrecision", Value: int64(2)},
{Key: "EnumFormat", Value: "Text"},
{Key: "GroupDigits", Value: false},
{Key: "TimeFormat", Value: "HoursMinutes"},
Expand Down
4 changes: 2 additions & 2 deletions sdk/mpr/writer_widgets_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func serializeCustomWidget(cw *pages.CustomWidget) bson.D {
{Key: "LabelTemplate", Value: serializeLabelTemplate(cw.Label)},
{Key: "Name", Value: cw.Name},
{Key: "Object", Value: widgetObject},
{Key: "TabIndex", Value: int32(0)},
{Key: "TabIndex", Value: int64(0)},
{Key: "Type", Value: widgetType},
}

Expand Down Expand Up @@ -76,7 +76,7 @@ func serializeCustomWidgetWithRawType(cw *pages.CustomWidget) bson.D {
{Key: "LabelTemplate", Value: serializeLabelTemplate(cw.Label)},
{Key: "Name", Value: cw.Name},
{Key: "Object", Value: widgetObject},
{Key: "TabIndex", Value: int32(0)},
{Key: "TabIndex", Value: int64(0)},
{Key: "Type", Value: cw.RawType},
}

Expand Down
Loading