feat: form actions can be written in typescript - #164
Draft
romain-pm wants to merge 1 commit into
Draft
Conversation
The submission pipeline now falls back to JavaScript handlers registered under the 'formidable-form-action' registry type (JSServerExtensionInvoker SDK, javascript-modules-engine >= 1.3.0) when no Java FormAction matches. The built-in email notification, email content and forward actions are now TypeScript implementations in formidable-elements (node types moved along); save-to-JCR stays in Java. Security-sensitive logic (forward target resolution, SSRF checks, attachment building) remains in Java behind the new exported FormActionSupport service. On a pre-SDK engine, formidable still deploys and Java actions keep working.
Contributor
🦜 Chachalog
|
Contributor
📝 Documentation GuidelinesThank you for contributing to our documentation! To ensure your contributions meet our standards, please review these resources:
This comment is posted automatically when changes are detected in the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Form actions can now be written in TypeScript. The three built-in email/forward actions are converted to TS implementations in formidable-elements; save-to-JCR stays in Java. Existing forms and action configurations keep working unchanged.
Why
Formidable's action SPI was Java/OSGi-only, while the rest of the module family is moving to JavaScript modules. With the
JSServerExtensionInvokerSDK landing in javascript-modules-engine 1.3.0, consumer modules can define their own JS extension types — this PR uses it so site developers (and Formidable itself) can author actions in TypeScript without a Java bundle.Changes
JsFormActionDispatcherconsuming theformidable-form-actionregistry type (keyed by node type);FormSubmissionPipelinefalls back to it when no JavaFormActionmatches. Java handlers win on conflict; no handler at all still yieldsFMDB-008with progress counters.resolution:=optionalmanifest import) — on a pre-1.3.0 engine, formidable deploys and Java actions keep working.FormActionSupportservice (SSRF-checkedforwardSubmission— target URL never exposed to JS —, cappedbuildEmailAttachments, upload-size accessor).registerFormActionwrapper ({ok, status, message}wire contract, JavaFormActionExceptionstatuses preserved) and TS ports ofemailNotification,emailContent,forwardinformidable-elements/src/server/;TemplateInterpolator/FieldEscaperlogic ported with vitest coverage.docs/cnd-module-ownership.md);fmdbmix:formActionandfmdb:save2jcrActionstay in the engine.formidable-test-module-samples-tsx, new Cypress spec (tests/cypress/e2e/actions/70-ts-form-actions.cy.ts), Mailpit added to the e2e docker-compose, new/retargeted engine unit tests.Validation
mvn clean installgreen across all 8 modules (engine: 155 unit tests; elements: tsc + eslint + 14 vitest)sdk;version="[1.3,2)"importDocumentation
docs/how-to-create-form-action.md: new TypeScript section (wrapper usage, raw registry contract,FormActionSupport)docs/cnd-module-ownership.md: action-type ownership rule updatedDependency / draft status
feature/js-server-extensions-sdk(exportsorg.jahia.modules.javascript.modules.engine.sdkfromjavascript-modules-engine:1.3.0-SNAPSHOT). CI cannot compileformidable-engineuntil that branch is merged and a snapshot is published — keeping this PR draft until then. Once 1.3.0 is released, also consider pinning<jahia-depends>javascript-modules-engine=1.3.0</jahia-depends>.