Problem
mxcli can list, describe, and call JavaScript actions from microflows and nanoflows, but it cannot create or modify them. JavaScript actions still have to be authored in Studio Pro before any MDL script can reference them.
This forces awkward workarounds in doctype tests and example scripts: patterns from real projects (NanoflowCommons.SignIn, NanoflowCommons.RefreshObject, FeedbackModule.JS_PopulateFeedbackMetadata, etc.) cannot be reproduced end-to-end in a self-contained MDL example because there is no way to bring the called JS action into existence from MDL.
Current state
Supported (read-only):
- Grammar:
callJavaScriptActionStatement — mdl/grammar/domains/MDLMicroflow.g4:328
- Executor (call):
addCallJavaScriptActionAction — mdl/executor/cmd_microflows_builder_calls.go:428
- Executor (list/describe):
listJavaScriptActions, describeJavaScriptAction — mdl/executor/cmd_javascript_actions.go:19,68
- Backend reads:
ListJavaScriptActions, ReadJavaScriptActionByName — mdl/backend/java.go:15,17
- Parser:
mdl/types/JavaScriptAction, parameters parsed via parser_javaactions.go
- Writer (call site):
Microflows$JavaScriptActionCallAction — sdk/mpr/writer_microflow_actions.go:313
- Nanoflow roundtrip test:
TestRoundtripNanoflow_CallJavaScriptAction — mdl/executor/roundtrip_nanoflow_test.go:851 (currently skips when no JS action is pre-provisioned)
Missing:
- Grammar: no
createJavaScriptActionStatement rule
- AST: no
CreateJavaScriptActionStmt
- Executor: no
execCreateJavaScriptAction
- Backend writes: no
CreateJavaScriptAction / UpdateJavaScriptAction
- Writer: no
serializeJavaScriptAction (only the call-site writer exists)
- File side-channel: no
WriteJavaScriptSourceFile equivalent of the existing WriteJavaSourceFile
Compare with Java actions, which have the full surface: CreateJavaActionStmt AST → execCreateJavaAction executor (cmd_javaactions.go:285) → Backend.CreateJavaAction → BSON write + .java file emission.
Proposed MDL syntax
Mirror create java action so the two surfaces stay symmetric:
create javascript action MyModule.JS_RefreshObject (
$ObjectToRefresh: Object of MyModule.Item
) returns Boolean
folder 'JavaScript Actions'
as $$
// @ts-check
return Promise.resolve(true);
$$;
Open questions to nail down in a follow-up proposal:
- Where does the JS source live on disk? Java actions live under
javasource/ — JS actions presumably under javascriptsource/ (visible in the example projects). Need a WriteJavaScriptSourceFile symmetric with WriteJavaSourceFile.
- BSON
\$Type is JavaScriptActions\$JavaScriptAction (confirmed via parser). Need to dump a Studio-Pro-authored JS action and document the required fields (parameters, return type, MicroflowReturnType-style structure).
- Should the body be inline (dollar-quoted) only, or also support
external referring to an existing .js file authored elsewhere?
Why this matters
- 02b-nanoflow-examples.mdl can finally cover the JS-action-call patterns from real projects.
- mxcli init / scaffolding could ship reusable nanoflow helpers without requiring Studio Pro.
- Reproducible bug repros for nanoflow bugs that involve JS actions don't need a pre-built
.mpr.
Suggested implementation order
- Dump an existing JS action (e.g.
NanoflowCommons.SignIn from any reference project) and document the BSON in a proposal — docs/11-proposals/PROPOSAL_create_javascript_action.md.
- Wire grammar → AST → visitor → executor → backend (
Create/Update) following the Java action pattern.
- Add
Backend.WriteJavaScriptSourceFile and emit .js to javascriptsource/.
- Add a doctype-test example exercising
create javascript action + call javascript action in a nanoflow end-to-end. Unskip TestRoundtripNanoflow_CallJavaScriptAction so it provisions its own action.
- Update
.claude/skills/mendix/write-nanoflows.md with the new syntax.
Found during
Expanding mdl-examples/doctype-tests/02b-nanoflow-examples.mdl with representative patterns from EnquiriesManagement, LatoProductInventory, Evora-FactoryManagement. JS-action-call patterns were dropped from the doctype examples because there is no way to bring the called JS action into existence from MDL alone.
Problem
mxcli can list, describe, and call JavaScript actions from microflows and nanoflows, but it cannot create or modify them. JavaScript actions still have to be authored in Studio Pro before any MDL script can reference them.
This forces awkward workarounds in doctype tests and example scripts: patterns from real projects (
NanoflowCommons.SignIn,NanoflowCommons.RefreshObject,FeedbackModule.JS_PopulateFeedbackMetadata, etc.) cannot be reproduced end-to-end in a self-contained MDL example because there is no way to bring the called JS action into existence from MDL.Current state
Supported (read-only):
callJavaScriptActionStatement—mdl/grammar/domains/MDLMicroflow.g4:328addCallJavaScriptActionAction—mdl/executor/cmd_microflows_builder_calls.go:428listJavaScriptActions,describeJavaScriptAction—mdl/executor/cmd_javascript_actions.go:19,68ListJavaScriptActions,ReadJavaScriptActionByName—mdl/backend/java.go:15,17mdl/types/JavaScriptAction, parameters parsed viaparser_javaactions.goMicroflows$JavaScriptActionCallAction—sdk/mpr/writer_microflow_actions.go:313TestRoundtripNanoflow_CallJavaScriptAction—mdl/executor/roundtrip_nanoflow_test.go:851(currently skips when no JS action is pre-provisioned)Missing:
createJavaScriptActionStatementruleCreateJavaScriptActionStmtexecCreateJavaScriptActionCreateJavaScriptAction/UpdateJavaScriptActionserializeJavaScriptAction(only the call-site writer exists)WriteJavaScriptSourceFileequivalent of the existingWriteJavaSourceFileCompare with Java actions, which have the full surface:
CreateJavaActionStmtAST →execCreateJavaActionexecutor (cmd_javaactions.go:285) →Backend.CreateJavaAction→ BSON write +.javafile emission.Proposed MDL syntax
Mirror
create java actionso the two surfaces stay symmetric:Open questions to nail down in a follow-up proposal:
javasource/— JS actions presumably underjavascriptsource/(visible in the example projects). Need aWriteJavaScriptSourceFilesymmetric withWriteJavaSourceFile.\$TypeisJavaScriptActions\$JavaScriptAction(confirmed via parser). Need to dump a Studio-Pro-authored JS action and document the required fields (parameters, return type, MicroflowReturnType-style structure).externalreferring to an existing.jsfile authored elsewhere?Why this matters
.mpr.Suggested implementation order
NanoflowCommons.SignInfrom any reference project) and document the BSON in a proposal —docs/11-proposals/PROPOSAL_create_javascript_action.md.Create/Update) following the Java action pattern.Backend.WriteJavaScriptSourceFileand emit.jstojavascriptsource/.create javascript action+call javascript actionin a nanoflow end-to-end. UnskipTestRoundtripNanoflow_CallJavaScriptActionso it provisions its own action..claude/skills/mendix/write-nanoflows.mdwith the new syntax.Found during
Expanding
mdl-examples/doctype-tests/02b-nanoflow-examples.mdlwith representative patterns fromEnquiriesManagement,LatoProductInventory,Evora-FactoryManagement. JS-action-call patterns were dropped from the doctype examples because there is no way to bring the called JS action into existence from MDL alone.