[APPS] Support uploading backend functions to app definitions#284
Draft
sdkennedy2 wants to merge 2 commits intomasterfrom
Draft
[APPS] Support uploading backend functions to app definitions#284sdkennedy2 wants to merge 2 commits intomasterfrom
sdkennedy2 wants to merge 2 commits intomasterfrom
Conversation
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.

Motivation
High code apps need the ability to define backend functions that get bundled and published to the app definition after upload. This enables server-side logic to be co-located with the app's frontend code and automatically deployed as part of the build process.
Changes
Added a complete backend functions pipeline that runs after a successful app upload:
Discovery — scans a configurable
backendDir(default:backend/) for function modules. Supports both single-file (backend/myFunc.ts) and directory (backend/myFunc/index.ts) patterns.Bundling — each discovered function is bundled with esbuild into a self-contained ESM module. Node built-ins are externalized. If
@datadog/action-catalogis installed, itssetExecuteActionImplementationexport is forced into the bundle.Transformation — bundled code is wrapped in the Action Platform script format with a
main($)entry point that registers the$.Actions-basedexecuteActionimplementation and invokes the function with template-resolved args.Publishing — transformed functions are sent as
ActionQueryobjects to thePATCH /api/v2/app-builder/apps/{app_builder_id}endpoint.Shared constants (
NODE_EXTERNALS,ACTION_CATALOG_EXPORT_LINE,SET_EXECUTE_ACTION_SNIPPET) are extracted intobackend-shared.tsfor reuse by the upcoming dev server middleware.New configuration option:
QA Instructions
backend/directory containing one or more function modulesAPPS_UPLOAD_ASSETS=1and valid API/app keysBlast Radius
backend/directory — no impact on existing apps without backend functionsDocumentation