[docs] test#1042
Open
aspire-repo-bot[bot] wants to merge 1 commit into
Open
Conversation
… support TypeScript AppHosts can now gate command state using ctx.resourceSnapshot() on UpdateCommandStateContext, exposed via the new UpdateCommandStateResourceSnapshot DTO added in microsoft/aspire#17328. Remove the outdated caution note that said TypeScript had no resourceSnapshot equivalent, and replace it with a working example that mirrors the C# health-gated command pattern. Also update the Japanese (ja) localization of the same page. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
14 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the “Update command state logic” documentation to describe TypeScript updateState as supporting resource-snapshot-based gating (mirroring the C# pattern), and applies the same change to the Japanese translation.
Changes:
- Replaces the previous TypeScript caution/limitations guidance with a
resourceSnapshot()-based approach. - Adds a TypeScript example that imports
HealthStatus/ResourceCommandStateand gates command enablement on health. - Updates accompanying explanatory bullets in both English and Japanese docs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/frontend/src/content/docs/fundamentals/custom-resource-commands.mdx | Updates TypeScript updateState docs and example to use resourceSnapshot() + health gating. |
| src/frontend/src/content/docs/ja/fundamentals/custom-resource-commands.mdx | Japanese translation of the same TypeScript updateState docs and example updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+290
to
294
| In TypeScript the `updateState` field on `CommandOptions` is an async callback that receives an `UpdateCommandStateContext`. The context exposes: | ||
|
|
||
| - `serviceProvider` — used to resolve services. | ||
| - `resourceSnapshot()` — an async function that returns a curated snapshot of the resource instance, including `healthStatus` and `state` (lifecycle state). | ||
|
|
Comment on lines
297
to
+312
| ```typescript title="apphost.ts" | ||
| import { HealthStatus, ResourceCommandState } from './.modules/aspire.js'; | ||
|
|
||
| await cache.withCommand( | ||
| "clear-cache", | ||
| "Clear Cache", | ||
| executeClearCache, | ||
| { | ||
| commandOptions: { | ||
| iconName: "AnimalRabbitOff", | ||
| updateState: async (ctx) => { | ||
| const snapshot = await ctx.resourceSnapshot(); | ||
|
|
||
| return snapshot.healthStatus === HealthStatus.Healthy | ||
| ? ResourceCommandState.Enabled | ||
| : ResourceCommandState.Disabled; |
Comment on lines
+289
to
+292
| TypeScript では `CommandOptions` の `updateState` フィールドは非同期コールバックで、`UpdateCommandStateContext` を受け取ります。コンテキストは以下を公開します。 | ||
|
|
||
| TypeScript では `CommandOptions` の `updateState` フィールドが緩い型(`any`)であり、SDK はまだ `ResourceCommandState` 列挙体をエクスポートしていません。現時点の TypeScript AppHost で最も単純な方法は、`updateState` を完全に省略することです。コマンドは既定で有効になり、リソース到達後にのみコマンド登録します。 | ||
| - `serviceProvider` — サービスを解決するために使用します。 | ||
| - `resourceSnapshot()` — リソース インスタンスのスナップショット(`healthStatus` とライフサイクル状態の `state` を含む)を返す非同期関数。 |
Comment on lines
296
to
+312
| ```typescript title="apphost.ts" | ||
| import { HealthStatus, ResourceCommandState } from './.modules/aspire.js'; | ||
|
|
||
| await cache.withCommand( | ||
| "clear-cache", | ||
| "Clear Cache", | ||
| executeClearCache, | ||
| { | ||
| commandOptions: { | ||
| iconName: "AnimalRabbitOff", | ||
| updateState: async (ctx) => { | ||
| const snapshot = await ctx.resourceSnapshot(); | ||
|
|
||
| return snapshot.healthStatus === HealthStatus.Healthy | ||
| ? ResourceCommandState.Enabled | ||
| : ResourceCommandState.Disabled; | ||
| }, |
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.
test