Add udf and trigger commands for server-side programming management#125
Open
mkrueger wants to merge 1 commit into
Open
Add udf and trigger commands for server-side programming management#125mkrueger wants to merge 1 commit into
mkrueger wants to merge 1 commit into
Conversation
Adds 'udf' and 'trigger' commands that mirror the 'sproc' surface for the remaining Cosmos DB for NoSQL server-side resources: - udf: list, show, exists, create (from file or piped body, --force), delete - trigger: list, show, exists, create (--type pre/post, --operation, --force), delete Both operate on the current container (same scope as 'index'), return JSON results for piping, and expose 'exists' as a ShellBool for if/while conditions. Includes localization strings, docs, CHANGELOG, and unit tests for the pure helpers (subcommand normalization, trigger type/operation parsing). Part of #103.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new CLI surfaces to manage Cosmos DB for NoSQL server-side programming artifacts (UDFs and triggers) from within CosmosDBShell, completing the server-side programming management set alongside the previously added stored procedure support.
Changes:
- Introduces new
udfandtriggercommands withlist/show/exists/create/deletesubcommands scoped to the current container (with--database/--containeroverrides). - Adds localized help/error strings for both commands and updates user docs (
docs/commands.md) plus the Unreleased changelog. - Adds unit tests for the pure helper logic (subcommand normalization; trigger type/operation parsing).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/commands.md | Documents the new udf and trigger command surfaces and examples. |
| CosmosDBShell/lang/en.ftl | Adds localization strings for help text and errors for both commands. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/UdfCommand.cs | Implements udf command behavior (list/show/exists/create/delete) against container scripts. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/TriggerCommand.cs | Implements trigger command behavior including --type and --operation parsing. |
| CosmosDBShell.Tests/CommandTests/UdfCommandTests.cs | Tests UdfCommand.NormalizeSubcommand. |
| CosmosDBShell.Tests/CommandTests/TriggerCommandTests.cs | Tests TriggerCommand helper parsing/normalization. |
| CHANGELOG.md | Adds Unreleased entries describing the new commands. |
Comment on lines
+28
to
+32
| - 'list' returns the user-defined function ids in the container. | ||
| - 'show <name>' returns the body of a user-defined function. | ||
| - 'create <name> <file>' creates a user-defined function from a JavaScript file. Pass --force to replace an existing one. | ||
| - 'delete <name>' removes a user-defined function. | ||
| This command is restricted in MCP. Run it manually in the shell. |
Comment on lines
+28
to
+32
| - 'list' returns the trigger ids in the container with their type and operation. | ||
| - 'show <name>' returns the body of a trigger. | ||
| - 'create <name> <file>' creates a trigger from a JavaScript file. --type selects pre or post, --operation selects all/create/replace/delete/update, and --force replaces an existing one. | ||
| - 'delete <name>' removes a trigger. | ||
| This command is restricted in MCP. Run it manually in the shell. |
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
Adds
udfandtriggercommands so the shell can manage the remaining Cosmos DB for NoSQL server-side programming resources, completing the feature set requested in #103 (thesproccommand was added separately in #124).Both commands mirror the
sprocsurface and operate on the current container (same scope asindex).udflistshow <name>exists <name>if/whileconditionscreate <name> <file>--forceto replacedelete <name>triggerlistshow <name>exists <name>if/whileconditionscreate <name> <file>--type(pre/post, required),--operation(all/create/replace/delete/update, default all),--forceto replacedelete <name>Examples
Notes
sproc.listreturns structured JSON for piping;existsreturns aShellBool.Testing
dotnet buildclean; full test suite passes (1315 passed, 74 skipped, 0 failed), including the localization key audit and help verification tests that validate command registration.Docs
docs/commands.md: newudfandtriggersections.CHANGELOG.md: Unreleased entries linking [P1] Add Stored Procedures, UDFs, and Triggers management #103.Part of #103.