diff --git a/extension/loc/xlf/aspire-vscode.xlf b/extension/loc/xlf/aspire-vscode.xlf index 8855e802d27..2545cfe377c 100644 --- a/extension/loc/xlf/aspire-vscode.xlf +++ b/extension/loc/xlf/aspire-vscode.xlf @@ -434,7 +434,7 @@ Welcome to Aspire - Whether to the Aspire MCP server when a workspace is open. + Whether to register the Aspire MCP server when a workspace is open. Yes diff --git a/extension/package.json b/extension/package.json index 773c83e6f66..9c245cea22c 100644 --- a/extension/package.json +++ b/extension/package.json @@ -30,6 +30,8 @@ "workspaceContains:**/*.csproj", "onView:workbench.view.debug", "workspaceContains:**/apphost.cs", + "workspaceContains:**/apphost.ts", + "workspaceContains:**/apphost.js", "onCommand:aspire-vscode.installCliStable", "onCommand:aspire-vscode.installCliDaily", "onCommand:aspire-vscode.verifyCliInstalled" @@ -290,24 +292,24 @@ "explorer/context": [ { "command": "aspire-vscode.runAppHost", - "when": "resourceExtname == .cs && resourceFilename =~ /apphost\\.cs$/i", + "when": "resourceFilename =~ /apphost\\.(cs|ts|js)$/i", "group": "aspire_actions@1" }, { "command": "aspire-vscode.debugAppHost", - "when": "resourceExtname == .cs && resourceFilename =~ /apphost\\.cs$/i", + "when": "resourceFilename =~ /apphost\\.(cs|ts|js)$/i", "group": "aspire_actions@2" } ], "editor/title/run": [ { "command": "aspire-vscode.runAppHost", - "when": "(aspire.fileIsAppHostCs || aspire.workspaceHasAppHost) && aspire.editorSupportsRunDebug", + "when": "(aspire.fileIsAppHost || aspire.workspaceHasAppHost) && aspire.editorSupportsRunDebug", "group": "navigation@-4" }, { "command": "aspire-vscode.debugAppHost", - "when": "(aspire.fileIsAppHostCs || aspire.workspaceHasAppHost) && aspire.editorSupportsRunDebug", + "when": "(aspire.fileIsAppHost || aspire.workspaceHasAppHost) && aspire.editorSupportsRunDebug", "group": "navigation@-3" } ], diff --git a/extension/src/capabilities.ts b/extension/src/capabilities.ts index f1441c1e16a..da4ad8a7955 100644 --- a/extension/src/capabilities.ts +++ b/extension/src/capabilities.ts @@ -3,7 +3,7 @@ import { RunSessionInfo } from './dcp/types'; export type Capability = | 'prompting' // Support using VS Code to capture user input instead of CLI - | 'baseline.v1' + | 'baseline.v1' | 'secret-prompts.v1' | 'file-pickers.v1' | 'build-dotnet-using-cli' // Support building .NET projects using the CLI @@ -12,7 +12,9 @@ export type Capability = | 'project' // Support for running C# projects | 'ms-dotnettools.csharp' // Older AppHost versions used this extension identifier instead of project | 'python' // Support for running Python projects - | 'ms-python.python'; // Older AppHost versions used this extension identifier instead of python + | 'ms-python.python' // Older AppHost versions used this extension identifier instead of python + | 'node' // Support for running Node.js projects + | 'browser'; // Support for browser debugging (built-in to VS Code via js-debug) export type Capabilities = Capability[]; @@ -33,6 +35,11 @@ export function isPythonInstalled() { return isExtensionInstalled("ms-python.python"); } +export function isNodeInstalled() { + // Node.js debugging uses VS Code's built-in js-debug, no extension needed + return true; +} + export function getSupportedCapabilities(): Capabilities { const capabilities: Capabilities = ['prompting', 'baseline.v1', 'secret-prompts.v1', 'file-pickers.v1', 'build-dotnet-using-cli']; @@ -51,6 +58,11 @@ export function getSupportedCapabilities(): Capabilities { capabilities.push("ms-python.python"); } + if (isNodeInstalled()) { + capabilities.push("node"); + capabilities.push("browser"); + } + return capabilities; } diff --git a/extension/src/dcp/types.ts b/extension/src/dcp/types.ts index 47c9f804a31..02d98f83eff 100644 --- a/extension/src/dcp/types.ts +++ b/extension/src/dcp/types.ts @@ -44,6 +44,28 @@ export function isPythonLaunchConfiguration(obj: any): obj is PythonLaunchConfig return obj && obj.type === 'python'; } +export interface NodeLaunchConfiguration extends ExecutableLaunchConfiguration { + type: "node"; // Provided by VS Code's built-in js-debug, no extension needed + script_path?: string; + runtime_executable?: string; + working_directory?: string; +} + +export function isNodeLaunchConfiguration(obj: any): obj is NodeLaunchConfiguration { + return obj && obj.type === 'node'; +} + +export interface BrowserLaunchConfiguration extends ExecutableLaunchConfiguration { + type: "browser"; + url?: string; + web_root?: string; + browser?: string; +} + +export function isBrowserLaunchConfiguration(obj: any): obj is BrowserLaunchConfiguration { + return obj && obj.type === 'browser'; +} + export interface EnvVar { name: string; value: string; @@ -121,6 +143,7 @@ export interface AspireResourceExtendedDebugConfiguration extends vscode.DebugCo runId: string; debugSessionId: string | null; projectFile?: string; + isApphost?: boolean; } export type AspireCommandType = 'run' | 'deploy' | 'publish' | 'do'; diff --git a/extension/src/debugger/AspireDebugSession.ts b/extension/src/debugger/AspireDebugSession.ts index b38dd770932..adcff239824 100644 --- a/extension/src/debugger/AspireDebugSession.ts +++ b/extension/src/debugger/AspireDebugSession.ts @@ -1,13 +1,14 @@ import * as vscode from "vscode"; import { EventEmitter } from "vscode"; import * as fs from "fs"; -import { createDebugAdapterTracker } from "./adapterTracker"; -import { AspireResourceExtendedDebugConfiguration, AspireResourceDebugSession, EnvVar, AspireExtendedDebugConfiguration, ProjectLaunchConfiguration, StartAppHostOptions } from "../dcp/types"; +import { createDebugAdapterTracker, AppHostRestartHandler } from "./adapterTracker"; +import { AspireResourceExtendedDebugConfiguration, AspireResourceDebugSession, EnvVar, AspireExtendedDebugConfiguration, NodeLaunchConfiguration, ProjectLaunchConfiguration, StartAppHostOptions } from "../dcp/types"; import { extensionLogOutputChannel } from "../utils/logging"; import AspireDcpServer, { generateDcpIdPrefix } from "../dcp/AspireDcpServer"; import { spawnCliProcess } from "./languages/cli"; import { disconnectingFromSession, launchingWithAppHost, launchingWithDirectory, processExceptionOccurred, processExitedWithCode, aspireDashboard } from "../loc/strings"; import { projectDebuggerExtension } from "./languages/dotnet"; +import { nodeDebuggerExtension } from "./languages/node"; import AspireRpcServer from "../server/AspireRpcServer"; import { createDebugSessionConfiguration } from "./debuggerExtensions"; import { AspireTerminalProvider } from "../utils/AspireTerminalProvider"; @@ -34,7 +35,6 @@ export class AspireDebugSession implements vscode.DebugAdapter { private _dashboardDebugSession: vscode.DebugSession | null = null; private readonly _disposables: vscode.Disposable[] = []; private _disposed = false; - private _userInitiatedStop = false; public readonly onDidSendMessage = this._onDidSendMessage.event; public readonly debugSessionId: string; @@ -129,7 +129,6 @@ export class AspireDebugSession implements vscode.DebugAdapter { } else if (message.command === 'disconnect' || message.command === 'terminate') { this.sendMessageWithEmoji("🔌", disconnectingFromSession); - this._userInitiatedStop = true; this.dispose(); this.sendEvent({ @@ -215,33 +214,71 @@ export class AspireDebugSession implements vscode.DebugAdapter { } } - createDebugAdapterTrackerCore(debugAdapter: string) { + createDebugAdapterTrackerCore(debugAdapter: string, onAppHostRestartRequested?: AppHostRestartHandler) { if (this._trackedDebugAdapters.includes(debugAdapter)) { return; } this._trackedDebugAdapters.push(debugAdapter); - this._disposables.push(createDebugAdapterTracker(this._dcpServer, debugAdapter)); + this._disposables.push(createDebugAdapterTracker(this._dcpServer, debugAdapter, onAppHostRestartRequested)); } + private static readonly _nodeAppHostExtensions = ['.js', '.ts', '.mjs', '.mts', '.cjs', '.cts']; + + private _appHostRestartRequested = false; + async startAppHost(projectFile: string, args: string[], environment: EnvVar[], debug: boolean, options: StartAppHostOptions): Promise { try { - this.createDebugAdapterTrackerCore(projectDebuggerExtension.debugAdapter); + const fileExtension = path.extname(projectFile).toLowerCase(); + const isNodeAppHost = AspireDebugSession._nodeAppHostExtensions.includes(fileExtension); + + const debuggerExtension = isNodeAppHost ? nodeDebuggerExtension : projectDebuggerExtension; + + // Register the adapter tracker with an app host restart handler. + // When the user clicks "restart" on the app host child session, + // we suppress VS Code's automatic child restart and restart the + // entire Aspire debug session instead. + this.createDebugAdapterTrackerCore(debuggerExtension.debugAdapter, (debugSessionId) => { + if (debugSessionId === this.debugSessionId) { + this._appHostRestartRequested = true; + return true; // suppress VS Code's child restart + } + return false; + }); - // The CLI sends the full dotnet CLI args (e.g., ["run", "--no-build", "--project", "...", "--", ...appHostArgs]). - // Since we launch the apphost directly via the debugger (not via dotnet run), extract only the args after "--". - const separatorIndex = args.indexOf('--'); - const appHostArgs = separatorIndex >= 0 ? args.slice(separatorIndex + 1) : args; + let appHostArgs: string[]; + let launchConfig; + + if (isNodeAppHost) { + // The CLI prepends the runtime command (e.g., "npx") as args[0]. + // Extract it as the runtimeExecutable and use the rest as the actual args. + const runtimeExecutable = args.length > 0 ? args[0] : undefined; + appHostArgs = args.slice(1); + launchConfig = { + script_path: projectFile, + working_directory: path.dirname(projectFile), + type: 'node', + ...(runtimeExecutable ? { runtime_executable: runtimeExecutable } : {}) + } as NodeLaunchConfiguration; + } + else { + // The CLI sends the full dotnet CLI args (e.g., ["run", "--no-build", "--project", "...", "--", ...appHostArgs]). + // Since we launch the apphost directly via the debugger (not via dotnet run), extract only the args after "--". + const separatorIndex = args.indexOf('--'); + appHostArgs = separatorIndex >= 0 ? args.slice(separatorIndex + 1) : args; + launchConfig = { project_path: projectFile, type: 'project' } as ProjectLaunchConfiguration; + } extensionLogOutputChannel.info(`Starting AppHost for project: ${projectFile} with args: ${appHostArgs.join(' ')}`); const appHostDebugSessionConfiguration = await createDebugSessionConfiguration( this.configuration, - { project_path: projectFile, type: 'project' } as ProjectLaunchConfiguration, + launchConfig, appHostArgs, environment, - { debug, forceBuild: options.forceBuild, runId: '', debugSessionId: this.debugSessionId, isApphost: true, debugSession: this }, - projectDebuggerExtension); + { debug, forceBuild: isNodeAppHost ? false : options.forceBuild, runId: '', debugSessionId: this.debugSessionId, isApphost: true, debugSession: this }, + debuggerExtension); + const appHostDebugSession = await this.startAndGetDebugSession(appHostDebugSessionConfiguration); if (!appHostDebugSession) { @@ -252,15 +289,15 @@ export class AspireDebugSession implements vscode.DebugAdapter { const disposable = vscode.debug.onDidTerminateDebugSession(async session => { if (this._appHostDebugSession && session.id === this._appHostDebugSession.id) { - const command = this.configuration.command ?? 'run'; - // Only restart for 'run' — pipeline commands (do/deploy/publish) exit normally after completing. - const shouldRestart = !this._userInitiatedStop && command === 'run'; + // Only restart the Aspire session when the user explicitly clicked + // "restart" on the app host debug toolbar (detected via DAP tracker). + // All other cases (user stop, process crash/exit) just dispose. + const shouldRestart = this._appHostRestartRequested; const config = this.configuration; - // Always dispose the current Aspire debug session when the AppHost stops. this.dispose(); if (shouldRestart) { - extensionLogOutputChannel.info('AppHost terminated unexpectedly, restarting Aspire debug session'); + extensionLogOutputChannel.info('AppHost restart requested, restarting Aspire debug session'); await vscode.debug.startDebugging(undefined, config); } } diff --git a/extension/src/debugger/adapterTracker.ts b/extension/src/debugger/adapterTracker.ts index bfd699a1cf1..d43439c9373 100644 --- a/extension/src/debugger/adapterTracker.ts +++ b/extension/src/debugger/adapterTracker.ts @@ -5,10 +5,36 @@ import AspireDcpServer from '../dcp/AspireDcpServer'; import { removeTrailingNewline } from '../utils/strings'; import { dcpServerNotInitialized } from '../loc/strings'; -export function createDebugAdapterTracker(dcpServer: AspireDcpServer, debugAdapter: string): vscode.Disposable { +/** + * Callback invoked when a restart is requested on an app host debug session. + * Return `true` to suppress VS Code's automatic child session restart. + */ +export type AppHostRestartHandler = (debugSessionId: string) => boolean; + +export function createDebugAdapterTracker(dcpServer: AspireDcpServer, debugAdapter: string, onAppHostRestartRequested?: AppHostRestartHandler): vscode.Disposable { return vscode.debug.registerDebugAdapterTrackerFactory(debugAdapter, { createDebugAdapterTracker(session: vscode.DebugSession) { return { + onWillReceiveMessage: message => { + if (!isDebugConfigurationWithId(session.configuration)) { + return; + } + + // Detect restart requests on app host debug sessions. + // When the user clicks "restart" on the app host child session, + // suppress VS Code's automatic child restart so the Aspire debug + // session can restart entirely instead. + if (session.configuration.isApphost + && (message.command === 'disconnect' || message.command === 'terminate') + && message.arguments?.restart + && onAppHostRestartRequested + && session.configuration.debugSessionId) { + const shouldSuppress = onAppHostRestartRequested(session.configuration.debugSessionId); + if (shouldSuppress) { + message.arguments.restart = false; + } + } + }, onDidSendMessage: message => { if (message.type === 'event' && message.event === 'output') { if (!isDebugConfigurationWithId(session.configuration) || session.configuration.debugSessionId === null) { diff --git a/extension/src/debugger/debuggerExtensions.ts b/extension/src/debugger/debuggerExtensions.ts index c314c44fcb1..2d6c9aaccda 100644 --- a/extension/src/debugger/debuggerExtensions.ts +++ b/extension/src/debugger/debuggerExtensions.ts @@ -6,6 +6,8 @@ import { extensionLogOutputChannel } from "../utils/logging"; import { projectDebuggerExtension } from "./languages/dotnet"; import { isCsharpInstalled, isPythonInstalled } from "../capabilities"; import { pythonDebuggerExtension } from "./languages/python"; +import { nodeDebuggerExtension } from "./languages/node"; +import { browserDebuggerExtension } from "./languages/browser"; import { isDirectory } from "../utils/io"; // Represents a resource-specific debugger extension for when the default session configuration is not sufficient to launch the resource. @@ -39,7 +41,8 @@ export async function createDebugSessionConfiguration(debugSessionConfig: Aspire noDebug: !launchOptions.debug, runId: launchOptions.runId, debugSessionId: launchOptions.debugSessionId, - console: 'internalConsole' + console: 'internalConsole', + isApphost: launchOptions.isApphost }; if (debugSessionConfig.debuggers) { @@ -72,6 +75,9 @@ export function getResourceDebuggerExtensions(): ResourceDebuggerExtension[] { extensions.push(pythonDebuggerExtension); } + extensions.push(nodeDebuggerExtension); + extensions.push(browserDebuggerExtension); + return extensions; } diff --git a/extension/src/debugger/languages/browser.ts b/extension/src/debugger/languages/browser.ts new file mode 100644 index 00000000000..5719a1cd521 --- /dev/null +++ b/extension/src/debugger/languages/browser.ts @@ -0,0 +1,41 @@ +import { AspireResourceExtendedDebugConfiguration, ExecutableLaunchConfiguration, isBrowserLaunchConfiguration } from "../../dcp/types"; +import { browserDisplayName, browserLabel, invalidLaunchConfiguration } from "../../loc/strings"; +import { extensionLogOutputChannel } from "../../utils/logging"; +import { ResourceDebuggerExtension } from "../debuggerExtensions"; + +export const browserDebuggerExtension: ResourceDebuggerExtension = { + resourceType: 'browser', + debugAdapter: 'pwa-msedge', + extensionId: null, // built-in to VS Code via js-debug + getDisplayName: (launchConfiguration: ExecutableLaunchConfiguration) => { + if (isBrowserLaunchConfiguration(launchConfiguration) && launchConfiguration.url) { + return browserDisplayName(launchConfiguration.url); + } + return browserLabel; + }, + getSupportedFileTypes: () => [], + getProjectFile: () => '', + createDebugSessionConfigurationCallback: async (launchConfig, _args, _env, _launchOptions, debugConfiguration: AspireResourceExtendedDebugConfiguration): Promise => { + if (!isBrowserLaunchConfiguration(launchConfig)) { + extensionLogOutputChannel.info(`The resource type was not browser for ${JSON.stringify(launchConfig)}`); + throw new Error(invalidLaunchConfiguration(JSON.stringify(launchConfig))); + } + + // Map browser name to VS Code js-debug adapter type (pwa- prefix required) + const browser = launchConfig.browser || 'msedge'; + debugConfiguration.type = `pwa-${browser}`; + debugConfiguration.request = 'launch'; + debugConfiguration.url = launchConfig.url; + debugConfiguration.webRoot = launchConfig.web_root; + debugConfiguration.sourceMaps = true; + debugConfiguration.resolveSourceMapLocations = ['**', '!**/node_modules/**']; + // Use an auto-managed temp user data directory so multiple browser debuggers + // can run concurrently without conflicting + debugConfiguration.userDataDir = true; + + // Remove program/args/cwd since browser debugging doesn't use them + delete debugConfiguration.program; + delete debugConfiguration.args; + delete debugConfiguration.cwd; + } +}; diff --git a/extension/src/debugger/languages/node.ts b/extension/src/debugger/languages/node.ts new file mode 100644 index 00000000000..063ea1f48f7 --- /dev/null +++ b/extension/src/debugger/languages/node.ts @@ -0,0 +1,57 @@ +import { AspireResourceExtendedDebugConfiguration, ExecutableLaunchConfiguration, isNodeLaunchConfiguration } from "../../dcp/types"; +import { invalidLaunchConfiguration } from "../../loc/strings"; +import { extensionLogOutputChannel } from "../../utils/logging"; +import { ResourceDebuggerExtension } from "../debuggerExtensions"; +import * as vscode from 'vscode'; + +function getProjectFile(launchConfig: ExecutableLaunchConfiguration): string { + if (isNodeLaunchConfiguration(launchConfig)) { + // Use the absolute script path if available, otherwise fall back to working directory. + // The working directory ensures cwd is set correctly for package manager mode (npm run dev). + return launchConfig.script_path || launchConfig.working_directory || ''; + } + + throw new Error(invalidLaunchConfiguration(JSON.stringify(launchConfig))); +} + +export const nodeDebuggerExtension: ResourceDebuggerExtension = { + resourceType: 'node', + debugAdapter: 'node', + extensionId: null, + getDisplayName: (launchConfiguration: ExecutableLaunchConfiguration) => { + if (isNodeLaunchConfiguration(launchConfiguration)) { + const displayPath = launchConfiguration.script_path || launchConfiguration.working_directory || ''; + return `Node.js: ${displayPath ? vscode.workspace.asRelativePath(displayPath) : 'unknown'}`; + } + return 'Node.js'; + }, + getSupportedFileTypes: () => ['.js', '.ts', '.mjs', '.mts', '.cjs', '.cts'], + getProjectFile: (launchConfig) => getProjectFile(launchConfig), + createDebugSessionConfigurationCallback: async (launchConfig, args, _env, _launchOptions, debugConfiguration: AspireResourceExtendedDebugConfiguration): Promise => { + if (!isNodeLaunchConfiguration(launchConfig)) { + extensionLogOutputChannel.info(`The resource type was not node for ${JSON.stringify(launchConfig)}`); + throw new Error(invalidLaunchConfiguration(JSON.stringify(launchConfig))); + } + + debugConfiguration.type = 'node'; + + // Use working_directory for cwd if available + if (launchConfig.working_directory) { + debugConfiguration.cwd = launchConfig.working_directory; + } + + if (launchConfig.runtime_executable) { + debugConfiguration.runtimeExecutable = launchConfig.runtime_executable; + } + + // For package manager script execution (e.g., npm run dev), use args directly as runtimeArgs. + // The args from DCP already contain the full command (e.g., ["run", "dev", "--port", "5173"]). + if (launchConfig.runtime_executable && launchConfig.runtime_executable !== 'node') { + debugConfiguration.runtimeArgs = args ?? []; + delete debugConfiguration.args; + delete debugConfiguration.program; + } + + debugConfiguration.resolveSourceMapLocations = ['**', '!**/node_modules/**']; + } +}; diff --git a/extension/src/editor/AspireEditorCommandProvider.ts b/extension/src/editor/AspireEditorCommandProvider.ts index 3cf0c5c4d09..3d4989c866c 100644 --- a/extension/src/editor/AspireEditorCommandProvider.ts +++ b/extension/src/editor/AspireEditorCommandProvider.ts @@ -59,23 +59,40 @@ export class AspireEditorCommandProvider implements vscode.Disposable { vscode.commands.executeCommand('setContext', 'aspire.editorSupportsRunDebug', isSupportedFile); - if (await this.isAppHostCsFile(document.uri.fsPath)) { - vscode.commands.executeCommand('setContext', 'aspire.fileIsAppHostCs', true); + if (await this.isAppHostFile(document.uri.fsPath)) { + vscode.commands.executeCommand('setContext', 'aspire.fileIsAppHost', true); } else { - vscode.commands.executeCommand('setContext', 'aspire.fileIsAppHostCs', false); + vscode.commands.executeCommand('setContext', 'aspire.fileIsAppHost', false); } } - private async isAppHostCsFile(filePath: string): Promise { + private async isAppHostFile(filePath: string): Promise { const fileText = await vscode.workspace.fs.readFile(vscode.Uri.file(filePath)).then(buffer => buffer.toString()); const lines = fileText.split(/\r?\n/); + // C# apphost detection if (lines.some(line => line.startsWith('#:sdk Aspire.AppHost.Sdk'))) { return true; } - return lines.some(line => line === 'var builder = DistributedApplication.CreateBuilder(args);'); + if (lines.some(line => line === 'var builder = DistributedApplication.CreateBuilder(args);')) { + return true; + } + + // TypeScript/JavaScript apphost detection + const ext = path.extname(filePath).toLowerCase(); + if (['.ts', '.js', '.mts', '.mjs'].includes(ext)) { + if (lines.some(line => /import\s+.*createBuilder.*from\s+['"].*\.modules\/aspire/.test(line))) { + return true; + } + + if (lines.some(line => /require\s*\(['"].*\.modules\/aspire/.test(line))) { + return true; + } + } + + return false; } private onChangeAppHostPath(newPath: string | null) { @@ -122,7 +139,7 @@ export class AspireEditorCommandProvider implements vscode.Disposable { * Returns the resolved AppHost path from the active editor or workspace settings, or null if none is available. */ public async getAppHostPath(): Promise { - if (vscode.window.activeTextEditor && await this.isAppHostCsFile(vscode.window.activeTextEditor.document.uri.fsPath)) { + if (vscode.window.activeTextEditor && await this.isAppHostFile(vscode.window.activeTextEditor.document.uri.fsPath)) { return vscode.window.activeTextEditor.document.uri.fsPath; } diff --git a/extension/src/loc/strings.ts b/extension/src/loc/strings.ts index c0e15ca5e23..87783c4d194 100644 --- a/extension/src/loc/strings.ts +++ b/extension/src/loc/strings.ts @@ -65,6 +65,8 @@ export const failedToGetConfigInfo = (exitCode: number) => vscode.l10n.t('Failed export const failedToParseConfigInfo = (error: any) => vscode.l10n.t('Failed to parse Aspire config info: {0}. Try updating the Aspire CLI with: aspire update', error); export const errorGettingConfigInfo = (error: any) => vscode.l10n.t('Error getting Aspire config info: {0}. Try updating the Aspire CLI with: aspire update', error); export const invalidLaunchConfiguration = (projectPath: string) => vscode.l10n.t('Invalid launch configuration for {0}.', projectPath); +export const browserDisplayName = (url: string) => vscode.l10n.t('Browser: {0}', url); +export const browserLabel = vscode.l10n.t('Browser'); export const dontShowAgainLabel = vscode.l10n.t("Don't Show Again"); export const doYouWantToSetDefaultApphost = (appHost: string) => vscode.l10n.t('Do you want to set {0} as the default apphost for this workspace?', appHost); export const doYouWantToSelectDefaultApphost = vscode.l10n.t('Do you want to select the default apphost for this workspace?'); diff --git a/extension/src/server/interactionService.ts b/extension/src/server/interactionService.ts index 66ff29428a6..a546a1401b6 100644 --- a/extension/src/server/interactionService.ts +++ b/extension/src/server/interactionService.ts @@ -522,6 +522,7 @@ function tryExecuteEndpoint(interactionService: IInteractionService, withAuthent const message = (err && (((err as any).message) ?? String(err))) || 'An unknown error occurred'; extensionLogOutputChannel.error(`Interaction service endpoint '${name}' failed: ${message}`); vscode.window.showErrorMessage(errorMessage(message)); + interactionService.showStatus(null); throw err; } diff --git a/playground/AspireWithJavaScript/.vscode/settings.json b/playground/AspireWithJavaScript/.vscode/settings.json new file mode 100644 index 00000000000..d09fe4abc28 --- /dev/null +++ b/playground/AspireWithJavaScript/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "aspire.dashboardBrowser": "simpleBrowser" +} diff --git a/playground/AspireWithJavaScript/AspireJavaScript.AppHost/AppHost.cs b/playground/AspireWithJavaScript/AspireJavaScript.AppHost/AppHost.cs index 0fe07a74870..5d7212675df 100644 --- a/playground/AspireWithJavaScript/AspireJavaScript.AppHost/AppHost.cs +++ b/playground/AspireWithJavaScript/AspireJavaScript.AppHost/AppHost.cs @@ -10,13 +10,16 @@ .WithExternalHttpEndpoints() .PublishAsDockerFile(); +#pragma warning disable ASPIREEXTENSION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. builder.AddJavaScriptApp("react", "../AspireJavaScript.React", runScriptName: "start") .WithReference(weatherApi) .WaitFor(weatherApi) .WithEnvironment("BROWSER", "none") // Disable opening browser on npm start .WithHttpEndpoint(env: "PORT") .WithExternalHttpEndpoints() - .PublishAsDockerFile(); + .PublishAsDockerFile() + .WithBrowserDebugger(); +#pragma warning restore ASPIREEXTENSION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. builder.AddJavaScriptApp("vue", "../AspireJavaScript.Vue") .WithRunScript("start") @@ -27,10 +30,12 @@ .WithExternalHttpEndpoints() .PublishAsDockerFile(); +#pragma warning disable ASPIREEXTENSION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. var reactvite = builder.AddViteApp("reactvite", "../AspireJavaScript.Vite") .WithReference(weatherApi) .WithEnvironment("BROWSER", "none") .WithExternalHttpEndpoints(); +#pragma warning restore ASPIREEXTENSION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. builder.AddNodeApp("node", "../AspireJavaScript.NodeApp", "app.js") .WithRunScript("dev") // Use 'npm run dev' for development diff --git a/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/AppHost.cs b/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/AppHost.cs index 784b93baeab..a0f75deaad4 100644 --- a/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/AppHost.cs +++ b/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/AppHost.cs @@ -5,20 +5,12 @@ // Add services to the container. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); builder.Services.AddCors(); var app = builder.Build(); app.MapDefaultEndpoints(); -// Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} - app.UseHttpsRedirection(); app.UseCors(static builder => builder.AllowAnyMethod() @@ -42,8 +34,7 @@ .ToArray(); return forecast; }) -.WithName("GetWeatherForecast") -.WithOpenApi(); +.WithName("GetWeatherForecast"); app.UseFileServer(); diff --git a/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/Properties/launchSettings.json b/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/Properties/launchSettings.json index 4c791b4f6cc..ee034e9ee04 100644 --- a/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/Properties/launchSettings.json +++ b/playground/AspireWithJavaScript/AspireJavaScript.MinimalApi/Properties/launchSettings.json @@ -13,7 +13,6 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", "applicationUrl": "http://localhost:5084", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -23,7 +22,6 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", "applicationUrl": "https://localhost:7167;http://localhost:5084", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/playground/AspireWithJavaScript/AspireJavaScript.NodeApp/app.js b/playground/AspireWithJavaScript/AspireJavaScript.NodeApp/app.js index 9c39903c951..7e0e086f97f 100644 --- a/playground/AspireWithJavaScript/AspireJavaScript.NodeApp/app.js +++ b/playground/AspireWithJavaScript/AspireJavaScript.NodeApp/app.js @@ -69,7 +69,7 @@ app.use((err, req, res, next) => { }); // General 404 handler (for non-API routes) -app.use('*', (req, res) => { +app.use((req, res) => { res.status(404).json({ message: 'Route not found', path: req.originalUrl diff --git a/playground/AspireWithJavaScript/AspireJavaScript.React/webpack.config.js b/playground/AspireWithJavaScript/AspireJavaScript.React/webpack.config.js index 016c52e1674..770f78907a3 100644 --- a/playground/AspireWithJavaScript/AspireJavaScript.React/webpack.config.js +++ b/playground/AspireWithJavaScript/AspireJavaScript.React/webpack.config.js @@ -3,6 +3,7 @@ const HTMLWebpackPlugin = require("html-webpack-plugin"); module.exports = (env) => { return { entry: "./src/index.js", + devtool: "source-map", devServer: { port: env.PORT || 4001, allowedHosts: "all", diff --git a/playground/TypeScriptAppHost/.gitignore b/playground/TypeScriptAppHost/.gitignore index 867ed95f2f0..56a45c92c4a 100644 --- a/playground/TypeScriptAppHost/.gitignore +++ b/playground/TypeScriptAppHost/.gitignore @@ -1 +1,2 @@ !.aspire/ +.aspire/dcp/ diff --git a/playground/TypeScriptAppHost/.modules/.codegen-hash b/playground/TypeScriptAppHost/.modules/.codegen-hash index 684c5ac1140..e02d1446575 100644 --- a/playground/TypeScriptAppHost/.modules/.codegen-hash +++ b/playground/TypeScriptAppHost/.modules/.codegen-hash @@ -1 +1 @@ -B1EE4C88283B2949DA165E54F052FB8213C98527E5BDA53C3EBB44D5FC8C876B \ No newline at end of file +01B89896FB4482B7BC294CB5C1CE4D8763C7096CA487FB9A6430DAA7217C0312 \ No newline at end of file diff --git a/playground/TypeScriptAppHost/.modules/aspire.ts b/playground/TypeScriptAppHost/.modules/aspire.ts index 9fb119d55da..8ade3448ce5 100644 --- a/playground/TypeScriptAppHost/.modules/aspire.ts +++ b/playground/TypeScriptAppHost/.modules/aspire.ts @@ -26,9 +26,18 @@ import { // Handle Type Aliases (Internal - not exported to users) // ============================================================================ +/** Handle to DockerComposeAspireDashboardResource */ +type DockerComposeAspireDashboardResourceHandle = Handle<'Aspire.Hosting.Docker/Aspire.Hosting.Docker.DockerComposeAspireDashboardResource'>; + /** Handle to DockerComposeEnvironmentResource */ type DockerComposeEnvironmentResourceHandle = Handle<'Aspire.Hosting.Docker/Aspire.Hosting.Docker.DockerComposeEnvironmentResource'>; +/** Handle to DockerComposeServiceResource */ +type DockerComposeServiceResourceHandle = Handle<'Aspire.Hosting.Docker/Aspire.Hosting.Docker.DockerComposeServiceResource'>; + +/** Handle to Service */ +type ServiceHandle = Handle<'Aspire.Hosting.Docker/Aspire.Hosting.Docker.Resources.ComposeNodes.Service'>; + /** Handle to JavaScriptAppResource */ type JavaScriptAppResourceHandle = Handle<'Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.JavaScriptAppResource'>; @@ -65,9 +74,18 @@ type RedisInsightResourceHandle = Handle<'Aspire.Hosting.Redis/Aspire.Hosting.Re /** Handle to CommandLineArgsCallbackContext */ type CommandLineArgsCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext'>; +/** Handle to ContainerRegistryResource */ +type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; + /** Handle to ContainerResource */ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource'>; +/** Handle to CSharpAppResource */ +type CSharpAppResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource'>; + +/** Handle to DotnetToolResource */ +type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; + /** Handle to EndpointReference */ type EndpointReferenceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference'>; @@ -83,6 +101,12 @@ type ExecutableResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicatio /** Handle to ExecuteCommandContext */ type ExecuteCommandContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext'>; +/** Handle to IComputeResource */ +type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource'>; + +/** Handle to IContainerFilesDestinationResource */ +type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -110,6 +134,9 @@ type ProjectResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationMo /** Handle to ReferenceExpression */ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression'>; +/** Handle to ReferenceExpressionBuilder */ +type ReferenceExpressionBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder'>; + /** Handle to ResourceLoggerService */ type ResourceLoggerServiceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService'>; @@ -119,6 +146,9 @@ type ResourceNotificationServiceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.A /** Handle to ResourceUrlsCallbackContext */ type ResourceUrlsCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext'>; +/** Handle to ConnectionStringResource */ +type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; + /** Handle to DistributedApplication */ type DistributedApplicationHandle = Handle<'Aspire.Hosting/Aspire.Hosting.DistributedApplication'>; @@ -131,12 +161,30 @@ type DistributedApplicationEventSubscriptionHandle = Handle<'Aspire.Hosting/Aspi /** Handle to IDistributedApplicationEventing */ type IDistributedApplicationEventingHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing'>; +/** Handle to ExternalServiceResource */ +type ExternalServiceResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ExternalServiceResource'>; + /** Handle to IDistributedApplicationBuilder */ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder'>; +/** Handle to IResourceWithContainerFiles */ +type IResourceWithContainerFilesHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles'>; + /** Handle to IResourceWithServiceDiscovery */ type IResourceWithServiceDiscoveryHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery'>; +/** Handle to PipelineConfigurationContext */ +type PipelineConfigurationContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext'>; + +/** Handle to PipelineStep */ +type PipelineStepHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep'>; + +/** Handle to PipelineStepContext */ +type PipelineStepContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext'>; + +/** Handle to ProjectResourceOptions */ +type ProjectResourceOptionsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions'>; + /** Handle to Dict */ type DictstringanyHandle = Handle<'Aspire.Hosting/Dict'>; @@ -162,6 +210,14 @@ type IServiceProviderHandle = Handle<'System.ComponentModel/System.IServiceProvi // Enum Types // ============================================================================ +/** Enum type for CertificateTrustScope */ +export enum CertificateTrustScope { + None = "None", + Append = "Append", + Override = "Override", + System = "System", +} + /** Enum type for ContainerLifetime */ export enum ContainerLifetime { Session = "Session", @@ -199,6 +255,20 @@ export enum ImagePullPolicy { Never = "Never", } +/** Enum type for OtlpProtocol */ +export enum OtlpProtocol { + Grpc = "Grpc", + HttpProtobuf = "HttpProtobuf", + HttpJson = "HttpJson", +} + +/** Enum type for ProbeType */ +export enum ProbeType { + Startup = "Startup", + Readiness = "Readiness", + Liveness = "Liveness", +} + /** Enum type for ProtocolType */ export enum ProtocolType { IP = "IP", @@ -234,6 +304,12 @@ export enum UrlDisplayLocation { DetailsOnly = "DetailsOnly", } +/** Enum type for WaitBehavior */ +export enum WaitBehavior { + WaitOnResourceUnavailable = "WaitOnResourceUnavailable", + StopOnResourceUnavailable = "StopOnResourceUnavailable", +} + // ============================================================================ // DTO Interfaces // ============================================================================ @@ -294,14 +370,27 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } +export interface AddContainerRegistryOptions { + repository?: ParameterResource; +} + export interface AddDatabaseOptions { databaseName?: string; } +export interface AddDockerfileOptions { + dockerfilePath?: string; + stage?: string; +} + export interface AddJavaScriptAppOptions { runScriptName?: string; } +export interface AddParameterFromConfigurationOptions { + secret?: boolean; +} + export interface AddParameterOptions { secret?: boolean; } @@ -325,6 +414,14 @@ export interface AddViteAppOptions { runScriptName?: string; } +export interface AppendFormattedOptions { + format?: string; +} + +export interface AppendValueProviderOptions { + format?: string; +} + export interface GetValueAsyncOptions { cancellationToken?: AbortSignal; } @@ -341,14 +438,27 @@ export interface WithBindMountOptions { isReadOnly?: boolean; } +export interface WithBrowserDebuggerOptions { + browser?: string; +} + export interface WithBuildScriptOptions { args?: string[]; } +export interface WithBunOptions { + install?: boolean; + installArgs?: string[]; +} + export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithDashboardOptions { + enabled?: boolean; +} + export interface WithDataBindMountOptions { isReadOnly?: boolean; } @@ -362,6 +472,16 @@ export interface WithDescriptionOptions { enableMarkdown?: boolean; } +export interface WithDockerfileBaseImageOptions { + buildImage?: string; + runtimeImage?: string; +} + +export interface WithDockerfileOptions { + dockerfilePath?: string; + stage?: string; +} + export interface WithEndpointOptions { port?: number; targetPort?: number; @@ -373,6 +493,15 @@ export interface WithEndpointOptions { protocol?: ProtocolType; } +export interface WithExternalServiceHttpHealthCheckOptions { + path?: string; + statusCode?: number; +} + +export interface WithForwardedHeadersOptions { + enabled?: boolean; +} + export interface WithHostPortOptions { port?: number; } @@ -391,6 +520,20 @@ export interface WithHttpHealthCheckOptions { endpointName?: string; } +export interface WithHttpProbeOptions { + path?: string; + initialDelaySeconds?: number; + periodSeconds?: number; + timeoutSeconds?: number; + failureThreshold?: number; + successThreshold?: number; + endpointName?: string; +} + +export interface WithHttpsDeveloperCertificateOptions { + password?: ParameterResource; +} + export interface WithHttpsEndpointOptions { port?: number; targetPort?: number; @@ -399,10 +542,19 @@ export interface WithHttpsEndpointOptions { isProxied?: boolean; } +export interface WithIconNameOptions { + iconVariant?: IconVariant; +} + export interface WithImageOptions { tag?: string; } +export interface WithMcpServerOptions { + path?: string; + endpointName?: string; +} + export interface WithNpmOptions { install?: boolean; installCommand?: string; @@ -424,6 +576,18 @@ export interface WithPgWebOptions { containerName?: string; } +export interface WithPipelineStepFactoryOptions { + dependsOn?: string[]; + requiredBy?: string[]; + tags?: string[]; + description?: string; +} + +export interface WithPnpmOptions { + install?: boolean; + installArgs?: string[]; +} + export interface WithPostgresMcpOptions { configureContainer?: (obj: PostgresMcpContainerResource) => Promise; containerName?: string; @@ -444,6 +608,10 @@ export interface WithReferenceOptions { optional?: boolean; } +export interface WithRequiredCommandOptions { + helpLink?: string; +} + export interface WithRunScriptOptions { args?: string[]; } @@ -461,6 +629,11 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +export interface WithYarnOptions { + install?: boolean; + installArgs?: string[]; +} + // ============================================================================ // CommandLineArgsCallbackContext // ============================================================================ @@ -930,1057 +1103,15203 @@ export class ExecuteCommandContext { } // ============================================================================ -// ResourceUrlsCallbackContext +// PipelineConfigurationContext // ============================================================================ /** - * Type class for ResourceUrlsCallbackContext. + * Type class for PipelineConfigurationContext. */ -export class ResourceUrlsCallbackContext { - constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Urls property */ - private _urls?: AspireList; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', { context: this._handle } ); }, - }; - - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', - { context: this._handle } + set: async (value: PipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, + } }; + /** Gets pipeline steps with the specified tag */ + async getStepsByTag(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/getStepsByTag', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for PipelineConfigurationContext that enables fluent chaining. + */ +export class PipelineConfigurationContextPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineConfigurationContext) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets pipeline steps with the specified tag */ + getStepsByTag(tag: string): Promise { + return this._promise.then(obj => obj.getStepsByTag(tag)); + } + } // ============================================================================ -// DistributedApplicationBuilder +// PipelineStep // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for PipelineStep. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class PipelineStep { + constructor(private _handle: PipelineStepHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { + /** Gets the Name property */ + name = { get: async (): Promise => { return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + 'Aspire.Hosting.Pipelines/PipelineStep.name', { context: this._handle } ); }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.setName', + { context: this._handle, value } + ); + } }; - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + /** Gets the Description property */ + description = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.description', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.setDescription', + { context: this._handle, value } + ); + } }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', - { context: this._handle } + /** Gets the DependsOnSteps property */ + private _dependsOnSteps?: AspireList; + get dependsOnSteps(): AspireList { + if (!this._dependsOnSteps) { + this._dependsOnSteps = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Pipelines/PipelineStep.dependsOnSteps', + 'Aspire.Hosting.Pipelines/PipelineStep.dependsOnSteps' ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, - }; + } + return this._dependsOnSteps; + } - /** Builds the distributed application */ - /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', - rpcArgs - ); - return new DistributedApplication(result, this._client); + /** Gets the RequiredBySteps property */ + private _requiredBySteps?: AspireList; + get requiredBySteps(): AspireList { + if (!this._requiredBySteps) { + this._requiredBySteps = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Pipelines/PipelineStep.requiredBySteps', + 'Aspire.Hosting.Pipelines/PipelineStep.requiredBySteps' + ); + } + return this._requiredBySteps; } - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); + /** Gets the Tags property */ + private _tags?: AspireList; + get tags(): AspireList { + if (!this._tags) { + this._tags = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Pipelines/PipelineStep.tags', + 'Aspire.Hosting.Pipelines/PipelineStep.tags' + ); + } + return this._tags; } - /** Adds a container resource */ + /** Adds a dependency on another step by name */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', + async _dependsOnInternal(stepName: string): Promise { + const rpcArgs: Record = { context: this._handle, stepName }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/dependsOn', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + dependsOn(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._dependsOnInternal(stepName)); } - /** Adds an executable resource */ + /** Specifies that another step requires this step by name */ /** @internal */ - async _addExecutableInternal(name: string, command: string, workingDirectory: string, args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, name, command, workingDirectory, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExecutable', + async _requiredByInternal(stepName: string): Promise { + const rpcArgs: Record = { context: this._handle, stepName }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/requiredBy', rpcArgs ); - return new ExecutableResource(result, this._client); + return this; } - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + requiredBy(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._requiredByInternal(stepName)); } - /** Adds a parameter resource */ - /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', - rpcArgs - ); - return new ParameterResource(result, this._client); - } +} - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); - } +/** + * Thenable wrapper for PipelineStep that enables fluent chaining. + */ +export class PipelineStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds a connection string resource */ - /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', - rpcArgs - ); - return new ResourceWithConnectionString(result, this._client); + then( + onfulfilled?: ((value: PipelineStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + /** Adds a dependency on another step by name */ + dependsOn(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._promise.then(obj => obj.dependsOn(stepName))); } - /** Adds a .NET project resource */ - /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', - rpcArgs - ); - return new ProjectResource(result, this._client); + /** Specifies that another step requires this step by name */ + requiredBy(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._promise.then(obj => obj.requiredBy(stepName))); } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); - } +} - /** Adds a PostgreSQL server resource */ - /** @internal */ - async _addPostgresInternal(name: string, userName?: ParameterResource, password?: ParameterResource, port?: number): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (userName !== undefined) rpcArgs.userName = userName; - if (password !== undefined) rpcArgs.password = password; - if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.PostgreSQL/addPostgres', - rpcArgs - ); - return new PostgresServerResource(result, this._client); - } +// ============================================================================ +// PipelineStepContext +// ============================================================================ - addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise { - const userName = options?.userName; - const password = options?.password; - const port = options?.port; - return new PostgresServerResourcePromise(this._addPostgresInternal(name, userName, password, port)); - } +/** + * Type class for PipelineStepContext. + */ +export class PipelineStepContext { + constructor(private _handle: PipelineStepContextHandle, private _client: AspireClientRpc) {} - /** Adds a Redis container resource with specific port */ - /** @internal */ - async _addRedisWithPortInternal(name: string, port?: number): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Redis/addRedisWithPort', - rpcArgs - ); - return new RedisResource(result, this._client); - } + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } - addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { - const port = options?.port; - return new RedisResourcePromise(this._addRedisWithPortInternal(name, port)); - } + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; - /** Adds a Redis container resource */ - /** @internal */ - async _addRedisInternal(name: string, port?: number, password?: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (port !== undefined) rpcArgs.port = port; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Redis/addRedis', - rpcArgs - ); - return new RedisResource(result, this._client); - } + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', + { context: this._handle } + ); + }, + }; - addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { - const port = options?.port; - const password = options?.password; - return new RedisResourcePromise(this._addRedisInternal(name, port, password)); - } +} - /** Adds a Node.js application resource */ +// ============================================================================ +// ProjectResourceOptions +// ============================================================================ + +/** + * Type class for ProjectResourceOptions. + */ +export class ProjectResourceOptions { + constructor(private _handle: ProjectResourceOptionsHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the LaunchProfileName property */ + launchProfileName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.launchProfileName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setLaunchProfileName', + { context: this._handle, value } + ); + } + }; + + /** Gets the ExcludeLaunchProfile property */ + excludeLaunchProfile = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeLaunchProfile', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setExcludeLaunchProfile', + { context: this._handle, value } + ); + } + }; + + /** Gets the ExcludeKestrelEndpoints property */ + excludeKestrelEndpoints = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeKestrelEndpoints', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setExcludeKestrelEndpoints', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// ReferenceExpressionBuilder +// ============================================================================ + +/** + * Type class for ReferenceExpressionBuilder. + */ +export class ReferenceExpressionBuilder { + constructor(private _handle: ReferenceExpressionBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the IsEmpty property */ + isEmpty = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ReferenceExpressionBuilder.isEmpty', + { context: this._handle } + ); + }, + }; + + /** Appends a literal string to the reference expression */ /** @internal */ - async _addNodeAppInternal(name: string, appDirectory: string, scriptPath: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, appDirectory, scriptPath }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.JavaScript/addNodeApp', + async _appendLiteralInternal(value: string): Promise { + const rpcArgs: Record = { context: this._handle, value }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendLiteral', rpcArgs ); - return new NodeAppResource(result, this._client); + return this; } - addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._addNodeAppInternal(name, appDirectory, scriptPath)); + appendLiteral(value: string): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._appendLiteralInternal(value)); } - /** Adds a JavaScript application resource */ + /** Appends a formatted string value to the reference expression */ /** @internal */ - async _addJavaScriptAppInternal(name: string, appDirectory: string, runScriptName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, appDirectory }; - if (runScriptName !== undefined) rpcArgs.runScriptName = runScriptName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.JavaScript/addJavaScriptApp', + async _appendFormattedInternal(value: string, format?: string): Promise { + const rpcArgs: Record = { context: this._handle, value }; + if (format !== undefined) rpcArgs.format = format; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendFormatted', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return this; } - addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise { - const runScriptName = options?.runScriptName; - return new JavaScriptAppResourcePromise(this._addJavaScriptAppInternal(name, appDirectory, runScriptName)); + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { + const format = options?.format; + return new ReferenceExpressionBuilderPromise(this._appendFormattedInternal(value, format)); } - /** Adds a Vite application resource */ + /** Appends a value provider to the reference expression */ /** @internal */ - async _addViteAppInternal(name: string, appDirectory: string, runScriptName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, appDirectory }; - if (runScriptName !== undefined) rpcArgs.runScriptName = runScriptName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.JavaScript/addViteApp', + async _appendValueProviderInternal(valueProvider: any, format?: string): Promise { + const rpcArgs: Record = { context: this._handle, valueProvider }; + if (format !== undefined) rpcArgs.format = format; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendValueProvider', rpcArgs ); - return new ViteAppResource(result, this._client); + return this; } - addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise { - const runScriptName = options?.runScriptName; - return new ViteAppResourcePromise(this._addViteAppInternal(name, appDirectory, runScriptName)); + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { + const format = options?.format; + return new ReferenceExpressionBuilderPromise(this._appendValueProviderInternal(valueProvider, format)); } - /** Adds a Docker Compose publishing environment */ - /** @internal */ - async _addDockerComposeEnvironmentInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Docker/addDockerComposeEnvironment', + /** Builds the reference expression */ + async build(): Promise { + const rpcArgs: Record = { context: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/build', rpcArgs ); - return new DockerComposeEnvironmentResource(result, this._client); - } - - addDockerComposeEnvironment(name: string): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._addDockerComposeEnvironmentInternal(name)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReferenceExpressionBuilder that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReferenceExpressionBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReferenceExpressionBuilder) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); - } - - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); - } - - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); - } - - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); - } - - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); - } - - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); - } - - /** Adds a PostgreSQL server resource */ - addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._promise.then(obj => obj.addPostgres(name, options))); - } - - /** Adds a Redis container resource with specific port */ - addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.addRedisWithPort(name, options))); - } - - /** Adds a Redis container resource */ - addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.addRedis(name, options))); - } - - /** Adds a Node.js application resource */ - addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.addNodeApp(name, appDirectory, scriptPath))); + /** Appends a literal string to the reference expression */ + appendLiteral(value: string): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendLiteral(value))); } - /** Adds a JavaScript application resource */ - addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.addJavaScriptApp(name, appDirectory, options))); + /** Appends a formatted string value to the reference expression */ + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendFormatted(value, options))); } - /** Adds a Vite application resource */ - addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.addViteApp(name, appDirectory, options))); + /** Appends a value provider to the reference expression */ + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendValueProvider(valueProvider, options))); } - /** Adds a Docker Compose publishing environment */ - addDockerComposeEnvironment(name: string): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.addDockerComposeEnvironment(name))); + /** Builds the reference expression */ + build(): Promise { + return this._promise.then(obj => obj.build()); } } // ============================================================================ -// DistributedApplicationEventing +// ResourceUrlsCallbackContext // ============================================================================ /** - * Type class for DistributedApplicationEventing. + * Type class for ResourceUrlsCallbackContext. */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Service +// ============================================================================ + +/** + * Type class for Service. + */ +export class Service { + constructor(private _handle: ServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Image property */ + image = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.image', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setImage', + { context: this._handle, value } + ); + } + }; + + /** Gets the PullPolicy property */ + pullPolicy = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.pullPolicy', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setPullPolicy', + { context: this._handle, value } + ); + } + }; + + /** Gets the ContainerName property */ + containerName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.containerName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setContainerName', + { context: this._handle, value } + ); + } + }; + + /** Gets the Command property */ + private _command?: AspireList; + get command(): AspireList { + if (!this._command) { + this._command = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.command', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.command' + ); + } + return this._command; + } + + /** Gets the Entrypoint property */ + private _entrypoint?: AspireList; + get entrypoint(): AspireList { + if (!this._entrypoint) { + this._entrypoint = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.entrypoint', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.entrypoint' + ); + } + return this._entrypoint; + } + + /** Gets the Environment property */ + private _environment?: AspireDict; + get environment(): AspireDict { + if (!this._environment) { + this._environment = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.environment', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.environment' + ); + } + return this._environment; + } + + /** Gets the EnvFile property */ + private _envFile?: AspireList; + get envFile(): AspireList { + if (!this._envFile) { + this._envFile = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.envFile', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.envFile' + ); + } + return this._envFile; + } + + /** Gets the WorkingDir property */ + workingDir = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.workingDir', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setWorkingDir', + { context: this._handle, value } + ); + } + }; + + /** Gets the Ports property */ + private _ports?: AspireList; + get ports(): AspireList { + if (!this._ports) { + this._ports = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.ports', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.ports' + ); + } + return this._ports; + } + + /** Gets the Expose property */ + private _expose?: AspireList; + get expose(): AspireList { + if (!this._expose) { + this._expose = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.expose', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.expose' + ); + } + return this._expose; + } + + /** Gets the User property */ + user = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.user', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setUser', + { context: this._handle, value } + ); + } + }; + + /** Gets the Networks property */ + private _networks?: AspireList; + get networks(): AspireList { + if (!this._networks) { + this._networks = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.networks', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.networks' + ); + } + return this._networks; + } + + /** Gets the Restart property */ + restart = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.restart', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setRestart', + { context: this._handle, value } + ); + } + }; + + /** Gets the Labels property */ + private _labels?: AspireDict; + get labels(): AspireDict { + if (!this._labels) { + this._labels = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.labels', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.labels' + ); + } + return this._labels; + } + + /** Gets the DomainName property */ + domainName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.domainName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setDomainName', + { context: this._handle, value } + ); + } + }; + + /** Gets the Hostname property */ + hostname = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.hostname', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setHostname', + { context: this._handle, value } + ); + } + }; + + /** Gets the Isolation property */ + isolation = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.isolation', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setIsolation', + { context: this._handle, value } + ); + } + }; + + /** Gets the Ipc property */ + ipc = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.ipc', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setIpc', + { context: this._handle, value } + ); + } + }; + + /** Gets the MacAddress property */ + macAddress = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.macAddress', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setMacAddress', + { context: this._handle, value } + ); + } + }; + + /** Gets the Pid property */ + pid = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.pid', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setPid', + { context: this._handle, value } + ); + } + }; + + /** Gets the CapAdd property */ + private _capAdd?: AspireList; + get capAdd(): AspireList { + if (!this._capAdd) { + this._capAdd = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.capAdd', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.capAdd' + ); + } + return this._capAdd; + } + + /** Gets the CapDrop property */ + private _capDrop?: AspireList; + get capDrop(): AspireList { + if (!this._capDrop) { + this._capDrop = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.capDrop', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.capDrop' + ); + } + return this._capDrop; + } + + /** Gets the CgroupParent property */ + cgroupParent = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.cgroupParent', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setCgroupParent', + { context: this._handle, value } + ); + } + }; + + /** Gets the Devices property */ + private _devices?: AspireList; + get devices(): AspireList { + if (!this._devices) { + this._devices = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.devices', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.devices' + ); + } + return this._devices; + } + + /** Gets the Dns property */ + private _dns?: AspireList; + get dns(): AspireList { + if (!this._dns) { + this._dns = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.dns', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.dns' + ); + } + return this._dns; + } + + /** Gets the DnsSearch property */ + private _dnsSearch?: AspireList; + get dnsSearch(): AspireList { + if (!this._dnsSearch) { + this._dnsSearch = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.dnsSearch', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.dnsSearch' + ); + } + return this._dnsSearch; + } + + /** Gets the ExtraHosts property */ + private _extraHosts?: AspireDict; + get extraHosts(): AspireDict { + if (!this._extraHosts) { + this._extraHosts = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.extraHosts', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.extraHosts' + ); + } + return this._extraHosts; + } + + /** Gets the GroupAdd property */ + private _groupAdd?: AspireList; + get groupAdd(): AspireList { + if (!this._groupAdd) { + this._groupAdd = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.groupAdd', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.groupAdd' + ); + } + return this._groupAdd; + } + + /** Gets the Init property */ + init = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.init', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setInit', + { context: this._handle, value } + ); + } + }; + + /** Gets the Links property */ + private _links?: AspireList; + get links(): AspireList { + if (!this._links) { + this._links = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.links', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.links' + ); + } + return this._links; + } + + /** Gets the ExternalLinks property */ + private _externalLinks?: AspireList; + get externalLinks(): AspireList { + if (!this._externalLinks) { + this._externalLinks = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.externalLinks', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.externalLinks' + ); + } + return this._externalLinks; + } + + /** Gets the NetworkMode property */ + networkMode = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.networkMode', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setNetworkMode', + { context: this._handle, value } + ); + } + }; + + /** Gets the Profiles property */ + private _profiles?: AspireList; + get profiles(): AspireList { + if (!this._profiles) { + this._profiles = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.profiles', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.profiles' + ); + } + return this._profiles; + } + + /** Gets the ReadOnly property */ + readOnly = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.readOnly', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setReadOnly', + { context: this._handle, value } + ); + } + }; + + /** Gets the SecurityOpt property */ + private _securityOpt?: AspireList; + get securityOpt(): AspireList { + if (!this._securityOpt) { + this._securityOpt = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.securityOpt', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.securityOpt' + ); + } + return this._securityOpt; + } + + /** Gets the StopGracePeriod property */ + stopGracePeriod = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.stopGracePeriod', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setStopGracePeriod', + { context: this._handle, value } + ); + } + }; + + /** Gets the StopSignal property */ + stopSignal = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.stopSignal', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setStopSignal', + { context: this._handle, value } + ); + } + }; + + /** Gets the Sysctls property */ + private _sysctls?: AspireDict; + get sysctls(): AspireDict { + if (!this._sysctls) { + this._sysctls = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.sysctls', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.sysctls' + ); + } + return this._sysctls; + } + + /** Gets the Tmpfs property */ + private _tmpfs?: AspireList; + get tmpfs(): AspireList { + if (!this._tmpfs) { + this._tmpfs = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.tmpfs', + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.tmpfs' + ); + } + return this._tmpfs; + } + + /** Gets the StdinOpen property */ + stdinOpen = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.stdinOpen', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setStdinOpen', + { context: this._handle, value } + ); + } + }; + + /** Gets the Tty property */ + tty = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.tty', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setTty', + { context: this._handle, value } + ); + } + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.name', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker.Resources.ComposeNodes/Service.setName', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistry', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @internal */ + async _addContainerInternal(name: string, image: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, image }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + addContainer(name: string, image: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @internal */ + async _addDockerfileInternal(name: string, contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addDockerfile', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @internal */ + async _addDotnetToolInternal(name: string, packageId: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, packageId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addDotnetTool', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @internal */ + async _addExecutableInternal(name: string, command: string, workingDirectory: string, args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, command, workingDirectory, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExecutable', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @internal */ + async _addParameterFromConfigurationInternal(name: string, configurationKey: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, configurationKey }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterFromConfiguration', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Adds a PostgreSQL server resource */ + /** @internal */ + async _addPostgresInternal(name: string, userName?: ParameterResource, password?: ParameterResource, port?: number): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (userName !== undefined) rpcArgs.userName = userName; + if (password !== undefined) rpcArgs.password = password; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/addPostgres', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise { + const userName = options?.userName; + const password = options?.password; + const port = options?.port; + return new PostgresServerResourcePromise(this._addPostgresInternal(name, userName, password, port)); + } + + /** Adds a Redis container resource with specific port */ + /** @internal */ + async _addRedisWithPortInternal(name: string, port?: number): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/addRedisWithPort', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { + const port = options?.port; + return new RedisResourcePromise(this._addRedisWithPortInternal(name, port)); + } + + /** Adds a Redis container resource */ + /** @internal */ + async _addRedisInternal(name: string, port?: number, password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (port !== undefined) rpcArgs.port = port; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/addRedis', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { + const port = options?.port; + const password = options?.password; + return new RedisResourcePromise(this._addRedisInternal(name, port, password)); + } + + /** Adds a Node.js application resource */ + /** @internal */ + async _addNodeAppInternal(name: string, appDirectory: string, scriptPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, appDirectory, scriptPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/addNodeApp', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._addNodeAppInternal(name, appDirectory, scriptPath)); + } + + /** Adds a JavaScript application resource */ + /** @internal */ + async _addJavaScriptAppInternal(name: string, appDirectory: string, runScriptName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, appDirectory }; + if (runScriptName !== undefined) rpcArgs.runScriptName = runScriptName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/addJavaScriptApp', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise { + const runScriptName = options?.runScriptName; + return new JavaScriptAppResourcePromise(this._addJavaScriptAppInternal(name, appDirectory, runScriptName)); + } + + /** Adds a Vite application resource */ + /** @internal */ + async _addViteAppInternal(name: string, appDirectory: string, runScriptName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, appDirectory }; + if (runScriptName !== undefined) rpcArgs.runScriptName = runScriptName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/addViteApp', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise { + const runScriptName = options?.runScriptName; + return new ViteAppResourcePromise(this._addViteAppInternal(name, appDirectory, runScriptName)); + } + + /** Adds a Docker Compose publishing environment */ + /** @internal */ + async _addDockerComposeEnvironmentInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/addDockerComposeEnvironment', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + addDockerComposeEnvironment(name: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._addDockerComposeEnvironmentInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Adds a PostgreSQL server resource */ + addPostgres(name: string, options?: AddPostgresOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.addPostgres(name, options))); + } + + /** Adds a Redis container resource with specific port */ + addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.addRedisWithPort(name, options))); + } + + /** Adds a Redis container resource */ + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.addRedis(name, options))); + } + + /** Adds a Node.js application resource */ + addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.addNodeApp(name, appDirectory, scriptPath))); + } + + /** Adds a JavaScript application resource */ + addJavaScriptApp(name: string, appDirectory: string, options?: AddJavaScriptAppOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.addJavaScriptApp(name, appDirectory, options))); + } + + /** Adds a Vite application resource */ + addViteApp(name: string, appDirectory: string, options?: AddViteAppOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.addViteApp(name, appDirectory, options))); + } + + /** Adds a Docker Compose publishing environment */ + addDockerComposeEnvironment(name: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.addDockerComposeEnvironment(name))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @internal */ + async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { + const rpcArgs: Record = { context: this._handle, subscription }; + await this._client.invokeCapability( + 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', + rpcArgs + ); + return this; + } + + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// ConnectionStringResource +// ============================================================================ + +export class ConnectionStringResource extends ResourceBuilderBase { + constructor(handle: ConnectionStringResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ConnectionStringResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { + const helpLink = options?.helpLink; + return new ConnectionStringResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { + const displayText = options?.displayText; + return new ConnectionStringResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { + const displayText = options?.displayText; + return new ConnectionStringResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { + const exitCode = options?.exitCode; + return new ConnectionStringResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + const commandOptions = options?.commandOptions; + return new ConnectionStringResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { + const iconVariant = options?.iconVariant; + return new ConnectionStringResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ConnectionStringResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for ConnectionStringResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ConnectionStringResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ConnectionStringResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + +} + +// ============================================================================ +// ContainerRegistryResource +// ============================================================================ + +export class ContainerRegistryResource extends ResourceBuilderBase { + constructor(handle: ContainerRegistryResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ContainerRegistryResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { + const helpLink = options?.helpLink; + return new ContainerRegistryResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + const displayText = options?.displayText; + return new ContainerRegistryResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + const displayText = options?.displayText; + return new ContainerRegistryResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + const commandOptions = options?.commandOptions; + return new ContainerRegistryResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ContainerRegistryResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for ContainerRegistryResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ContainerRegistryResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ContainerRegistryResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export class ContainerResource extends ResourceBuilderBase { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ContainerResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise { + return new ContainerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ContainerResourcePromise { + return new ContainerResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { + const displayText = options?.displayText; + return new ContainerResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { + const displayText = options?.displayText; + return new ContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerResourcePromise { + return new ContainerResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ContainerResourcePromise { + const exitCode = options?.exitCode; + return new ContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new ContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { + return new ContainerResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { + const password = options?.password; + return new ContainerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ContainerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerResourcePromise { + return new ContainerResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + +} + +/** + * Thenable wrapper for ContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ContainerResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// CSharpAppResource +// ============================================================================ + +export class CSharpAppResource extends ResourceBuilderBase { + constructor(handle: CSharpAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new CSharpAppResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReplicas', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the number of replicas */ + withReplicas(replicas: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReplicasInternal(replicas)); + } + + /** @internal */ + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/disableForwardedHeaders', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._disableForwardedHeadersInternal()); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new CSharpAppResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new CSharpAppResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new CSharpAppResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { + const displayText = options?.displayText; + return new CSharpAppResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { + const displayText = options?.displayText; + return new CSharpAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFiles', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + const exitCode = options?.exitCode; + return new CSharpAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + const commandOptions = options?.commandOptions; + return new CSharpAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { + const password = options?.password; + return new CSharpAppResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { + const iconVariant = options?.iconVariant; + return new CSharpAppResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new CSharpAppResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + +} + +/** + * Thenable wrapper for CSharpAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class CSharpAppResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: CSharpAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Sets the number of replicas */ + withReplicas(replicas: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); + } + + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// DockerComposeAspireDashboardResource +// ============================================================================ + +export class DockerComposeAspireDashboardResource extends ResourceBuilderBase { + constructor(handle: DockerComposeAspireDashboardResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** Gets the PrimaryEndpoint property */ + primaryEndpoint = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeAspireDashboardResource.primaryEndpoint', + { context: this._handle } + ); + return new EndpointReference(handle, this._client); + }, + }; + + /** Gets the OtlpGrpcEndpoint property */ + otlpGrpcEndpoint = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeAspireDashboardResource.otlpGrpcEndpoint', + { context: this._handle } + ); + return new EndpointReference(handle, this._client); + }, + }; + + /** Gets the Entrypoint property */ + entrypoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeAspireDashboardResource.entrypoint', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeAspireDashboardResource.setEntrypoint', + { context: this._handle, value } + ); + } + }; + + /** Gets the ShellExecution property */ + shellExecution = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeAspireDashboardResource.shellExecution', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeAspireDashboardResource.setShellExecution', + { context: this._handle, value } + ); + } + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeAspireDashboardResource.name', + { context: this._handle } + ); + }, + }; + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): DockerComposeAspireDashboardResourcePromise { + const isReadOnly = options?.isReadOnly; + return new DockerComposeAspireDashboardResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } + + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEntrypointInternal(entrypoint)); + } + + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withImageTagInternal(tag)); + } + + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withImageRegistryInternal(registry)); + } + + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): DockerComposeAspireDashboardResourcePromise { + const tag = options?.tag; + return new DockerComposeAspireDashboardResourcePromise(this._withImageInternal(image, tag)); + } + + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withImageSHA256Internal(sha256)); + } + + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withContainerRuntimeArgsInternal(args)); + } + + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withLifetimeInternal(lifetime)); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._publishAsContainerInternal()); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): DockerComposeAspireDashboardResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new DockerComposeAspireDashboardResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the container name */ + withContainerName(name: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withContainerNameInternal(name)); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withBuildSecretInternal(name, value)); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DockerComposeAspireDashboardResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new DockerComposeAspireDashboardResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DockerComposeAspireDashboardResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new DockerComposeAspireDashboardResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DockerComposeAspireDashboardResourcePromise { + const helpLink = options?.helpLink; + return new DockerComposeAspireDashboardResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DockerComposeAspireDashboardResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new DockerComposeAspireDashboardResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DockerComposeAspireDashboardResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new DockerComposeAspireDashboardResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DockerComposeAspireDashboardResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DockerComposeAspireDashboardResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DockerComposeAspireDashboardResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DockerComposeAspireDashboardResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DockerComposeAspireDashboardResourcePromise { + const displayText = options?.displayText; + return new DockerComposeAspireDashboardResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeAspireDashboardResourcePromise { + const displayText = options?.displayText; + return new DockerComposeAspireDashboardResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): DockerComposeAspireDashboardResourcePromise { + const exitCode = options?.exitCode; + return new DockerComposeAspireDashboardResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DockerComposeAspireDashboardResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new DockerComposeAspireDashboardResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeAspireDashboardResourcePromise { + const commandOptions = options?.commandOptions; + return new DockerComposeAspireDashboardResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DockerComposeAspireDashboardResourcePromise { + const password = options?.password; + return new DockerComposeAspireDashboardResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DockerComposeAspireDashboardResourcePromise { + const iconVariant = options?.iconVariant; + return new DockerComposeAspireDashboardResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DockerComposeAspireDashboardResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new DockerComposeAspireDashboardResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DockerComposeAspireDashboardResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new DockerComposeAspireDashboardResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): DockerComposeAspireDashboardResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new DockerComposeAspireDashboardResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/withHostPort', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Sets the host port for the Aspire dashboard */ + withHostPort(options?: WithHostPortOptions): DockerComposeAspireDashboardResourcePromise { + const port = options?.port; + return new DockerComposeAspireDashboardResourcePromise(this._withHostPortInternal(port)); + } + + /** @internal */ + private async _withForwardedHeadersInternal(enabled?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (enabled !== undefined) rpcArgs.enabled = enabled; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/withForwardedHeaders', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Enables or disables forwarded headers support for the Aspire dashboard */ + withForwardedHeaders(options?: WithForwardedHeadersOptions): DockerComposeAspireDashboardResourcePromise { + const enabled = options?.enabled; + return new DockerComposeAspireDashboardResourcePromise(this._withForwardedHeadersInternal(enabled)); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new DockerComposeAspireDashboardResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + +} + +/** + * Thenable wrapper for DockerComposeAspireDashboardResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class DockerComposeAspireDashboardResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DockerComposeAspireDashboardResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Sets the host port for the Aspire dashboard */ + withHostPort(options?: WithHostPortOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withHostPort(options))); + } + + /** Enables or disables forwarded headers support for the Aspire dashboard */ + withForwardedHeaders(options?: WithForwardedHeadersOptions): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.withForwardedHeaders(options))); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): DockerComposeAspireDashboardResourcePromise { + return new DockerComposeAspireDashboardResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// DockerComposeEnvironmentResource +// ============================================================================ + +export class DockerComposeEnvironmentResource extends ResourceBuilderBase { + constructor(handle: DockerComposeEnvironmentResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** Gets the DefaultNetworkName property */ + defaultNetworkName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeEnvironmentResource.defaultNetworkName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeEnvironmentResource.setDefaultNetworkName', + { context: this._handle, value } + ); + } + }; + + /** Gets the DashboardEnabled property */ + dashboardEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeEnvironmentResource.dashboardEnabled', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeEnvironmentResource.setDashboardEnabled', + { context: this._handle, value } + ); + } + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeEnvironmentResource.name', + { context: this._handle } + ); + }, + }; + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DockerComposeEnvironmentResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new DockerComposeEnvironmentResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DockerComposeEnvironmentResourcePromise { + const helpLink = options?.helpLink; + return new DockerComposeEnvironmentResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DockerComposeEnvironmentResourcePromise { + const displayText = options?.displayText; + return new DockerComposeEnvironmentResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeEnvironmentResourcePromise { + const displayText = options?.displayText; + return new DockerComposeEnvironmentResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeEnvironmentResourcePromise { + const commandOptions = options?.commandOptions; + return new DockerComposeEnvironmentResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DockerComposeEnvironmentResourcePromise { + const iconVariant = options?.iconVariant; + return new DockerComposeEnvironmentResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DockerComposeEnvironmentResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new DockerComposeEnvironmentResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _withPropertiesInternal(configure: (obj: DockerComposeEnvironmentResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as DockerComposeEnvironmentResourceHandle; + const obj = new DockerComposeEnvironmentResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/withProperties', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Configures properties of the Docker Compose environment */ + withProperties(configure: (obj: DockerComposeEnvironmentResource) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._withPropertiesInternal(configure)); + } + + /** @internal */ + private async _withDashboardInternal(enabled?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (enabled !== undefined) rpcArgs.enabled = enabled; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/withDashboard', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Enables or disables the Aspire dashboard for the Docker Compose environment */ + withDashboard(options?: WithDashboardOptions): DockerComposeEnvironmentResourcePromise { + const enabled = options?.enabled; + return new DockerComposeEnvironmentResourcePromise(this._withDashboardInternal(enabled)); + } + + /** @internal */ + private async _configureDashboardInternal(configure: (obj: DockerComposeAspireDashboardResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as DockerComposeAspireDashboardResourceHandle; + const obj = new DockerComposeAspireDashboardResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/configureDashboard', + rpcArgs + ); + return new DockerComposeEnvironmentResource(result, this._client); + } + + /** Configures the Aspire dashboard resource for the Docker Compose environment */ + configureDashboard(configure: (obj: DockerComposeAspireDashboardResource) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._configureDashboardInternal(configure)); + } + +} + +/** + * Thenable wrapper for DockerComposeEnvironmentResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class DockerComposeEnvironmentResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DockerComposeEnvironmentResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Configures properties of the Docker Compose environment */ + withProperties(configure: (obj: DockerComposeEnvironmentResource) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withProperties(configure))); + } + + /** Enables or disables the Aspire dashboard for the Docker Compose environment */ + withDashboard(options?: WithDashboardOptions): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withDashboard(options))); + } + + /** Configures the Aspire dashboard resource for the Docker Compose environment */ + configureDashboard(configure: (obj: DockerComposeAspireDashboardResource) => Promise): DockerComposeEnvironmentResourcePromise { + return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.configureDashboard(configure))); + } + +} + +// ============================================================================ +// DockerComposeServiceResource +// ============================================================================ + +export class DockerComposeServiceResource extends ResourceBuilderBase { + constructor(handle: DockerComposeServiceResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** Gets the Parent property */ + parent = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeServiceResource.parent', + { context: this._handle } + ); + return new DockerComposeEnvironmentResource(handle, this._client); + }, + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Docker/DockerComposeServiceResource.name', + { context: this._handle } + ); + }, + }; + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DockerComposeServiceResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new DockerComposeServiceResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DockerComposeServiceResourcePromise { + const helpLink = options?.helpLink; + return new DockerComposeServiceResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DockerComposeServiceResourcePromise { + const displayText = options?.displayText; + return new DockerComposeServiceResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeServiceResourcePromise { + const displayText = options?.displayText; + return new DockerComposeServiceResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeServiceResourcePromise { + const commandOptions = options?.commandOptions; + return new DockerComposeServiceResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DockerComposeServiceResourcePromise { + const iconVariant = options?.iconVariant; + return new DockerComposeServiceResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DockerComposeServiceResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new DockerComposeServiceResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new DockerComposeServiceResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for DockerComposeServiceResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class DockerComposeServiceResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DockerComposeServiceResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DockerComposeServiceResourcePromise { + return new DockerComposeServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + +} + +// ============================================================================ +// DotnetToolResource +// ============================================================================ + +export class DotnetToolResource extends ResourceBuilderBase { + constructor(handle: DotnetToolResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new DotnetToolResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withToolPackageInternal(packageId: string): Promise { + const rpcArgs: Record = { builder: this._handle, packageId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolPackage', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the tool package ID */ + withToolPackage(packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolPackageInternal(packageId)); + } + + /** @internal */ + private async _withToolVersionInternal(version: string): Promise { + const rpcArgs: Record = { builder: this._handle, version }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolVersion', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the tool version */ + withToolVersion(version: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolVersionInternal(version)); + } + + /** @internal */ + private async _withToolPrereleaseInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolPrerelease', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Allows prerelease tool versions */ + withToolPrerelease(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolPrereleaseInternal()); + } + + /** @internal */ + private async _withToolSourceInternal(source: string): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolSource', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a NuGet source for the tool */ + withToolSource(source: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolSourceInternal(source)); + } + + /** @internal */ + private async _withToolIgnoreExistingFeedsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolIgnoreExistingFeeds', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Ignores existing NuGet feeds */ + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolIgnoreExistingFeedsInternal()); + } + + /** @internal */ + private async _withToolIgnoreFailedSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolIgnoreFailedSources', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Ignores failed NuGet sources */ + withToolIgnoreFailedSources(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolIgnoreFailedSourcesInternal()); + } + + /** @internal */ + private async _publishAsDockerFileInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { + const helpLink = options?.helpLink; + return new DotnetToolResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new DotnetToolResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DotnetToolResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DotnetToolResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { + const displayText = options?.displayText; + return new DotnetToolResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { + const displayText = options?.displayText; + return new DotnetToolResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + const exitCode = options?.exitCode; + return new DotnetToolResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + const commandOptions = options?.commandOptions; + return new DotnetToolResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { + const password = options?.password; + return new DotnetToolResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { + const iconVariant = options?.iconVariant; + return new DotnetToolResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new DotnetToolResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + +} + +/** + * Thenable wrapper for DotnetToolResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class DotnetToolResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Sets the tool package ID */ + withToolPackage(packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPackage(packageId))); + } + + /** Sets the tool version */ + withToolVersion(version: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolVersion(version))); + } + + /** Allows prerelease tool versions */ + withToolPrerelease(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPrerelease())); + } + + /** Adds a NuGet source for the tool */ + withToolSource(source: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolSource(source))); + } + + /** Ignores existing NuGet feeds */ + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreExistingFeeds())); + } + + /** Ignores failed NuGet sources */ + withToolIgnoreFailedSources(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreFailedSources())); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// ExecutableResource +// ============================================================================ + +export class ExecutableResource extends ResourceBuilderBase { + constructor(handle: ExecutableResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ExecutableResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ExecutableResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { + const helpLink = options?.helpLink; + return new ExecutableResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ExecutableResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ExecutableResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ExecutableResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { + const displayText = options?.displayText; + return new ExecutableResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { + const displayText = options?.displayText; + return new ExecutableResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ExecutableResourcePromise { + const exitCode = options?.exitCode; + return new ExecutableResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ExecutableResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { + const commandOptions = options?.commandOptions; + return new ExecutableResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { + const password = options?.password; + return new ExecutableResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { + const iconVariant = options?.iconVariant; + return new ExecutableResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ExecutableResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + +} + +/** + * Thenable wrapper for ExecutableResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ExecutableResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ExecutableResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// ExternalServiceResource +// ============================================================================ + +export class ExternalServiceResource extends ResourceBuilderBase { + constructor(handle: ExternalServiceResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ExternalServiceResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withExternalServiceHttpHealthCheckInternal(path?: string, statusCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalServiceHttpHealthCheck', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds an HTTP health check to an external service */ + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + return new ExternalServiceResourcePromise(this._withExternalServiceHttpHealthCheckInternal(path, statusCode)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { + const helpLink = options?.helpLink; + return new ExternalServiceResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { + const displayText = options?.displayText; + return new ExternalServiceResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { + const displayText = options?.displayText; + return new ExternalServiceResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + const commandOptions = options?.commandOptions; + return new ExternalServiceResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { + const iconVariant = options?.iconVariant; + return new ExternalServiceResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ExternalServiceResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for ExternalServiceResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ExternalServiceResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ExternalServiceResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds an HTTP health check to an external service */ + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExternalServiceHttpHealthCheck(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + +} + +// ============================================================================ +// JavaScriptAppResource +// ============================================================================ + +export class JavaScriptAppResource extends ResourceBuilderBase { + constructor(handle: JavaScriptAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): JavaScriptAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new JavaScriptAppResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _publishAsDockerFileInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): JavaScriptAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new JavaScriptAppResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): JavaScriptAppResourcePromise { + const helpLink = options?.helpLink; + return new JavaScriptAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): JavaScriptAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new JavaScriptAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new JavaScriptAppResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new JavaScriptAppResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new JavaScriptAppResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): JavaScriptAppResourcePromise { + const displayText = options?.displayText; + return new JavaScriptAppResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): JavaScriptAppResourcePromise { + const displayText = options?.displayText; + return new JavaScriptAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withContainerFilesSourceInternal(sourcePath)); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._clearContainerFilesSourcesInternal()); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise { + const exitCode = options?.exitCode; + return new JavaScriptAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new JavaScriptAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise { + const commandOptions = options?.commandOptions; + return new JavaScriptAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): JavaScriptAppResourcePromise { + const password = options?.password; + return new JavaScriptAppResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): JavaScriptAppResourcePromise { + const iconVariant = options?.iconVariant; + return new JavaScriptAppResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): JavaScriptAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new JavaScriptAppResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): JavaScriptAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new JavaScriptAppResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + +} + +/** + * Thenable wrapper for JavaScriptAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class JavaScriptAppResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: JavaScriptAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withContainerFilesSource(sourcePath))); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.clearContainerFilesSources())); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// NodeAppResource +// ============================================================================ + +export class NodeAppResource extends ResourceBuilderBase { + constructor(handle: NodeAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** Gets the Command property */ + command = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.command', + { context: this._handle } + ); + }, + }; + + /** Gets the WorkingDirectory property */ + workingDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.workingDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.name', + { context: this._handle } + ); + }, + }; + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NodeAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new NodeAppResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _publishAsDockerFileInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): NodeAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new NodeAppResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NodeAppResourcePromise { + const helpLink = options?.helpLink; + return new NodeAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): NodeAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new NodeAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new NodeAppResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new NodeAppResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; - await this._client.invokeCapability( - 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', rpcArgs ); - return this; + return new NodeAppResource(result, this._client); } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new NodeAppResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); } -} + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } -/** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. - */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withExternalHttpEndpointsInternal()); + } - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): NodeAppResourcePromise { + const displayText = options?.displayText; + return new NodeAppResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): NodeAppResourcePromise { + const displayText = options?.displayText; + return new NodeAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFiles', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withContainerFilesSourceInternal(sourcePath)); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._clearContainerFilesSourcesInternal()); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._waitForInternal(dependency)); } -} - -// ============================================================================ -// ContainerResource -// ============================================================================ + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } -export class ContainerResource extends ResourceBuilderBase { - constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Prevents resource from starting automatically */ + withExplicitStart(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): NodeAppResourcePromise { + const exitCode = options?.exitCode; + return new NodeAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds arguments */ - withArgs(args: string[]): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsInternal(args)); + /** Adds a health check by key */ + withHealthCheck(key: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsCallbackInternal(callback)); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new NodeAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); } /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise { + const commandOptions = options?.commandOptions; + return new NodeAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withCertificateTrustScopeInternal(scope)); } /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new ContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NodeAppResourcePromise { + const password = options?.password; + return new NodeAppResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + private async _withoutHttpsCertificateInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withoutHttpsCertificateInternal()); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ContainerResourcePromise { - return new ContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): NodeAppResourcePromise { + const iconVariant = options?.iconVariant; + return new NodeAppResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', rpcArgs ); + return new NodeAppResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NodeAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new NodeAppResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ - private async _asHttp2ServiceInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): ContainerResourcePromise { - return new ContainerResourcePromise(this._asHttp2ServiceInternal()); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { - const displayText = options?.displayText; - return new ContainerResourcePromise(this._withUrlInternal(url, displayText)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NodeAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new NodeAppResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { - const displayText = options?.displayText; - return new ContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); await callback(obj); }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withPipelineConfigurationInternal(callback)); } - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', rpcArgs ); - return new ContainerResource(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + private async _withNpmInternal(install?: boolean, installCommand?: string, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installCommand !== undefined) rpcArgs.installCommand = installCommand; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withNpm', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForInternal(dependency)); + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): NodeAppResourcePromise { + const install = options?.install; + const installCommand = options?.installCommand; + const installArgs = options?.installArgs; + return new NodeAppResourcePromise(this._withNpmInternal(install, installCommand, installArgs)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withBunInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBun', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerResourcePromise { - return new ContainerResourcePromise(this._withExplicitStartInternal()); + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): NodeAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NodeAppResourcePromise(this._withBunInternal(install, installArgs)); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + private async _withYarnInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withYarn', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ContainerResourcePromise { - const exitCode = options?.exitCode; - return new ContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): NodeAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NodeAppResourcePromise(this._withYarnInternal(install, installArgs)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withPnpmInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withPnpm', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withHealthCheckInternal(key)); + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): NodeAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new NodeAppResourcePromise(this._withPnpmInternal(install, installArgs)); } /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', + private async _withBuildScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBuildScript', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new ContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise { + const args = options?.args; + return new NodeAppResourcePromise(this._withBuildScriptInternal(scriptName, args)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + private async _withRunScriptInternal(scriptName: string, args?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle, scriptName }; + if (args !== undefined) rpcArgs.args = args; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withRunScript', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { - const commandOptions = options?.commandOptions; - return new ContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise { + const args = options?.args; + return new NodeAppResourcePromise(this._withRunScriptInternal(scriptName, args)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withBrowserDebuggerInternal(browser?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (browser !== undefined) rpcArgs.browser = browser; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBrowserDebugger', rpcArgs ); - return new ContainerResource(result, this._client); + return new NodeAppResource(result, this._client); } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withParentRelationshipInternal(parent)); + + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NodeAppResourcePromise { + const browser = options?.browser; + return new NodeAppResourcePromise(this._withBrowserDebuggerInternal(browser)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', rpcArgs ); + return new NodeAppResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); } } /** - * Thenable wrapper for ContainerResource that enables fluent chaining. + * Thenable wrapper for NodeAppResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class ContainerResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class NodeAppResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: ContainerResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: NodeAppResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + withEnvironment(name: string, value: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); } /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + withEnvironmentExpression(name: string, value: ReferenceExpression): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ - withArgs(args: string[]): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); + withArgs(args: string[]): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + withServiceReference(source: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + withExternalHttpEndpoints(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ @@ -1989,1223 +16308,1400 @@ export class ContainerResourcePromise implements PromiseLike } /** Configures resource for HTTP/2 */ - asHttp2Service(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + asHttp2Service(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withContainerFilesSource(sourcePath))); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.clearContainerFilesSources())); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withNpm(options))); + } + + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withBun(options))); + } + + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withYarn(options))); + } + + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withPnpm(options))); + } + + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withBuildScript(scriptName, options))); + } + + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withRunScript(scriptName, options))); + } + + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withBrowserDebugger(options))); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// ParameterResource +// ============================================================================ + +export class ParameterResource extends ResourceBuilderBase { + constructor(handle: ParameterResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ParameterResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ParameterResourcePromise { + return new ParameterResourcePromise(this._withContainerRegistryInternal(registry)); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ParameterResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ParameterResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _withDescriptionInternal(description: string, enableMarkdown?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, description }; + if (enableMarkdown !== undefined) rpcArgs.enableMarkdown = enableMarkdown; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDescription', + rpcArgs + ); + return new ParameterResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Sets a parameter description */ + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { + const enableMarkdown = options?.enableMarkdown; + return new ParameterResourcePromise(this._withDescriptionInternal(description, enableMarkdown)); } -} - -// ============================================================================ -// DockerComposeEnvironmentResource -// ============================================================================ + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ParameterResource(result, this._client); + } -export class DockerComposeEnvironmentResource extends ResourceBuilderBase { - constructor(handle: DockerComposeEnvironmentResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { + const helpLink = options?.helpLink; + return new ParameterResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new DockerComposeEnvironmentResource(result, this._client); + return new ParameterResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new DockerComposeEnvironmentResource(result, this._client); + return new ParameterResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new DockerComposeEnvironmentResource(result, this._client); + return new ParameterResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): DockerComposeEnvironmentResourcePromise { + withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { const displayText = options?.displayText; - return new DockerComposeEnvironmentResourcePromise(this._withUrlInternal(url, displayText)); + return new ParameterResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new DockerComposeEnvironmentResource(result, this._client); + return new ParameterResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeEnvironmentResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { const displayText = options?.displayText; - return new DockerComposeEnvironmentResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ParameterResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; await callback(obj); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new DockerComposeEnvironmentResource(result, this._client); + return new ParameterResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _excludeFromManifestInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new DockerComposeEnvironmentResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new DockerComposeEnvironmentResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new DockerComposeEnvironmentResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeEnvironmentResourcePromise { - const commandOptions = options?.commandOptions; - return new DockerComposeEnvironmentResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new DockerComposeEnvironmentResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', rpcArgs ); + return new ParameterResource(result, this._client); } -} - -/** - * Thenable wrapper for DockerComposeEnvironmentResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class DockerComposeEnvironmentResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: DockerComposeEnvironmentResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): DockerComposeEnvironmentResourcePromise { - return new DockerComposeEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - -} - -// ============================================================================ -// ExecutableResource -// ============================================================================ - -export class ExecutableResource extends ResourceBuilderBase { - constructor(handle: ExecutableResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ParameterResourcePromise { + return new ParameterResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); + /** Prevents resource from starting automatically */ + withExplicitStart(): ParameterResourcePromise { + return new ParameterResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a health check by key */ + withHealthCheck(key: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + const commandOptions = options?.commandOptions; + return new ParameterResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { + return new ParameterResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Adds arguments */ - withArgs(args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsInternal(args)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ParameterResourcePromise { + return new ParameterResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsCallbackInternal(callback)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { + const iconVariant = options?.iconVariant; + return new ParameterResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ParameterResourcePromise { + return new ParameterResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new ExecutableResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ExecutableResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ParameterResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ExecutableResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); } - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', rpcArgs ); - return new ExecutableResource(result, this._client); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withExternalHttpEndpointsInternal()); +} + +/** + * Thenable wrapper for ParameterResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ParameterResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ParameterResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Sets a parameter description */ + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withDescription(description, options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._asHttp2ServiceInternal()); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Prevents resource from starting automatically */ + withExplicitStart(): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Adds a health check by key */ + withHealthCheck(key: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { - const displayText = options?.displayText; - return new ExecutableResourcePromise(this._withUrlInternal(url, displayText)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { - const displayText = options?.displayText; - return new ExecutableResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } - /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForInternal(dependency)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ExecutableResource(result, this._client); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withExplicitStartInternal()); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + +} + +// ============================================================================ +// PgAdminContainerResource +// ============================================================================ + +export class PgAdminContainerResource extends ResourceBuilderBase { + constructor(handle: PgAdminContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ExecutableResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ExecutableResourcePromise { - const exitCode = options?.exitCode; - return new ExecutableResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', rpcArgs ); - return new ExecutableResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withHealthCheckInternal(key)); + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PgAdminContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); } /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', rpcArgs ); - return new ExecutableResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new ExecutableResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEntrypointInternal(entrypoint)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', rpcArgs ); - return new ExecutableResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { - const commandOptions = options?.commandOptions; - return new ExecutableResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Sets the container image tag */ + withImageTag(tag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withImageTagInternal(tag)); } - /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', rpcArgs ); - return new ExecutableResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); + /** Sets the container image registry */ + withImageRegistry(registry: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withImageRegistryInternal(registry)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', rpcArgs ); + return new PgAdminContainerResource(result, this._client); } -} - -/** - * Thenable wrapper for ExecutableResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ExecutableResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ExecutableResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise { + const tag = options?.tag; + return new PgAdminContainerResourcePromise(this._withImageInternal(image, tag)); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withImageSHA256Internal(sha256)); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); } - /** Adds arguments */ - withArgs(args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgs(args))); + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withLifetimeInternal(lifetime)); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + /** Configures the resource to be published as a container */ + publishAsContainer(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._publishAsContainerInternal()); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgAdminContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PgAdminContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); + /** Sets the container name */ + withContainerName(name: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + /** @internal */ + private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withBuildArgInternal(name, value)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withBuildSecretInternal(name, value)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgAdminContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PgAdminContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); } - /** Adds a health check by key */ - withHealthCheck(key: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgAdminContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PgAdminContainerResourcePromise(this._withMcpServerInternal(path, endpointName)); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Configures OTLP telemetry export */ + withOtlpExporter(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withOtlpExporterInternal()); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } -} - -// ============================================================================ -// JavaScriptAppResource -// ============================================================================ - -export class JavaScriptAppResource extends ResourceBuilderBase { - constructor(handle: JavaScriptAppResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); } /** @internal */ - private async _withExecutableCommandInternal(command: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExecutableCommand', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } - /** Sets the executable command */ - withExecutableCommand(command: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withExecutableCommandInternal(command)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { - const rpcArgs: Record = { builder: this._handle, workingDirectory }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withWorkingDirectory', + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } - /** Sets the executable working directory */ - withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgAdminContainerResourcePromise { + const helpLink = options?.helpLink; + return new PgAdminContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { + private async _withEnvironmentInternal(name: string, value: string): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Sets an environment variable */ - withEnvironment(name: string, value: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentInternal(name, value)); + withEnvironment(name: string, value: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + withEnvironmentExpression(name: string, value: ReferenceExpression): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; const obj = new EnvironmentCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentCallbackAsync', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); } /** @internal */ - private async _withArgsInternal(args: string[]): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withArgs', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds arguments */ - withArgs(args: string[]): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withArgsInternal(args)); + withArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withArgsInternal(args)); } /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withArgsCallback', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withArgsCallbackInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; const arg = new CommandLineArgsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withArgsCallbackAsync', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): JavaScriptAppResourcePromise { + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgAdminContainerResourcePromise { const connectionName = options?.connectionName; const optional = options?.optional; - return new JavaScriptAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + return new PgAdminContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withServiceReference', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withServiceReferenceInternal(source)); + withServiceReference(source: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withServiceReferenceInternal(source)); } /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { const rpcArgs: Record = { builder: this._handle }; if (port !== undefined) rpcArgs.port = port; if (targetPort !== undefined) rpcArgs.targetPort = targetPort; @@ -3215,15 +17711,15 @@ export class JavaScriptAppResource extends ResourceBuilderBase( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withEndpoint', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise { + withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise { const port = options?.port; const targetPort = options?.targetPort; const scheme = options?.scheme; @@ -3232,72 +17728,72 @@ export class JavaScriptAppResource extends ResourceBuilderBase { + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { const rpcArgs: Record = { builder: this._handle }; if (port !== undefined) rpcArgs.port = port; if (targetPort !== undefined) rpcArgs.targetPort = targetPort; if (name !== undefined) rpcArgs.name = name; if (env !== undefined) rpcArgs.env = env; if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHttpEndpoint', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise { + withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise { const port = options?.port; const targetPort = options?.targetPort; const name = options?.name; const env = options?.env; const isProxied = options?.isProxied; - return new JavaScriptAppResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + return new PgAdminContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { const rpcArgs: Record = { builder: this._handle }; if (port !== undefined) rpcArgs.port = port; if (targetPort !== undefined) rpcArgs.targetPort = targetPort; if (name !== undefined) rpcArgs.name = name; if (env !== undefined) rpcArgs.env = env; if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHttpsEndpoint', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise { + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise { const port = options?.port; const targetPort = options?.targetPort; const name = options?.name; const env = options?.env; const isProxied = options?.isProxied; - return new JavaScriptAppResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + return new PgAdminContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { + private async _withExternalHttpEndpointsInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExternalHttpEndpoints', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withExternalHttpEndpointsInternal()); + withExternalHttpEndpoints(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withExternalHttpEndpointsInternal()); } /** Gets an endpoint reference */ @@ -3310,218 +17806,278 @@ export class JavaScriptAppResource extends ResourceBuilderBase { + private async _asHttp2ServiceInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/asHttp2Service', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Configures resource for HTTP/2 */ - asHttp2Service(): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._asHttp2ServiceInternal()); + asHttp2Service(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._asHttp2ServiceInternal()); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): JavaScriptAppResourcePromise { + withUrl(url: string, options?: WithUrlOptions): PgAdminContainerResourcePromise { const displayText = options?.displayText; - return new JavaScriptAppResourcePromise(this._withUrlInternal(url, displayText)); + return new PgAdminContainerResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): JavaScriptAppResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgAdminContainerResourcePromise { const displayText = options?.displayText; - return new JavaScriptAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new PgAdminContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; await callback(obj); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpointFactory', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/waitFor', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise { + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise { const exitCode = options?.exitCode; - return new JavaScriptAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new PgAdminContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { + private async _withHealthCheckInternal(key: string): Promise { const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withHealthCheckInternal(key)); + withHealthCheck(key: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; if (path !== undefined) rpcArgs.path = path; if (statusCode !== undefined) rpcArgs.statusCode = statusCode; if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHttpHealthCheck', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise { + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise { const path = options?.path; const statusCode = options?.statusCode; const endpointName = options?.endpointName; - return new JavaScriptAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + return new PgAdminContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -3529,1967 +18085,2054 @@ export class JavaScriptAppResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withCommand', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise { const commandOptions = options?.commandOptions; - return new JavaScriptAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new PgAdminContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgAdminContainerResourcePromise { + const password = options?.password; + return new PgAdminContainerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new JavaScriptAppResource(result, this._client); + return new PgAdminContainerResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withParentRelationshipInternal(parent)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', rpcArgs ); + return new PgAdminContainerResource(result, this._client); } -} + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withChildRelationshipInternal(child)); + } -/** - * Thenable wrapper for JavaScriptAppResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class JavaScriptAppResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } - then( - onfulfilled?: ((value: JavaScriptAppResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgAdminContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new PgAdminContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } - /** Sets the executable command */ - withExecutableCommand(command: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Sets the executable working directory */ - withWorkingDirectory(workingDirectory: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgAdminContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PgAdminContainerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._excludeFromMcpInternal()); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } - /** Adds arguments */ - withArgs(args: string[]): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgAdminContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PgAdminContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new PgAdminContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); } - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPgAdminHostPort', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + /** Sets the host port for pgAdmin */ + withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise { + const port = options?.port; + return new PgAdminContainerResourcePromise(this._withHostPortInternal(port)); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new PgAdminContainerResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } +} - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); +/** + * Thenable wrapper for PgAdminContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class PgAdminContainerResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PgAdminContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); } - /** Prevents resource from starting automatically */ - withExplicitStart(): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Sets the container image tag */ + withImageTag(tag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** Sets the container image registry */ + withImageRegistry(registry: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); } - /** Adds a health check by key */ - withHealthCheck(key: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); } -} + /** Configures the resource to be published as a container */ + publishAsContainer(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } -// ============================================================================ -// NodeAppResource -// ============================================================================ + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } -export class NodeAppResource extends ResourceBuilderBase { - constructor(handle: NodeAppResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Sets the container name */ + withContainerName(name: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** @internal */ - private async _withExecutableCommandInternal(command: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExecutableCommand', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } - /** Sets the executable command */ - withExecutableCommand(command: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withExecutableCommandInternal(command)); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } - /** @internal */ - private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { - const rpcArgs: Record = { builder: this._handle, workingDirectory }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withWorkingDirectory', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); } - /** Sets the executable working directory */ - withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); } - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Configures OTLP telemetry export */ + withOtlpExporter(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); } - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Adds arguments */ - withArgs(args: string[]): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withArgsInternal(args)); + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); } - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withArgsCallbackInternal(callback)); + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + /** Adds arguments */ + withArgs(args: string[]): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); } - /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): NodeAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new NodeAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } - /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withServiceReferenceInternal(source)); + withServiceReference(source: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); } - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new NodeAppResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); } - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new NodeAppResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new NodeAppResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); } - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withExternalHttpEndpointsInternal()); + withExternalHttpEndpoints(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); } - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Configures resource for HTTP/2 */ + asHttp2Service(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._asHttp2ServiceInternal()); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): NodeAppResourcePromise { - const displayText = options?.displayText; - return new NodeAppResourcePromise(this._withUrlInternal(url, displayText)); + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } - /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): NodeAppResourcePromise { - const displayText = options?.displayText; - return new NodeAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Prevents resource from starting automatically */ + withExplicitStart(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a health check by key */ + withHealthCheck(key: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); } - /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._waitForInternal(dependency)); + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } - /** Prevents resource from starting automatically */ - withExplicitStart(): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withExplicitStartInternal()); + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } - /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): NodeAppResourcePromise { - const exitCode = options?.exitCode; - return new NodeAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } - /** Adds a health check by key */ - withHealthCheck(key: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withHealthCheckInternal(key)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new NodeAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise { - const commandOptions = options?.commandOptions; - return new NodeAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } - /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } - /** @internal */ - private async _withNpmInternal(install?: boolean, installCommand?: string, installArgs?: string[]): Promise { - const rpcArgs: Record = { resource: this._handle }; - if (install !== undefined) rpcArgs.install = install; - if (installCommand !== undefined) rpcArgs.installCommand = installCommand; - if (installArgs !== undefined) rpcArgs.installArgs = installArgs; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.JavaScript/withNpm', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); } - /** Configures npm as the package manager */ - withNpm(options?: WithNpmOptions): NodeAppResourcePromise { - const install = options?.install; - const installCommand = options?.installCommand; - const installArgs = options?.installArgs; - return new NodeAppResourcePromise(this._withNpmInternal(install, installCommand, installArgs)); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); } - /** @internal */ - private async _withBuildScriptInternal(scriptName: string, args?: string[]): Promise { - const rpcArgs: Record = { resource: this._handle, scriptName }; - if (args !== undefined) rpcArgs.args = args; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.JavaScript/withBuildScript', - rpcArgs - ); - return new NodeAppResource(result, this._client); + /** Sets the host port for pgAdmin */ + withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHostPort(options))); } - /** Specifies an npm script to run before starting the application */ - withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise { - const args = options?.args; - return new NodeAppResourcePromise(this._withBuildScriptInternal(scriptName, args)); + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// PgWebContainerResource +// ============================================================================ + +export class PgWebContainerResource extends ResourceBuilderBase { + constructor(handle: PgWebContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); } /** @internal */ - private async _withRunScriptInternal(scriptName: string, args?: string[]): Promise { - const rpcArgs: Record = { resource: this._handle, scriptName }; - if (args !== undefined) rpcArgs.args = args; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.JavaScript/withRunScript', + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new NodeAppResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Specifies an npm script to run during development */ - withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise { - const args = options?.args; - return new NodeAppResourcePromise(this._withRunScriptInternal(scriptName, args)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withContainerRegistryInternal(registry)); } -} + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); + } -/** - * Thenable wrapper for NodeAppResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class NodeAppResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PgWebContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } - then( - onfulfilled?: ((value: NodeAppResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Sets the executable command */ - withExecutableCommand(command: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEntrypointInternal(entrypoint)); } - /** Sets the executable working directory */ - withWorkingDirectory(workingDirectory: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets the container image tag */ + withImageTag(tag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withImageTagInternal(tag)); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets the container image registry */ + withImageRegistry(registry: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withImageRegistryInternal(registry)); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds arguments */ - withArgs(args: string[]): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise { + const tag = options?.tag; + return new PgWebContainerResourcePromise(this._withImageInternal(image, tag)); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withImageSHA256Internal(sha256)); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withLifetimeInternal(lifetime)); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + /** Configures the resource to be published as a container */ + publishAsContainer(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._publishAsContainerInternal()); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgWebContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PgWebContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** Sets the container name */ + withContainerName(name: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** @internal */ + private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withBuildArgInternal(name, value)); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withBuildSecretInternal(name, value)); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgWebContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PgWebContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); } - /** Configures npm as the package manager */ - withNpm(options?: WithNpmOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withNpm(options))); + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Specifies an npm script to run before starting the application */ - withBuildScript(scriptName: string, options?: WithBuildScriptOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withBuildScript(scriptName, options))); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgWebContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PgWebContainerResourcePromise(this._withMcpServerInternal(path, endpointName)); } - /** Specifies an npm script to run during development */ - withRunScript(scriptName: string, options?: WithRunScriptOptions): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withRunScript(scriptName, options))); + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } -} - -// ============================================================================ -// ParameterResource -// ============================================================================ - -export class ParameterResource extends ResourceBuilderBase { - constructor(handle: ParameterResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Configures OTLP telemetry export */ + withOtlpExporter(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withOtlpExporterInternal()); } /** @internal */ - private async _withDescriptionInternal(description: string, enableMarkdown?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, description }; - if (enableMarkdown !== undefined) rpcArgs.enableMarkdown = enableMarkdown; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDescription', + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets a parameter description */ - withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { - const enableMarkdown = options?.enableMarkdown; - return new ParameterResourcePromise(this._withDescriptionInternal(description, enableMarkdown)); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgWebContainerResourcePromise { + const helpLink = options?.helpLink; + return new PgWebContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { - const displayText = options?.displayText; - return new ParameterResourcePromise(this._withUrlInternal(url, displayText)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { - const displayText = options?.displayText; - return new ParameterResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); await callback(obj); }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ParameterResourcePromise { - return new ParameterResourcePromise(this._withExplicitStartInternal()); + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withHealthCheckInternal(key)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { - const commandOptions = options?.commandOptions; - return new ParameterResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new ParameterResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { - return new ParameterResourcePromise(this._withParentRelationshipInternal(parent)); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', rpcArgs ); + return new PgWebContainerResource(result, this._client); } -} - -/** - * Thenable wrapper for ParameterResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ParameterResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ParameterResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Sets a parameter description */ - withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withDescription(description, options))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Adds arguments */ + withArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withArgsInternal(args)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withArgsCallbackInternal(callback)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgWebContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new PgWebContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withServiceReferenceInternal(source)); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); } -} + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } -// ============================================================================ -// PgAdminContainerResource -// ============================================================================ + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); + } -export class PgAdminContainerResource extends ResourceBuilderBase { - constructor(handle: PgAdminContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withReferenceUriInternal(name, uri)); } /** @internal */ - private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source, target }; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBindMount', + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise { - const isReadOnly = options?.isReadOnly; - return new PgAdminContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withEntrypointInternal(entrypoint: string): Promise { - const rpcArgs: Record = { builder: this._handle, entrypoint }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEntrypoint', + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ - private async _withImageTagInternal(tag: string): Promise { - const rpcArgs: Record = { builder: this._handle, tag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImageTag', + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the container image tag */ - withImageTag(tag: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withImageTagInternal(tag)); + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new PgWebContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); } /** @internal */ - private async _withImageRegistryInternal(registry: string): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImageRegistry', + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the container image registry */ - withImageRegistry(registry: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withImageRegistryInternal(registry)); + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PgWebContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withImageInternal(image: string, tag?: string): Promise { - const rpcArgs: Record = { builder: this._handle, image }; - if (tag !== undefined) rpcArgs.tag = tag; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImage', + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise { - const tag = options?.tag; - return new PgAdminContainerResourcePromise(this._withImageInternal(image, tag)); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PgWebContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withContainerRuntimeArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRuntimeArgs', + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); } /** @internal */ - private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { - const rpcArgs: Record = { builder: this._handle, lifetime }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withLifetime', + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withLifetimeInternal(lifetime)); + /** Configures resource for HTTP/2 */ + asHttp2Service(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._asHttp2ServiceInternal()); } /** @internal */ - private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { - const rpcArgs: Record = { builder: this._handle, pullPolicy }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImagePullPolicy', + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withContainerNameInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerName', + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - - /** Sets the container name */ - withContainerName(name: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withContainerNameInternal(name)); + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): PgWebContainerResourcePromise { + const displayText = options?.displayText; + return new PgWebContainerResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgWebContainerResourcePromise { + const displayText = options?.displayText; + return new PgWebContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; await callback(obj); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds arguments */ - withArgs(args: string[]): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withArgsInternal(args)); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withArgsCallbackInternal(callback)); + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgAdminContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new PgAdminContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withServiceReferenceInternal(source)); + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new PgAdminContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + /** Prevents resource from starting automatically */ + withExplicitStart(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new PgAdminContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgWebContainerResourcePromise { + const exitCode = options?.exitCode; + return new PgWebContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new PgAdminContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new PgWebContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); } /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', rpcArgs ); - return new PgAdminContainerResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + return new PgWebContainerResource(result, this._client); } - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new PgWebContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._asHttp2ServiceInternal()); + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withCertificateTrustScopeInternal(scope)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgWebContainerResourcePromise { + const password = options?.password; + return new PgWebContainerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PgAdminContainerResourcePromise { - const displayText = options?.displayText; - return new PgAdminContainerResourcePromise(this._withUrlInternal(url, displayText)); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withoutHttpsCertificateInternal()); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgAdminContainerResourcePromise { - const displayText = options?.displayText; - return new PgAdminContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgWebContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new PgWebContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._waitForInternal(dependency)); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgWebContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PgWebContainerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withExplicitStartInternal()); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise { - const exitCode = options?.exitCode; - return new PgAdminContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withHealthCheckInternal(key)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new PgAdminContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgWebContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PgWebContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise { - const commandOptions = options?.commandOptions; - return new PgAdminContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** @internal */ - private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { const rpcArgs: Record = { resource: this._handle, target }; if (name !== undefined) rpcArgs.name = name; if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withVolume', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise { + withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise { const name = options?.name; const isReadOnly = options?.isReadOnly; - return new PgAdminContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + return new PgWebContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); } /** Gets the resource name */ @@ -5502,918 +20145,928 @@ export class PgAdminContainerResource extends ResourceBuilderBase { + private async _withHostPortInternal(port?: number): Promise { const rpcArgs: Record = { builder: this._handle }; if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.PostgreSQL/withPgAdminHostPort', + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPgWebHostPort', + rpcArgs + ); + return new PgWebContainerResource(result, this._client); + } + + /** Sets the host port for pgweb */ + withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise { + const port = options?.port; + return new PgWebContainerResourcePromise(this._withHostPortInternal(port)); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', rpcArgs ); - return new PgAdminContainerResource(result, this._client); + return new PgWebContainerResource(result, this._client); } - /** Sets the host port for pgAdmin */ - withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise { - const port = options?.port; - return new PgAdminContainerResourcePromise(this._withHostPortInternal(port)); + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); } } /** - * Thenable wrapper for PgAdminContainerResource that enables fluent chaining. + * Thenable wrapper for PgWebContainerResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class PgAdminContainerResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class PgWebContainerResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: PgAdminContainerResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: PgWebContainerResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); } /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + withEntrypoint(entrypoint: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); } /** Sets the container image tag */ - withImageTag(tag: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + withImageTag(tag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); } /** Sets the container image registry */ - withImageRegistry(registry: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + withImageRegistry(registry: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); } /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); } /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); } /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); } /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); } - /** Sets the container name */ - withContainerName(name: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + /** Configures the resource to be published as a container */ + publishAsContainer(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Sets the container name */ + withContainerName(name: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } - /** Adds arguments */ - withArgs(args: string[]): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + /** Configures OTLP telemetry export */ + withOtlpExporter(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Adds arguments */ + withArgs(args: string[]): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); } - /** Adds a health check by key */ - withHealthCheck(key: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); } - /** Sets the host port for pgAdmin */ - withHostPort(options?: WithHostPortOptions): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withHostPort(options))); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); } -} + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } -// ============================================================================ -// PgWebContainerResource -// ============================================================================ + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } -export class PgWebContainerResource extends ResourceBuilderBase { - constructor(handle: PgWebContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Configures resource for HTTP/2 */ + asHttp2Service(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); } - /** @internal */ - private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source, target }; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBindMount', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise { - const isReadOnly = options?.isReadOnly; - return new PgWebContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** @internal */ - private async _withEntrypointInternal(entrypoint: string): Promise { - const rpcArgs: Record = { builder: this._handle, entrypoint }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEntrypoint', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } - /** @internal */ - private async _withImageTagInternal(tag: string): Promise { - const rpcArgs: Record = { builder: this._handle, tag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImageTag', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } - /** Sets the container image tag */ - withImageTag(tag: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withImageTagInternal(tag)); + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } - /** @internal */ - private async _withImageRegistryInternal(registry: string): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImageRegistry', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } - /** Sets the container image registry */ - withImageRegistry(registry: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withImageRegistryInternal(registry)); + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } - /** @internal */ - private async _withImageInternal(image: string, tag?: string): Promise { - const rpcArgs: Record = { builder: this._handle, image }; - if (tag !== undefined) rpcArgs.tag = tag; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImage', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise { - const tag = options?.tag; - return new PgWebContainerResourcePromise(this._withImageInternal(image, tag)); + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } - /** @internal */ - private async _withContainerRuntimeArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRuntimeArgs', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); + /** Prevents resource from starting automatically */ + withExplicitStart(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** @internal */ - private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { - const rpcArgs: Record = { builder: this._handle, lifetime }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withLifetime', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withLifetimeInternal(lifetime)); + /** Adds a health check by key */ + withHealthCheck(key: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } - /** @internal */ - private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { - const rpcArgs: Record = { builder: this._handle, pullPolicy }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImagePullPolicy', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); } - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** @internal */ - private async _withContainerNameInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerName', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } - /** Sets the container name */ - withContainerName(name: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withContainerNameInternal(name)); + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } - /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } - /** Adds arguments */ - withArgs(args: string[]): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withArgsInternal(args)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withArgsCallbackInternal(callback)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); } - /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); + /** Sets the host port for pgweb */ + withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHostPort(options))); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgWebContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new PgWebContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// PostgresDatabaseResource +// ============================================================================ + +export class PostgresDatabaseResource extends ResourceBuilderBase { + constructor(handle: PostgresDatabaseResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); - } + /** Gets the Parent property */ + parent = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.parent', + { context: this._handle } + ); + return new PostgresServerResource(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + + /** Gets the DatabaseName property */ + databaseName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.databaseName', + { context: this._handle } + ); + }, + }; + + /** Gets the UriExpression property */ + uriExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.uriExpression', + { context: this._handle } + ); + }, + }; - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withServiceReferenceInternal(source)); - } + /** Gets the JdbcConnectionString property */ + jdbcConnectionString = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.jdbcConnectionString', + { context: this._handle } + ); + }, + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.name', + { context: this._handle } + ); + }, + }; /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new PgWebContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new PgWebContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresDatabaseResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PostgresDatabaseResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new PgWebContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresDatabaseResourcePromise { + const helpLink = options?.helpLink; + return new PostgresDatabaseResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', rpcArgs ); - return new PgWebContainerResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + return new PostgresDatabaseResource(result, this._client); } - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withConnectionPropertyInternal(name, value)); } /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._asHttp2ServiceInternal()); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withConnectionPropertyValueInternal(name, value)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PgWebContainerResourcePromise { + withUrl(url: string, options?: WithUrlOptions): PostgresDatabaseResourcePromise { const displayText = options?.displayText; - return new PgWebContainerResourcePromise(this._withUrlInternal(url, displayText)); + return new PostgresDatabaseResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgWebContainerResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresDatabaseResourcePromise { const displayText = options?.displayText; - return new PgWebContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new PostgresDatabaseResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; await callback(obj); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PostgresDatabaseResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new PostgresDatabaseResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PostgresDatabaseResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new PostgresDatabaseResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise { + const commandOptions = options?.commandOptions; + return new PostgresDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._waitForInternal(dependency)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withExplicitStartInternal()); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresDatabaseResourcePromise { + const iconVariant = options?.iconVariant; + return new PostgresDatabaseResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgWebContainerResourcePromise { - const exitCode = options?.exitCode; - return new PgWebContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withHealthCheckInternal(key)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new PgWebContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise { - const commandOptions = options?.commandOptions; - return new PgWebContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresDatabaseResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PostgresDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { resource: this._handle, target }; - if (name !== undefined) rpcArgs.name = name; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withVolume', + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new PgWebContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -6426,1248 +21079,1476 @@ export class PgWebContainerResource extends ResourceBuilderBase { + private async _withPostgresMcpInternal(configureContainer?: (obj: PostgresMcpContainerResource) => Promise, containerName?: string): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PostgresMcpContainerResourceHandle; + const obj = new PostgresMcpContainerResource(objHandle, this._client); + await configureContainer(obj); + }) : undefined; const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.PostgreSQL/withPgWebHostPort', + if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; + if (containerName !== undefined) rpcArgs.containerName = containerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withPostgresMcp', rpcArgs ); - return new PgWebContainerResource(result, this._client); + return new PostgresDatabaseResource(result, this._client); } - /** Sets the host port for pgweb */ - withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise { - const port = options?.port; - return new PgWebContainerResourcePromise(this._withHostPortInternal(port)); + /** Adds Postgres MCP server */ + withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise { + const configureContainer = options?.configureContainer; + const containerName = options?.containerName; + return new PostgresDatabaseResourcePromise(this._withPostgresMcpInternal(configureContainer, containerName)); + } + + /** @internal */ + private async _withCreationScriptInternal(script: string): Promise { + const rpcArgs: Record = { builder: this._handle, script }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.PostgreSQL/withCreationScript', + rpcArgs + ); + return new PostgresDatabaseResource(result, this._client); + } + + /** Defines the SQL script for database creation */ + withCreationScript(script: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._withCreationScriptInternal(script)); } } /** - * Thenable wrapper for PgWebContainerResource that enables fluent chaining. + * Thenable wrapper for PostgresDatabaseResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class PgWebContainerResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class PostgresDatabaseResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: PgWebContainerResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: PostgresDatabaseResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** Sets the container image tag */ - withImageTag(tag: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets the container image registry */ - withImageRegistry(registry: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } - /** Sets the container name */ - withContainerName(name: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Adds Postgres MCP server */ + withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withPostgresMcp(options))); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Defines the SQL script for database creation */ + withCreationScript(script: string): PostgresDatabaseResourcePromise { + return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withCreationScript(script))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } +} - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); +// ============================================================================ +// PostgresMcpContainerResource +// ============================================================================ + +export class PostgresMcpContainerResource extends ResourceBuilderBase { + constructor(handle: PostgresMcpContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** Adds arguments */ - withArgs(args: string[]): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withContainerRegistryInternal(registry)); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresMcpContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new PostgresMcpContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + /** @internal */ + private async _withEntrypointInternal(entrypoint: string): Promise { + const rpcArgs: Record = { builder: this._handle, entrypoint }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEntrypoint', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEntrypointInternal(entrypoint)); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + /** @internal */ + private async _withImageTagInternal(tag: string): Promise { + const rpcArgs: Record = { builder: this._handle, tag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageTag', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + /** Sets the container image tag */ + withImageTag(tag: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withImageTagInternal(tag)); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + /** @internal */ + private async _withImageRegistryInternal(registry: string): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageRegistry', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); + /** Sets the container image registry */ + withImageRegistry(registry: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withImageRegistryInternal(registry)); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + /** @internal */ + private async _withImageInternal(image: string, tag?: string): Promise { + const rpcArgs: Record = { builder: this._handle, image }; + if (tag !== undefined) rpcArgs.tag = tag; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImage', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): PostgresMcpContainerResourcePromise { + const tag = options?.tag; + return new PostgresMcpContainerResourcePromise(this._withImageInternal(image, tag)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withImageSHA256Internal(sha256)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @internal */ + private async _withContainerRuntimeArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRuntimeArgs', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + /** @internal */ + private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { + const rpcArgs: Record = { builder: this._handle, lifetime }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withLifetimeInternal(lifetime)); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } - /** Adds a health check by key */ - withHealthCheck(key: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._publishAsContainerInternal()); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresMcpContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PostgresMcpContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Sets the container name */ + withContainerName(name: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Sets the host port for pgweb */ - withHostPort(options?: WithHostPortOptions): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withHostPort(options))); + /** @internal */ + private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } -} + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withBuildArgInternal(name, value)); + } -// ============================================================================ -// PostgresDatabaseResource -// ============================================================================ + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); + } -export class PostgresDatabaseResource extends ResourceBuilderBase { - constructor(handle: PostgresDatabaseResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withBuildSecretInternal(name, value)); } - /** Gets the Parent property */ - parent = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.parent', - { context: this._handle } - ); - return new PostgresServerResource(handle, this._client); - }, - }; + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); + } - /** Gets the DatabaseName property */ - databaseName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.databaseName', - { context: this._handle } - ); - }, - }; + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } - /** Gets the UriExpression property */ - uriExpression = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.uriExpression', - { context: this._handle } - ); - return new ReferenceExpression(handle, this._client); - }, - }; + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); + } - /** Gets the JdbcConnectionString property */ - jdbcConnectionString = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.jdbcConnectionString', - { context: this._handle } - ); - return new ReferenceExpression(handle, this._client); - }, - }; + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresMcpContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PostgresMcpContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } - /** Gets the Name property */ - name = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/PostgresDatabaseResource.name', - { context: this._handle } - ); - }, - }; + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresMcpContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PostgresMcpContainerResourcePromise(this._withMcpServerInternal(path, endpointName)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Configures OTLP telemetry export */ + withOtlpExporter(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withOtlpExporterInternal()); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PostgresDatabaseResourcePromise { - const displayText = options?.displayText; - return new PostgresDatabaseResourcePromise(this._withUrlInternal(url, displayText)); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresDatabaseResourcePromise { - const displayText = options?.displayText; - return new PostgresDatabaseResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresMcpContainerResourcePromise { + const helpLink = options?.helpLink; + return new PostgresMcpContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._withExplicitStartInternal()); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._withHealthCheckInternal(key)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise { - const commandOptions = options?.commandOptions; - return new PostgresDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); + return new PostgresMcpContainerResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withPostgresMcpInternal(configureContainer?: (obj: PostgresMcpContainerResource) => Promise, containerName?: string): Promise { - const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PostgresMcpContainerResourceHandle; - const obj = new PostgresMcpContainerResource(objHandle, this._client); - await configureContainer(obj); - }) : undefined; - const rpcArgs: Record = { builder: this._handle }; - if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; - if (containerName !== undefined) rpcArgs.containerName = containerName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.PostgreSQL/withPostgresMcp', + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds Postgres MCP server */ - withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise { - const configureContainer = options?.configureContainer; - const containerName = options?.containerName; - return new PostgresDatabaseResourcePromise(this._withPostgresMcpInternal(configureContainer, containerName)); + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withCreationScriptInternal(script: string): Promise { - const rpcArgs: Record = { builder: this._handle, script }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.PostgreSQL/withCreationScript', + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new PostgresDatabaseResource(result, this._client); + return new PostgresMcpContainerResource(result, this._client); } - /** Defines the SQL script for database creation */ - withCreationScript(script: string): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._withCreationScriptInternal(script)); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } -} - -/** - * Thenable wrapper for PostgresDatabaseResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class PostgresDatabaseResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: PostgresDatabaseResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Adds arguments */ + withArgs(args: string[]): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withArgsInternal(args)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withArgsCallbackInternal(callback)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (connectionName !== undefined) rpcArgs.connectionName = connectionName; + if (optional !== undefined) rpcArgs.optional = optional; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PostgresMcpContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new PostgresMcpContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withServiceReferenceInternal(source)); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } - /** Adds Postgres MCP server */ - withPostgresMcp(options?: WithPostgresMcpOptions): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withPostgresMcp(options))); + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); } - /** Defines the SQL script for database creation */ - withCreationScript(script: string): PostgresDatabaseResourcePromise { - return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withCreationScript(script))); + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); } -} - -// ============================================================================ -// PostgresMcpContainerResource -// ============================================================================ - -export class PostgresMcpContainerResource extends ResourceBuilderBase { - constructor(handle: PostgresMcpContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withReferenceUriInternal(name, uri)); } /** @internal */ - private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source, target }; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBindMount', + 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresMcpContainerResourcePromise { - const isReadOnly = options?.isReadOnly; - return new PostgresMcpContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withEntrypointInternal(entrypoint: string): Promise { - const rpcArgs: Record = { builder: this._handle, entrypoint }; + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEntrypoint', + 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ - private async _withImageTagInternal(tag: string): Promise { - const rpcArgs: Record = { builder: this._handle, tag }; + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImageTag', + 'Aspire.Hosting/withEndpoint', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the container image tag */ - withImageTag(tag: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withImageTagInternal(tag)); + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): PostgresMcpContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new PostgresMcpContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); } /** @internal */ - private async _withImageRegistryInternal(registry: string): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImageRegistry', + 'Aspire.Hosting/withHttpEndpoint', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the container image registry */ - withImageRegistry(registry: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withImageRegistryInternal(registry)); + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresMcpContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PostgresMcpContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withImageInternal(image: string, tag?: string): Promise { - const rpcArgs: Record = { builder: this._handle, image }; - if (tag !== undefined) rpcArgs.tag = tag; + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImage', + 'Aspire.Hosting/withHttpsEndpoint', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): PostgresMcpContainerResourcePromise { - const tag = options?.tag; - return new PostgresMcpContainerResourcePromise(this._withImageInternal(image, tag)); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresMcpContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new PostgresMcpContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withContainerRuntimeArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRuntimeArgs', + 'Aspire.Hosting/withExternalHttpEndpoints', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); } /** @internal */ - private async _withLifetimeInternal(lifetime: ContainerLifetime): Promise { - const rpcArgs: Record = { builder: this._handle, lifetime }; + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withLifetime', + 'Aspire.Hosting/asHttp2Service', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withLifetimeInternal(lifetime)); + /** Configures resource for HTTP/2 */ + asHttp2Service(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._asHttp2ServiceInternal()); } /** @internal */ - private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { - const rpcArgs: Record = { builder: this._handle, pullPolicy }; + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImagePullPolicy', + 'Aspire.Hosting/withUrlsCallback', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withContainerNameInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerName', + 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the container name */ - withContainerName(name: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withContainerNameInternal(name)); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withUrl', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): PostgresMcpContainerResourcePromise { + const displayText = options?.displayText; + return new PostgresMcpContainerResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + 'Aspire.Hosting/withUrlExpression', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresMcpContainerResourcePromise { + const displayText = options?.displayText; + return new PostgresMcpContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; await callback(obj); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withUrlForEndpointFactory', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', + 'Aspire.Hosting/excludeFromManifest', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds arguments */ - withArgs(args: string[]): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withArgsInternal(args)); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', + 'Aspire.Hosting/waitFor', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withArgsCallbackInternal(callback)); + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', + 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/waitForStart', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PostgresMcpContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new PostgresMcpContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', + 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withServiceReferenceInternal(source)); + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', + 'Aspire.Hosting/withExplicitStart', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): PostgresMcpContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new PostgresMcpContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): PostgresMcpContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new PostgresMcpContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise { + const exitCode = options?.exitCode; + return new PostgresMcpContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', + 'Aspire.Hosting/withHealthCheck', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): PostgresMcpContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new PostgresMcpContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', + 'Aspire.Hosting/withHttpHealthCheck', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new PostgresMcpContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); } - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', rpcArgs ); + return new PostgresMcpContainerResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new PostgresMcpContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', + 'Aspire.Hosting/withDeveloperCertificateTrust', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._asHttp2ServiceInternal()); + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + 'Aspire.Hosting/withCertificateTrustScope', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withCertificateTrustScopeInternal(scope)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresMcpContainerResourcePromise { + const password = options?.password; + return new PostgresMcpContainerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', + 'Aspire.Hosting/withoutHttpsCertificate', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PostgresMcpContainerResourcePromise { - const displayText = options?.displayText; - return new PostgresMcpContainerResourcePromise(this._withUrlInternal(url, displayText)); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withoutHttpsCertificateInternal()); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresMcpContainerResourcePromise { - const displayText = options?.displayText; - return new PostgresMcpContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', + 'Aspire.Hosting/withIconName', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresMcpContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new PostgresMcpContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/withHttpProbe', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._waitForInternal(dependency)); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresMcpContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PostgresMcpContainerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withExplicitStartInternal()); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/withRemoteImageName', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise { - const exitCode = options?.exitCode; - return new PostgresMcpContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withHealthCheckInternal(key)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new PostgresMcpContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresMcpContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PostgresMcpContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise { - const commandOptions = options?.commandOptions; - return new PostgresMcpContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -7698,6 +22579,29 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new PostgresMcpContainerResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + } /** @@ -7715,6 +22619,11 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + } + /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); @@ -7740,6 +22649,11 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.withImage(image, options))); } + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); @@ -7755,11 +22669,71 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.withImagePullPolicy(pullPolicy))); } + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + /** Sets the container name */ withContainerName(name: string): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Sets an environment variable */ withEnvironment(name: string, value: string): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); @@ -7780,6 +22754,21 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + /** Adds arguments */ withArgs(args: string[]): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); @@ -7805,6 +22794,26 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -7865,39 +22874,124 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.withUrlForEndpointFactory(endpointName, callback))); } + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Waits for another resource to be ready */ waitFor(dependency: ResourceBuilderBase): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Prevents resource from starting automatically */ withExplicitStart(): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } - /** Adds a health check by key */ - withHealthCheck(key: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Adds a volume */ @@ -7910,6 +23004,11 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.getResourceName()); } + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + } // ============================================================================ @@ -7935,11 +23034,20 @@ export class PostgresServerResource extends ResourceBuilderBase => { - const handle = await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/PostgresServerResource.userNameReference', { context: this._handle } ); - return new ReferenceExpression(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/PostgresServerResource.connectionStringExpression', + { context: this._handle } + ); }, }; @@ -7982,22 +23090,20 @@ export class PostgresServerResource extends ResourceBuilderBase => { - const handle = await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/PostgresServerResource.uriExpression', { context: this._handle } ); - return new ReferenceExpression(handle, this._client); }, }; /** Gets the JdbcConnectionString property */ jdbcConnectionString = { get: async (): Promise => { - const handle = await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/PostgresServerResource.jdbcConnectionString', { context: this._handle } ); - return new ReferenceExpression(handle, this._client); }, }; @@ -8043,6 +23149,21 @@ export class PostgresServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withContainerRegistryInternal(registry)); + } + /** @internal */ private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { const rpcArgs: Record = { builder: this._handle, source, target }; @@ -8122,6 +23243,21 @@ export class PostgresServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withImageSHA256Internal(sha256)); + } + /** @internal */ private async _withContainerRuntimeArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -8167,6 +23303,40 @@ export class PostgresServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._publishAsContainerInternal()); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresServerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new PostgresServerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); + } + /** @internal */ private async _withContainerNameInternal(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -8182,6 +23352,166 @@ export class PostgresServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withBuildSecretInternal(name, value)); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresServerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new PostgresServerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresServerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new PostgresServerResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresServerResourcePromise { + const helpLink = options?.helpLink; + return new PostgresServerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + /** @internal */ private async _withEnvironmentInternal(name: string, value: string): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; @@ -8252,6 +23582,81 @@ export class PostgresServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + /** @internal */ private async _withArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -8313,32 +23718,92 @@ export class PostgresServerResource extends ResourceBuilderBase( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReference', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PostgresServerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + return new PostgresServerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + } + + /** @internal */ + private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReference', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a service discovery reference to another resource */ + withServiceReference(source: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withServiceReferenceInternal(source)); + } + + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): PostgresServerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new PostgresServerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', + 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withServiceReferenceInternal(source)); + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -8506,192 +23971,488 @@ export class PostgresServerResource extends ResourceBuilderBase = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): PostgresServerResourcePromise { + const displayText = options?.displayText; + return new PostgresServerResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresServerResourcePromise { + const displayText = options?.displayText; + return new PostgresServerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitFor', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForCompletion', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PostgresServerResourcePromise { + const exitCode = options?.exitCode; + return new PostgresServerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresServerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new PostgresServerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresServerResourcePromise { + const commandOptions = options?.commandOptions; + return new PostgresServerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresServerResourcePromise { + const password = options?.password; + return new PostgresServerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): PostgresServerResourcePromise { - const displayText = options?.displayText; - return new PostgresServerResourcePromise(this._withUrlInternal(url, displayText)); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withoutHttpsCertificateInternal()); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): PostgresServerResourcePromise { - const displayText = options?.displayText; - return new PostgresServerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', + 'Aspire.Hosting/withIconName', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresServerResourcePromise { + const iconVariant = options?.iconVariant; + return new PostgresServerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/withHttpProbe', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._waitForInternal(dependency)); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresServerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new PostgresServerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withExplicitStartInternal()); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/withRemoteImageName', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): PostgresServerResourcePromise { - const exitCode = options?.exitCode; - return new PostgresServerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withHealthCheckInternal(key)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): PostgresServerResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new PostgresServerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresServerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new PostgresServerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): PostgresServerResourcePromise { - const commandOptions = options?.commandOptions; - return new PostgresServerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -8885,6 +24646,29 @@ export class PostgresServerResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new PostgresServerResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + } /** @@ -8902,6 +24686,11 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + } + /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); @@ -8927,6 +24716,11 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withImage(image, options))); } + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); @@ -8942,11 +24736,71 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withImagePullPolicy(pullPolicy))); } + /** Configures the resource to be published as a container */ + publishAsContainer(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + /** Sets the container name */ withContainerName(name: string): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Sets an environment variable */ withEnvironment(name: string, value: string): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); @@ -8967,6 +24821,31 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + /** Adds arguments */ withArgs(args: string[]): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withArgs(args))); @@ -8992,6 +24871,26 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -9052,11 +24951,31 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withUrlForEndpointFactory(endpointName, callback))); } + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Waits for another resource to be ready */ waitFor(dependency: ResourceBuilderBase): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Prevents resource from starting automatically */ withExplicitStart(): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); @@ -9082,11 +25001,76 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + /** Adds a volume */ withVolume(target: string, options?: WithVolumeOptions): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); @@ -9142,6 +25126,11 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withHostPort(options))); } + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + } // ============================================================================ @@ -9154,18 +25143,103 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReplicasInternal(replicas: number): Promise { - const rpcArgs: Record = { builder: this._handle, replicas }; + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ProjectResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ProjectResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ProjectResourcePromise { + return new ProjectResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { + return new ProjectResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReplicas', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets the number of replicas */ - withReplicas(replicas: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReplicasInternal(replicas)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ @@ -9238,6 +25312,51 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); } + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + /** @internal */ private async _withArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -9327,6 +25446,66 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); } + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + /** @internal */ private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -9560,6 +25739,36 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } + /** @internal */ + private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFiles', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ProjectResourcePromise { + return new ProjectResourcePromise(this._excludeFromManifestInternal()); + } + /** @internal */ private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; @@ -9575,6 +25784,51 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._waitForInternal(dependency)); } + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + /** @internal */ private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -9644,40 +25898,276 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + const commandOptions = options?.commandOptions; + return new ProjectResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { + return new ProjectResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { + return new ProjectResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { + const password = options?.password; + return new ProjectResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ProjectResourcePromise { + return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { + const iconVariant = options?.iconVariant; + return new ProjectResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ProjectResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ProjectResourcePromise { + return new ProjectResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { - const commandOptions = options?.commandOptions; - return new ProjectResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -9689,6 +26179,29 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + } /** @@ -9706,9 +26219,34 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Sets the number of replicas */ - withReplicas(replicas: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Sets an environment variable */ @@ -9731,6 +26269,21 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + /** Adds arguments */ withArgs(args: string[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgs(args))); @@ -9756,6 +26309,26 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -9816,11 +26389,36 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Waits for another resource to be ready */ waitFor(dependency: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Prevents resource from starting automatically */ withExplicitStart(): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withExplicitStart())); @@ -9846,16 +26444,86 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + } // ============================================================================ @@ -9867,6 +26535,21 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withContainerRegistryInternal(registry)); + } + /** @internal */ private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { const rpcArgs: Record = { builder: this._handle, source, target }; @@ -9946,6 +26629,21 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withImageSHA256Internal(sha256)); + } + /** @internal */ private async _withContainerRuntimeArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -9965,45 +26663,239 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, lifetime }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withLifetime', + 'Aspire.Hosting/withLifetime', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withLifetimeInternal(lifetime)); + } + + /** @internal */ + private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { + const rpcArgs: Record = { builder: this._handle, pullPolicy }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImagePullPolicy', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._publishAsContainerInternal()); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisCommanderResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new RedisCommanderResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); + } + + /** @internal */ + private async _withContainerNameInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerName', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the container name */ + withContainerName(name: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withContainerNameInternal(name)); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withBuildSecretInternal(name, value)); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisCommanderResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new RedisCommanderResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisCommanderResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new RedisCommanderResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withLifetimeInternal(lifetime)); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); } /** @internal */ - private async _withImagePullPolicyInternal(pullPolicy: ImagePullPolicy): Promise { - const rpcArgs: Record = { builder: this._handle, pullPolicy }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withImagePullPolicy', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withContainerNameInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerName', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets the container name */ - withContainerName(name: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withContainerNameInternal(name)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisCommanderResourcePromise { + const helpLink = options?.helpLink; + return new RedisCommanderResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ @@ -10076,6 +26968,51 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + /** @internal */ private async _withArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -10165,6 +27102,66 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + /** @internal */ private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -10398,6 +27395,21 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._excludeFromManifestInternal()); + } + /** @internal */ private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; @@ -10413,6 +27425,51 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + /** @internal */ private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -10504,18 +27561,254 @@ export class RedisCommanderResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, parent }; + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisCommanderResourcePromise { + const password = options?.password; + return new RedisCommanderResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisCommanderResourcePromise { + const iconVariant = options?.iconVariant; + return new RedisCommanderResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisCommanderResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new RedisCommanderResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisCommanderResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new RedisCommanderResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -10546,6 +27839,46 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisCommanderHostPort', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Sets the host port for Redis Commander */ + withHostPort(options?: WithHostPortOptions): RedisCommanderResourcePromise { + const port = options?.port; + return new RedisCommanderResourcePromise(this._withHostPortInternal(port)); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + } /** @@ -10563,6 +27896,11 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + } + /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); @@ -10588,6 +27926,11 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withImage(image, options))); } + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); @@ -10603,11 +27946,71 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withImagePullPolicy(pullPolicy))); } + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + /** Sets the container name */ withContainerName(name: string): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Sets an environment variable */ withEnvironment(name: string, value: string): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); @@ -10628,6 +28031,21 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + /** Adds arguments */ withArgs(args: string[]): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withArgs(args))); @@ -10653,6 +28071,26 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -10713,11 +28151,31 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withUrlForEndpointFactory(endpointName, callback))); } + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Waits for another resource to be ready */ waitFor(dependency: ResourceBuilderBase): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Prevents resource from starting automatically */ withExplicitStart(): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withExplicitStart())); @@ -10743,11 +28201,76 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + /** Adds a volume */ withVolume(target: string, options?: WithVolumeOptions): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); @@ -10758,6 +28281,16 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.getResourceName()); } + /** Sets the host port for Redis Commander */ + withHostPort(options?: WithHostPortOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withHostPort(options))); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + } // ============================================================================ @@ -10769,6 +28302,21 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withContainerRegistryInternal(registry)); + } + /** @internal */ private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { const rpcArgs: Record = { builder: this._handle, source, target }; @@ -10848,6 +28396,21 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withImageSHA256Internal(sha256)); + } + /** @internal */ private async _withContainerRuntimeArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -10893,6 +28456,40 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._publishAsContainerInternal()); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisInsightResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new RedisInsightResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); + } + /** @internal */ private async _withContainerNameInternal(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -10903,9 +28500,169 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withBuildSecretInternal(name, value)); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisInsightResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new RedisInsightResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisInsightResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new RedisInsightResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisInsightResourcePromise { + const helpLink = options?.helpLink; + return new RedisInsightResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ @@ -10978,6 +28735,51 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + /** @internal */ private async _withArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -11067,6 +28869,66 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + /** @internal */ private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -11300,6 +29162,21 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._excludeFromManifestInternal()); + } + /** @internal */ private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; @@ -11315,6 +29192,51 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + /** @internal */ private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -11369,55 +29291,291 @@ export class RedisInsightResource extends ResourceBuilderBase( - 'Aspire.Hosting/withHttpHealthCheck', + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisInsightResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new RedisInsightResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisInsightResourcePromise { + const commandOptions = options?.commandOptions; + return new RedisInsightResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisInsightResourcePromise { + const password = options?.password; + return new RedisInsightResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisInsightResourcePromise { + const iconVariant = options?.iconVariant; + return new RedisInsightResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisInsightResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new RedisInsightResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): RedisInsightResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new RedisInsightResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisInsightResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new RedisInsightResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisInsightResourcePromise { - const commandOptions = options?.commandOptions; - return new RedisInsightResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -11448,6 +29606,78 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisInsightHostPort', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Sets the host port for Redis Insight */ + withHostPort(options?: WithHostPortOptions): RedisInsightResourcePromise { + const port = options?.port; + return new RedisInsightResourcePromise(this._withHostPortInternal(port)); + } + + /** @internal */ + private async _withDataVolumeInternal(name?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisInsightDataVolume', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a data volume for Redis Insight */ + withDataVolume(options?: WithDataVolumeOptions): RedisInsightResourcePromise { + const name = options?.name; + return new RedisInsightResourcePromise(this._withDataVolumeInternal(name)); + } + + /** @internal */ + private async _withDataBindMountInternal(source: string): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withRedisInsightDataBindMount', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a data bind mount for Redis Insight */ + withDataBindMount(source: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withDataBindMountInternal(source)); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + } /** @@ -11465,6 +29695,11 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + } + /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); @@ -11490,6 +29725,11 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withImage(image, options))); } + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); @@ -11505,11 +29745,71 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withImagePullPolicy(pullPolicy))); } + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + /** Sets the container name */ withContainerName(name: string): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Sets an environment variable */ withEnvironment(name: string, value: string): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); @@ -11530,6 +29830,21 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + /** Adds arguments */ withArgs(args: string[]): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withArgs(args))); @@ -11555,6 +29870,26 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -11615,11 +29950,31 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withUrlForEndpointFactory(endpointName, callback))); } + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Waits for another resource to be ready */ waitFor(dependency: ResourceBuilderBase): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Prevents resource from starting automatically */ withExplicitStart(): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withExplicitStart())); @@ -11645,30 +30000,241 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Sets the host port for Redis Insight */ + withHostPort(options?: WithHostPortOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withHostPort(options))); + } + + /** Adds a data volume for Redis Insight */ + withDataVolume(options?: WithDataVolumeOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); + } + + /** Adds a data bind mount for Redis Insight */ + withDataBindMount(source: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withDataBindMount(source))); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// RedisResource +// ============================================================================ + +export class RedisResource extends ResourceBuilderBase { + constructor(handle: RedisResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** Gets the PrimaryEndpoint property */ + primaryEndpoint = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.primaryEndpoint', + { context: this._handle } + ); + return new EndpointReference(handle, this._client); + }, + }; + + /** Gets the Host property */ + host = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.host', + { context: this._handle } + ); + return new EndpointReferenceExpression(handle, this._client); + }, + }; + + /** Gets the Port property */ + port = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.port', + { context: this._handle } + ); + return new EndpointReferenceExpression(handle, this._client); + }, + }; + + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.tlsEnabled', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.setTlsEnabled', + { context: this._handle, value } + ); + } + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + + /** Gets the UriExpression property */ + uriExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.uriExpression', + { context: this._handle } + ); + }, + }; + + /** Gets the Entrypoint property */ + entrypoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.entrypoint', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.setEntrypoint', + { context: this._handle, value } + ); + } + }; + + /** Gets the ShellExecution property */ + shellExecution = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.shellExecution', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.setShellExecution', + { context: this._handle, value } + ); + } + }; - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); - } + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.name', + { context: this._handle } + ); + }, + }; - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new RedisResource(result, this._client); } -} - -// ============================================================================ -// RedisResource -// ============================================================================ - -export class RedisResource extends ResourceBuilderBase { - constructor(handle: RedisResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -11750,6 +30316,21 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withImageInternal(image, tag)); } + /** @internal */ + private async _withImageSHA256Internal(sha256: string): Promise { + const rpcArgs: Record = { builder: this._handle, sha256 }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withImageSHA256', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisResourcePromise { + return new RedisResourcePromise(this._withImageSHA256Internal(sha256)); + } + /** @internal */ private async _withContainerRuntimeArgsInternal(args: string[]): Promise { const rpcArgs: Record = { builder: this._handle, args }; @@ -11795,6 +30376,40 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisResourcePromise { + return new RedisResourcePromise(this._publishAsContainerInternal()); + } + + /** @internal */ + private async _withDockerfileInternal(contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfile', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new RedisResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); + } + /** @internal */ private async _withContainerNameInternal(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -11811,73 +30426,308 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildSecret', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._withBuildSecretInternal(name, value)); + } + + /** @internal */ + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpointProxySupport', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise { + return new RedisResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new RedisResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisResourcePromise { + return new RedisResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new RedisResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): RedisResourcePromise { + return new RedisResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): RedisResourcePromise { + return new RedisResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisResourcePromise { + return new RedisResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisResourcePromise { + const helpLink = options?.helpLink; + return new RedisResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets an environment variable */ + withEnvironment(name: string, value: string): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentExpression', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); return new RedisResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withConnectionProperty', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): RedisResourcePromise { + return new RedisResourcePromise(this._withConnectionPropertyInternal(name, value)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withConnectionPropertyValue', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): RedisResourcePromise { + return new RedisResourcePromise(this._withConnectionPropertyValueInternal(name, value)); } /** @internal */ @@ -11969,6 +30819,66 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withServiceReferenceInternal(source)); } + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisResourcePromise { + return new RedisResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): RedisResourcePromise { + return new RedisResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): RedisResourcePromise { + return new RedisResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): RedisResourcePromise { + return new RedisResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + /** @internal */ private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -12202,6 +31112,21 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisResourcePromise { + return new RedisResourcePromise(this._excludeFromManifestInternal()); + } + /** @internal */ private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; @@ -12217,6 +31142,51 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._waitForInternal(dependency)); } + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisResourcePromise { + return new RedisResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisResourcePromise { + return new RedisResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + /** @internal */ private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -12292,34 +31262,270 @@ export class RedisResource extends ResourceBuilderBase { const arg = new ExecuteCommandContext(argHandle, this._client); return await executeCommand(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisResourcePromise { + const commandOptions = options?.commandOptions; + return new RedisResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisResourcePromise { + return new RedisResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisResourcePromise { + return new RedisResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisResourcePromise { + const password = options?.password; + return new RedisResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisResourcePromise { + return new RedisResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisResourcePromise { + const iconVariant = options?.iconVariant; + return new RedisResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new RedisResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisResourcePromise { + return new RedisResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisResourcePromise { + return new RedisResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisResourcePromise { + return new RedisResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new RedisResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new RedisResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): RedisResourcePromise { - const commandOptions = options?.commandOptions; - return new RedisResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): RedisResourcePromise { - return new RedisResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -12453,6 +31659,21 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withPersistenceInternal(interval, keysChangedThreshold)); } + /** @internal */ + private async _withPasswordInternal(password: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, password }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/withPassword', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Configures the password for Redis */ + withPassword(password: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._withPasswordInternal(password)); + } + /** @internal */ private async _withHostPortInternal(port?: number): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -12470,6 +31691,29 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withHostPortInternal(port)); } + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + } /** @@ -12487,6 +31731,11 @@ export class RedisResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); @@ -12512,6 +31761,11 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withImage(image, options))); } + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); @@ -12527,11 +31781,71 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); } + /** Configures the resource to be published as a container */ + publishAsContainer(): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + /** Sets the container name */ withContainerName(name: string): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Sets an environment variable */ withEnvironment(name: string, value: string): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); @@ -12552,6 +31866,31 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + /** Adds arguments */ withArgs(args: string[]): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withArgs(args))); @@ -12577,6 +31916,26 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -12637,11 +31996,31 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Waits for another resource to be ready */ waitFor(dependency: ResourceBuilderBase): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Prevents resource from starting automatically */ withExplicitStart(): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withExplicitStart())); @@ -12667,11 +32046,76 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + /** Adds a volume */ withVolume(target: string, options?: WithVolumeOptions): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); @@ -12707,11 +32151,21 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withPersistence(options))); } + /** Configures the password for Redis */ + withPassword(password: ParameterResource): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withPassword(password))); + } + /** Sets the host port for Redis */ withHostPort(options?: WithHostPortOptions): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withHostPort(options))); } + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + } // ============================================================================ @@ -12723,6 +32177,105 @@ export class ViteAppResource extends ResourceBuilderBase super(handle, client); } + /** Gets the Command property */ + command = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.command', + { context: this._handle } + ); + }, + }; + + /** Gets the WorkingDirectory property */ + workingDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.workingDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/JavaScriptAppResource.name', + { context: this._handle } + ); + }, + }; + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ViteAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ViteAppResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _publishAsDockerFileInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + /** @internal */ private async _withExecutableCommandInternal(command: string): Promise { const rpcArgs: Record = { builder: this._handle, command }; @@ -12753,6 +32306,72 @@ export class ViteAppResource extends ResourceBuilderBase return new ViteAppResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); } + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ViteAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ViteAppResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ViteAppResourcePromise { + const helpLink = options?.helpLink; + return new ViteAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + /** @internal */ private async _withEnvironmentInternal(name: string, value: string): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; @@ -12812,15 +32431,60 @@ export class ViteAppResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallbackAsync', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets environment variables via async callback */ + withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); return new ViteAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -12912,6 +32576,66 @@ export class ViteAppResource extends ResourceBuilderBase return new ViteAppResourcePromise(this._withServiceReferenceInternal(source)); } + /** @internal */ + private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + /** @internal */ private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -13145,6 +32869,51 @@ export class ViteAppResource extends ResourceBuilderBase return new ViteAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withContainerFilesSourceInternal(sourcePath)); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._clearContainerFilesSourcesInternal()); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._excludeFromManifestInternal()); + } + /** @internal */ private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; @@ -13160,6 +32929,51 @@ export class ViteAppResource extends ResourceBuilderBase return new ViteAppResourcePromise(this._waitForInternal(dependency)); } + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + /** @internal */ private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -13214,55 +33028,291 @@ export class ViteAppResource extends ResourceBuilderBase if (statusCode !== undefined) rpcArgs.statusCode = statusCode; if (endpointName !== undefined) rpcArgs.endpointName = endpointName; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ViteAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise { + const commandOptions = options?.commandOptions; + return new ViteAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ViteAppResourcePromise { + const password = options?.password; + return new ViteAppResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParentRelationship', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ViteAppResourcePromise { + const iconVariant = options?.iconVariant; + return new ViteAppResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ViteAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ViteAppResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new ViteAppResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new ViteAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ViteAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ViteAppResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new ViteAppResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise { - const commandOptions = options?.commandOptions; - return new ViteAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); return new ViteAppResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._withParentRelationshipInternal(parent)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -13274,6 +33324,21 @@ export class ViteAppResource extends ResourceBuilderBase ); } + /** @internal */ + private async _withViteConfigInternal(configPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, configPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withViteConfig', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures a custom Vite configuration file */ + withViteConfig(configPath: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withViteConfigInternal(configPath)); + } + /** @internal */ private async _withNpmInternal(install?: boolean, installCommand?: string, installArgs?: string[]): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -13295,6 +33360,63 @@ export class ViteAppResource extends ResourceBuilderBase return new ViteAppResourcePromise(this._withNpmInternal(install, installCommand, installArgs)); } + /** @internal */ + private async _withBunInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBun', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): ViteAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new ViteAppResourcePromise(this._withBunInternal(install, installArgs)); + } + + /** @internal */ + private async _withYarnInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withYarn', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): ViteAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new ViteAppResourcePromise(this._withYarnInternal(install, installArgs)); + } + + /** @internal */ + private async _withPnpmInternal(install?: boolean, installArgs?: string[]): Promise { + const rpcArgs: Record = { resource: this._handle }; + if (install !== undefined) rpcArgs.install = install; + if (installArgs !== undefined) rpcArgs.installArgs = installArgs; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withPnpm', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): ViteAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new ViteAppResourcePromise(this._withPnpmInternal(install, installArgs)); + } + /** @internal */ private async _withBuildScriptInternal(scriptName: string, args?: string[]): Promise { const rpcArgs: Record = { resource: this._handle, scriptName }; @@ -13329,6 +33451,46 @@ export class ViteAppResource extends ResourceBuilderBase return new ViteAppResourcePromise(this._withRunScriptInternal(scriptName, args)); } + /** @internal */ + private async _withBrowserDebuggerInternal(browser?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (browser !== undefined) rpcArgs.browser = browser; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.JavaScript/withBrowserDebugger', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): ViteAppResourcePromise { + const browser = options?.browser; + return new ViteAppResourcePromise(this._withBrowserDebuggerInternal(browser)); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + } /** @@ -13346,6 +33508,26 @@ export class ViteAppResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + /** Sets the executable command */ withExecutableCommand(command: string): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); @@ -13356,6 +33538,26 @@ export class ViteAppResourcePromise implements PromiseLike { return new ViteAppResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); } + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Sets an environment variable */ withEnvironment(name: string, value: string): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); @@ -13376,6 +33578,21 @@ export class ViteAppResourcePromise implements PromiseLike { return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + /** Adds arguments */ withArgs(args: string[]): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); @@ -13401,6 +33618,26 @@ export class ViteAppResourcePromise implements PromiseLike { return new ViteAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -13461,59 +33698,288 @@ export class ViteAppResourcePromise implements PromiseLike { return new ViteAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withContainerFilesSource(sourcePath))); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.clearContainerFilesSources())); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Waits for another resource to be ready */ waitFor(dependency: ResourceBuilderBase): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Prevents resource from starting automatically */ withExplicitStart(): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Configures a custom Vite configuration file */ + withViteConfig(configPath: string): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withViteConfig(configPath))); + } + + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withNpm(options))); + } + + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withBun(options))); + } + + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withYarn(options))); + } + + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withPnpm(options))); + } + + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withBuildScript(scriptName, options))); + } + + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withRunScript(scriptName, options))); + } + + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withBrowserDebugger(options))); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); + } + +} + +// ============================================================================ +// ComputeResource +// ============================================================================ + +export class ComputeResource extends ResourceBuilderBase { + constructor(handle: IComputeResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _publishAsDockerComposeServiceInternal(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): Promise { + const configureId = registerCallback(async (argsData: unknown) => { + const args = argsData as { p0: unknown, p1: unknown }; + const arg1Handle = wrapIfHandle(args.p0) as DockerComposeServiceResourceHandle; + const arg1 = new DockerComposeServiceResource(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(args.p1) as ServiceHandle; + const arg2 = new Service(arg2Handle, this._client); + await configure(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Docker/publishAsDockerComposeService', + rpcArgs + ); + return new ComputeResource(result, this._client); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ComputeResourcePromise { + return new ComputeResourcePromise(this._publishAsDockerComposeServiceInternal(configure)); + } + +} + +/** + * Thenable wrapper for ComputeResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ComputeResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ComputeResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Publishes the resource as a Docker Compose service with custom service configuration */ + publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.publishAsDockerComposeService(configure))); } - /** Adds a health check by key */ - withHealthCheck(key: string): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } +} - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } +// ============================================================================ +// ContainerFilesDestinationResource +// ============================================================================ - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); +export class ContainerFilesDestinationResource extends ResourceBuilderBase { + constructor(handle: IContainerFilesDestinationResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFiles', + rpcArgs + ); + return new ContainerFilesDestinationResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); } - /** Configures npm as the package manager */ - withNpm(options?: WithNpmOptions): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withNpm(options))); - } +} - /** Specifies an npm script to run before starting the application */ - withBuildScript(scriptName: string, options?: WithBuildScriptOptions): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withBuildScript(scriptName, options))); +/** + * Thenable wrapper for ContainerFilesDestinationResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ContainerFilesDestinationResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ContainerFilesDestinationResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Specifies an npm script to run during development */ - withRunScript(scriptName: string, options?: WithRunScriptOptions): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withRunScript(scriptName, options))); + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); } } @@ -13527,6 +33993,57 @@ export class Resource extends ResourceBuilderBase { super(handle, client); } + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ResourcePromise { + return new ResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { + const helpLink = options?.helpLink; + return new ResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -13620,6 +34137,21 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ResourcePromise { + return new ResourcePromise(this._excludeFromManifestInternal()); + } + /** @internal */ private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -13687,6 +34219,151 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withParentRelationshipInternal(parent)); } + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withChildRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ResourcePromise { + return new ResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { + const iconVariant = options?.iconVariant; + return new ResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ResourcePromise { + return new ResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ResourcePromise { + return new ResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ResourcePromise { + return new ResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -13713,6 +34390,21 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -13738,6 +34430,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + /** Prevents resource from starting automatically */ withExplicitStart(): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withExplicitStart())); @@ -13758,6 +34455,46 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); @@ -13839,56 +34576,164 @@ export class ResourceWithArgs extends ResourceBuilderBase { constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: ResourceWithArgs) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ResourceWithArgs) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Adds arguments */ + withArgs(args: string[]): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + +} + +// ============================================================================ +// ResourceWithConnectionString +// ============================================================================ + +export class ResourceWithConnectionString extends ResourceBuilderBase { + constructor(handle: IResourceWithConnectionStringHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._withConnectionPropertyValueInternal(name, value)); + } + +} + +/** + * Thenable wrapper for ResourceWithConnectionString that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourceWithConnectionStringPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceWithConnectionString) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Adds arguments */ - withArgs(args: string[]): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallback(callback))); + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } } // ============================================================================ -// ResourceWithConnectionString +// ResourceWithContainerFiles // ============================================================================ -export class ResourceWithConnectionString extends ResourceBuilderBase { - constructor(handle: IResourceWithConnectionStringHandle, client: AspireClientRpc) { +export class ResourceWithContainerFiles extends ResourceBuilderBase { + constructor(handle: IResourceWithContainerFilesHandle, client: AspireClientRpc) { super(handle, client); } + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new ResourceWithContainerFiles(result, this._client); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._withContainerFilesSourceInternal(sourcePath)); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new ResourceWithContainerFiles(result, this._client); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._clearContainerFilesSourcesInternal()); + } + } /** - * Thenable wrapper for ResourceWithConnectionString that enables fluent chaining. + * Thenable wrapper for ResourceWithContainerFiles that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class ResourceWithConnectionStringPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ResourceWithContainerFilesPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: ResourceWithConnectionString) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ResourceWithContainerFiles) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._promise.then(obj => obj.withContainerFilesSource(sourcePath))); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._promise.then(obj => obj.clearContainerFilesSources())); + } + } // ============================================================================ @@ -13900,6 +34745,25 @@ export class ResourceWithEndpoints extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromise(this._withMcpServerInternal(path, endpointName)); + } + /** @internal */ private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -14061,6 +34925,35 @@ export class ResourceWithEndpoints extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + } /** @@ -14078,6 +34971,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withMcpServer(options))); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -14118,6 +35016,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpHealthCheck(options))); } + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + } // ============================================================================ @@ -14129,6 +35032,36 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withOtlpExporterProtocolInternal(protocol)); + } + /** @internal */ private async _withEnvironmentInternal(name: string, value: string): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; @@ -14199,6 +35132,51 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -14233,6 +35211,128 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, source, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withServiceReferenceNamed', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsDeveloperCertificate', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { + const password = options?.password; + return new ResourceWithEnvironmentPromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withoutHttpsCertificateInternal()); + } + } /** @@ -14250,6 +35350,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + /** Sets an environment variable */ withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); @@ -14270,6 +35380,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentCallbackAsync(callback))); } + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); @@ -14280,6 +35405,46 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withServiceReference(source))); } + /** Adds a named service discovery reference */ + withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + } // ============================================================================ @@ -14334,6 +35499,51 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStart', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + /** @internal */ private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; @@ -14373,6 +35583,21 @@ export class ResourceWithWaitSupportPromise implements PromiseLike obj.waitFor(dependency))); } + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + /** Waits for resource completion */ waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); @@ -14493,12 +35718,25 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointRe registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.Docker/Aspire.Hosting.Docker.Resources.ComposeNodes.Service', (handle, client) => new Service(handle as ServiceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ConnectionStringResource', (handle, client) => new ConnectionStringResource(handle as ConnectionStringResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource', (handle, client) => new ContainerRegistryResource(handle as ContainerRegistryResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource', (handle, client) => new ContainerResource(handle as ContainerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource', (handle, client) => new CSharpAppResource(handle as CSharpAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Docker/Aspire.Hosting.Docker.DockerComposeAspireDashboardResource', (handle, client) => new DockerComposeAspireDashboardResource(handle as DockerComposeAspireDashboardResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Docker/Aspire.Hosting.Docker.DockerComposeEnvironmentResource', (handle, client) => new DockerComposeEnvironmentResource(handle as DockerComposeEnvironmentResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Docker/Aspire.Hosting.Docker.DockerComposeServiceResource', (handle, client) => new DockerComposeServiceResource(handle as DockerComposeServiceResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource', (handle, client) => new DotnetToolResource(handle as DotnetToolResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource', (handle, client) => new ExecutableResource(handle as ExecutableResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ExternalServiceResource', (handle, client) => new ExternalServiceResource(handle as ExternalServiceResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.JavaScriptAppResource', (handle, client) => new JavaScriptAppResource(handle as JavaScriptAppResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.NodeAppResource', (handle, client) => new NodeAppResource(handle as NodeAppResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource', (handle, client) => new ParameterResource(handle as ParameterResourceHandle, client)); @@ -14512,9 +35750,12 @@ registerHandleWrapper('Aspire.Hosting.Redis/Aspire.Hosting.Redis.RedisCommanderR registerHandleWrapper('Aspire.Hosting.Redis/Aspire.Hosting.Redis.RedisInsightResource', (handle, client) => new RedisInsightResource(handle as RedisInsightResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Redis/Aspire.Hosting.ApplicationModel.RedisResource', (handle, client) => new RedisResource(handle as RedisResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.ViteAppResource', (handle, client) => new ViteAppResource(handle as ViteAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource', (handle, client) => new ComputeResource(handle as IComputeResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource', (handle, client) => new ContainerFilesDestinationResource(handle as IContainerFilesDestinationResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new Resource(handle as IResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs', (handle, client) => new ResourceWithArgs(handle as IResourceWithArgsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionString(handle as IResourceWithConnectionStringHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); diff --git a/src/Aspire.Cli/Backchannel/ExtensionBackchannel.cs b/src/Aspire.Cli/Backchannel/ExtensionBackchannel.cs index aaff055ca94..a5be56fc731 100644 --- a/src/Aspire.Cli/Backchannel/ExtensionBackchannel.cs +++ b/src/Aspire.Cli/Backchannel/ExtensionBackchannel.cs @@ -661,7 +661,7 @@ public async Task LaunchAppHostAsync(string projectFile, List arguments, var rpc = await _rpcTaskCompletionSource.Task; - _logger.LogDebug("Running .NET project at {ProjectFile} with arguments: {Arguments}", projectFile, string.Join(" ", arguments)); + _logger.LogDebug("Running project at {ProjectFile} with arguments: {Arguments}", projectFile, string.Join(" ", arguments)); await rpc.InvokeWithCancellationAsync( "launchAppHost", diff --git a/src/Aspire.Cli/Commands/RunCommand.cs b/src/Aspire.Cli/Commands/RunCommand.cs index a5e44f03f02..c8a02f12456 100644 --- a/src/Aspire.Cli/Commands/RunCommand.cs +++ b/src/Aspire.Cli/Commands/RunCommand.cs @@ -393,6 +393,12 @@ await InteractionService.DisplayLiveAsync(BuildLiveRenderable(), async updateTar InteractionService.DisplayMessage(KnownEmojis.PageFacingUp, string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.SeeLogsAt, ExecutionContext.LogFilePath)); return ExitCodeConstants.FailedToDotnetRunAppHost; } + catch (ConnectionLostException) when (isExtensionHost) + { + // When the extension manages the AppHost lifecycle (e.g., VS Code debug session), + // it terminates the process on stop/restart, causing the backchannel to drop. + return ExitCodeConstants.Success; + } catch (Exception ex) { var errorMessage = string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.UnexpectedErrorOccurred, ex.Message); diff --git a/src/Aspire.Cli/Projects/ExtensionGuestLauncher.cs b/src/Aspire.Cli/Projects/ExtensionGuestLauncher.cs new file mode 100644 index 00000000000..c76f4d4c140 --- /dev/null +++ b/src/Aspire.Cli/Projects/ExtensionGuestLauncher.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Cli.Backchannel; +using Aspire.Cli.Interaction; +using Aspire.Cli.Utils; + +namespace Aspire.Cli.Projects; + +/// +/// Launches a guest language process by delegating to the VS Code extension debug session. +/// +internal sealed class ExtensionGuestLauncher : IGuestProcessLauncher +{ + private readonly IExtensionInteractionService _extensionInteractionService; + private readonly FileInfo _appHostFile; + private readonly bool _debug; + + public ExtensionGuestLauncher( + IExtensionInteractionService extensionInteractionService, + FileInfo appHostFile, + bool debug) + { + _extensionInteractionService = extensionInteractionService; + _appHostFile = appHostFile; + _debug = debug; + } + + public async Task<(int ExitCode, OutputCollector? Output)> LaunchAsync( + string command, + string[] args, + DirectoryInfo workingDirectory, + IDictionary environmentVariables, + CancellationToken cancellationToken) + { + // Prepend the runtime command (e.g., "npx") as the first argument so the + // extension can extract it as the runtimeExecutable for the debug session. + var allArgs = new List { command }; + allArgs.AddRange(args); + + await _extensionInteractionService.LaunchAppHostAsync( + _appHostFile.FullName, + allArgs, + environmentVariables.Select(kvp => new EnvVar { Name = kvp.Key, Value = kvp.Value }).ToList(), + _debug); + + return (0, null); + } +} diff --git a/src/Aspire.Cli/Projects/GuestAppHostProject.cs b/src/Aspire.Cli/Projects/GuestAppHostProject.cs index 6c62f3e5094..205d65c7d22 100644 --- a/src/Aspire.Cli/Projects/GuestAppHostProject.cs +++ b/src/Aspire.Cli/Projects/GuestAppHostProject.cs @@ -99,7 +99,7 @@ private string GetEffectiveSdkVersion() _logger.LogDebug("Using SDK version from configuration: {Version}", configuredVersion); return configuredVersion; } - + _logger.LogDebug("Using default SDK version: {Version}", DotNetBasedAppHostServerProject.DefaultSdkVersion); return DotNetBasedAppHostServerProject.DefaultSdkVersion; } @@ -119,7 +119,7 @@ public Task GetDetectionPatternsAsync(CancellationToken cancellationTo public bool CanHandle(FileInfo appHostFile) { // Check if file matches this language's detection patterns - return _resolvedLanguage.DetectionPatterns.Any(p => + return _resolvedLanguage.DetectionPatterns.Any(p => appHostFile.Name.Equals(p, StringComparison.OrdinalIgnoreCase)); } @@ -259,7 +259,7 @@ public Task ValidateAppHostAsync(FileInfo appHostFile, var patterns = _resolvedLanguage.DetectionPatterns; if (!patterns.Any(p => appHostFile.Name.Equals(p, StringComparison.OrdinalIgnoreCase))) { - _logger.LogDebug("AppHost file {File} does not match {Language} detection patterns: {Patterns}", + _logger.LogDebug("AppHost file {File} does not match {Language} detection patterns: {Patterns}", appHostFile.Name, _resolvedLanguage.DisplayName, string.Join(", ", patterns)); return Task.FromResult(new AppHostValidationResult(IsValid: false)); } @@ -425,17 +425,50 @@ await GenerateCodeViaRpcAsync( ["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName }; - // Start guest apphost - it will connect to AppHost server, define resources - // When hot reload is enabled, use watch mode + // Check if the extension should launch the guest app host (for VS Code debugging). + // This mirrors the pattern in DotNetCliRunner.ExecuteAsync for .NET app hosts. + // The RuntimeSpec declares the required extension capability (e.g., "node" for TypeScript); + // only use the extension launcher when the runtime requests it and the extension supports it. + if (_guestRuntime is null) + { + _interactionService.DisplayError("GuestRuntime not initialized."); + return ExitCodeConstants.FailedToDotnetRunAppHost; + } + + IGuestProcessLauncher launcher; + if (_guestRuntime.ExtensionLaunchCapability is { } requiredCapability + && ExtensionHelper.IsExtensionHost(_interactionService, out var extensionInteractionService, out var extensionBackchannel) + && await extensionBackchannel.HasCapabilityAsync(requiredCapability, cancellationToken)) + { + launcher = new ExtensionGuestLauncher(extensionInteractionService, appHostFile, context.StartDebugSession); + } + else + { + launcher = _guestRuntime.CreateDefaultLauncher(); + } + + // Start guest apphost - it will connect to AppHost server, define resources. + // If launcher is an ExtensionGuestLauncher, it delegates to the VS Code extension. var (guestExitCode, guestOutput) = await ExecuteGuestAppHostAsync( - appHostFile, directory, environmentVariables, enableHotReload, rpcClient, cancellationToken); + appHostFile, directory, environmentVariables, enableHotReload, rpcClient, launcher, cancellationToken); + + if (launcher is ExtensionGuestLauncher) + { + // Extension manages the guest app host lifecycle via VS Code debug session. + // Wait for the AppHost server to exit (Ctrl+C or extension termination). + await appHostServerProcess.WaitForExitAsync(cancellationToken); + return appHostServerProcess.ExitCode; + } if (guestExitCode != 0) { _logger.LogError("{Language} apphost exited with code {ExitCode}", DisplayName, guestExitCode); // Display the output (same pattern as DotNetCliRunner) - _interactionService.DisplayLines(guestOutput.GetLines()); + if (guestOutput is not null) + { + _interactionService.DisplayLines(guestOutput.GetLines()); + } // Signal failure to RunCommand so it doesn't hang waiting for the backchannel var error = new InvalidOperationException($"The {DisplayName} apphost failed."); @@ -706,7 +739,10 @@ await GenerateCodeViaRpcAsync( _logger.LogError("{Language} apphost exited with code {ExitCode}", DisplayName, guestExitCode); // Display the output (same pattern as DotNetCliRunner) - _interactionService.DisplayLines(guestOutput.GetLines()); + if (guestOutput is not null) + { + _interactionService.DisplayLines(guestOutput.GetLines()); + } // Signal failure so callers don't hang waiting for the backchannel var error = new InvalidOperationException($"The {DisplayName} apphost failed."); @@ -1017,7 +1053,7 @@ public async Task FindAndStopRunningInstanceAsync(FileInf } // Stop all running instances - var stopTasks = matchingSockets.Select(socketPath => + var stopTasks = matchingSockets.Select(socketPath => _runningInstanceManager.StopRunningInstanceAsync(socketPath, cancellationToken)); var results = await Task.WhenAll(stopTasks); return results.All(r => r) ? RunningInstanceResult.InstanceStopped : RunningInstanceResult.StopFailed; @@ -1159,12 +1195,13 @@ private async Task InstallDependenciesAsync( /// /// Executes the guest AppHost using GuestRuntime. /// - private async Task<(int ExitCode, OutputCollector Output)> ExecuteGuestAppHostAsync( + private async Task<(int ExitCode, OutputCollector? Output)> ExecuteGuestAppHostAsync( FileInfo appHostFile, DirectoryInfo directory, IDictionary environmentVariables, bool watchMode, IAppHostRpcClient rpcClient, + IGuestProcessLauncher launcher, CancellationToken cancellationToken) { await EnsureRuntimeCreatedAsync(rpcClient, cancellationToken); @@ -1175,13 +1212,13 @@ private async Task InstallDependenciesAsync( return (ExitCodeConstants.FailedToDotnetRunAppHost, new OutputCollector()); } - return await _guestRuntime.RunAsync(appHostFile, directory, environmentVariables, watchMode, cancellationToken); + return await _guestRuntime.RunAsync(appHostFile, directory, environmentVariables, watchMode, launcher, cancellationToken); } /// /// Executes the guest AppHost for publishing using GuestRuntime. /// - private async Task<(int ExitCode, OutputCollector Output)> ExecuteGuestAppHostForPublishAsync( + private async Task<(int ExitCode, OutputCollector? Output)> ExecuteGuestAppHostForPublishAsync( FileInfo appHostFile, DirectoryInfo directory, IDictionary environmentVariables, @@ -1197,7 +1234,7 @@ private async Task InstallDependenciesAsync( return (ExitCodeConstants.FailedToDotnetRunAppHost, new OutputCollector()); } - return await _guestRuntime.PublishAsync(appHostFile, directory, environmentVariables, publishArgs, cancellationToken); + return await _guestRuntime.PublishAsync(appHostFile, directory, environmentVariables, publishArgs, _guestRuntime.CreateDefaultLauncher(), cancellationToken); } /// diff --git a/src/Aspire.Cli/Projects/GuestRuntime.cs b/src/Aspire.Cli/Projects/GuestRuntime.cs index ef10ec0921b..e0f348a4cde 100644 --- a/src/Aspire.Cli/Projects/GuestRuntime.cs +++ b/src/Aspire.Cli/Projects/GuestRuntime.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics; using Aspire.Cli.Utils; using Aspire.Hosting.Ats; using Microsoft.Extensions.Logging; @@ -38,6 +37,12 @@ public GuestRuntime(RuntimeSpec spec, ILogger logger) /// public string DisplayName => _spec.DisplayName; + /// + /// Gets the extension capability required to launch this language via the VS Code extension. + /// Null if this language does not support extension-based launching. + /// + public string? ExtensionLaunchCapability => _spec.ExtensionLaunchCapability; + /// /// Installs dependencies for the guest language project. /// @@ -52,47 +57,19 @@ public async Task InstallDependenciesAsync(DirectoryInfo directory, Cancell return 0; } - var command = FindCommand(_spec.InstallDependencies.Command); - if (command is null) - { - _logger.LogError("Command '{Command}' not found in PATH", _spec.InstallDependencies.Command); - return -1; - } - var args = ReplacePlaceholders(_spec.InstallDependencies.Args, null, directory, null); - _logger.LogDebug("Installing dependencies: {Command} {Args}", command, string.Join(" ", args)); + var environmentVariables = _spec.InstallDependencies.EnvironmentVariables ?? new Dictionary(); - var startInfo = new ProcessStartInfo - { - FileName = command, - WorkingDirectory = directory.FullName, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; + var launcher = CreateDefaultLauncher(); + var (exitCode, _) = await launcher.LaunchAsync( + _spec.InstallDependencies.Command, + args, + directory, + environmentVariables, + cancellationToken); - // Use ArgumentList for proper escaping of special characters - foreach (var arg in args) - { - startInfo.ArgumentList.Add(arg); - } - - // Add command-specific environment variables from the spec - if (_spec.InstallDependencies.EnvironmentVariables is not null) - { - foreach (var (key, value) in _spec.InstallDependencies.EnvironmentVariables) - { - startInfo.EnvironmentVariables[key] = value; - } - } - - using var process = new Process { StartInfo = startInfo }; - process.Start(); - await process.WaitForExitAsync(cancellationToken); - - return process.ExitCode; + return exitCode; } /// @@ -102,13 +79,15 @@ public async Task InstallDependenciesAsync(DirectoryInfo directory, Cancell /// The project directory. /// Environment variables to set for the process. /// Whether to run in watch mode for hot reload. + /// Strategy for launching the process. /// Cancellation token. - /// A tuple of the exit code and captured output. - public async Task<(int ExitCode, OutputCollector Output)> RunAsync( + /// A tuple of the exit code and captured output (null when launched via extension). + public async Task<(int ExitCode, OutputCollector? Output)> RunAsync( FileInfo appHostFile, DirectoryInfo directory, IDictionary environmentVariables, bool watchMode, + IGuestProcessLauncher launcher, CancellationToken cancellationToken) { // Use watch execute if watch mode is enabled and the spec supports it @@ -116,7 +95,7 @@ public async Task InstallDependenciesAsync(DirectoryInfo directory, Cancell ? _spec.WatchExecute : _spec.Execute; - return await ExecuteCommandAsync(commandSpec, appHostFile, directory, environmentVariables, null, cancellationToken); + return await ExecuteCommandAsync(commandSpec, appHostFile, directory, environmentVariables, null, launcher, cancellationToken); } /// @@ -126,104 +105,53 @@ public async Task InstallDependenciesAsync(DirectoryInfo directory, Cancell /// The project directory. /// Environment variables to set for the process. /// Additional arguments for publishing. + /// Strategy for launching the process. /// Cancellation token. /// A tuple of the exit code and captured output. - public async Task<(int ExitCode, OutputCollector Output)> PublishAsync( + public async Task<(int ExitCode, OutputCollector? Output)> PublishAsync( FileInfo appHostFile, DirectoryInfo directory, IDictionary environmentVariables, string[]? publishArgs, + IGuestProcessLauncher launcher, CancellationToken cancellationToken) { // Use publish execute if available, otherwise fall back to regular execute var commandSpec = _spec.PublishExecute ?? _spec.Execute; - return await ExecuteCommandAsync(commandSpec, appHostFile, directory, environmentVariables, publishArgs, cancellationToken); + return await ExecuteCommandAsync(commandSpec, appHostFile, directory, environmentVariables, publishArgs, launcher, cancellationToken); } - private async Task<(int ExitCode, OutputCollector Output)> ExecuteCommandAsync( + private async Task<(int ExitCode, OutputCollector? Output)> ExecuteCommandAsync( CommandSpec commandSpec, FileInfo appHostFile, DirectoryInfo directory, IDictionary environmentVariables, string[]? additionalArgs, + IGuestProcessLauncher launcher, CancellationToken cancellationToken) { - var command = FindCommand(commandSpec.Command); - if (command is null) - { - _logger.LogError("Command '{Command}' not found in PATH", commandSpec.Command); - var output = new OutputCollector(); - output.AppendError($"Command '{commandSpec.Command}' not found. Please ensure it is installed and in your PATH."); - return (-1, output); - } - var args = ReplacePlaceholders(commandSpec.Args, appHostFile, directory, additionalArgs); - _logger.LogDebug("Executing: {Command} {Args}", command, string.Join(" ", args)); - - var startInfo = new ProcessStartInfo - { - FileName = command, - WorkingDirectory = directory.FullName, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; - - // Use ArgumentList for proper escaping of special characters - foreach (var arg in args) - { - startInfo.ArgumentList.Add(arg); - } - - // Add caller-provided environment variables - foreach (var (key, value) in environmentVariables) - { - startInfo.EnvironmentVariables[key] = value; - } - - // Add command-specific environment variables from the spec - // These take precedence over caller-provided variables + // Merge command-specific environment variables from the spec (they take precedence) + var mergedEnvironment = new Dictionary(environmentVariables); if (commandSpec.EnvironmentVariables is not null) { foreach (var (key, value) in commandSpec.EnvironmentVariables) { - startInfo.EnvironmentVariables[key] = value; + mergedEnvironment[key] = value; } } - using var process = new Process { StartInfo = startInfo }; - - var outputCollector = new OutputCollector(); - - process.OutputDataReceived += (sender, e) => - { - if (e.Data is not null) - { - _logger.LogDebug("{Language}({ProcessId}) stdout: {Line}", _spec.Language, process.Id, e.Data); - outputCollector.AppendOutput(e.Data); - } - }; - - process.ErrorDataReceived += (sender, e) => - { - if (e.Data is not null) - { - _logger.LogDebug("{Language}({ProcessId}) stderr: {Line}", _spec.Language, process.Id, e.Data); - outputCollector.AppendError(e.Data); - } - }; - - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - - await process.WaitForExitAsync(cancellationToken); - return (process.ExitCode, outputCollector); + _logger.LogDebug("Launching: {Command} {Args}", commandSpec.Command, string.Join(" ", args)); + return await launcher.LaunchAsync(commandSpec.Command, args, directory, mergedEnvironment, cancellationToken); } + /// + /// Creates the default process-based launcher for this runtime. + /// + public ProcessGuestLauncher CreateDefaultLauncher() => new(_spec.Language, _logger); + /// /// Replaces placeholders in command arguments with actual values. /// @@ -269,12 +197,4 @@ private static string[] ReplacePlaceholders( return result.ToArray(); } - - /// - /// Finds the full path to a command in PATH. - /// - private static string? FindCommand(string command) - { - return PathLookupHelper.FindFullPathFromPath(command); - } } diff --git a/src/Aspire.Cli/Projects/IGuestProcessLauncher.cs b/src/Aspire.Cli/Projects/IGuestProcessLauncher.cs new file mode 100644 index 00000000000..10bd28d8aa3 --- /dev/null +++ b/src/Aspire.Cli/Projects/IGuestProcessLauncher.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Cli.Utils; + +namespace Aspire.Cli.Projects; + +/// +/// Strategy for launching a guest language process. +/// +internal interface IGuestProcessLauncher +{ + /// + /// Launches the guest process with the given command, arguments, and environment. + /// + Task<(int ExitCode, OutputCollector? Output)> LaunchAsync( + string command, + string[] args, + DirectoryInfo workingDirectory, + IDictionary environmentVariables, + CancellationToken cancellationToken); +} diff --git a/src/Aspire.Cli/Projects/ProcessGuestLauncher.cs b/src/Aspire.Cli/Projects/ProcessGuestLauncher.cs new file mode 100644 index 00000000000..4824436a93d --- /dev/null +++ b/src/Aspire.Cli/Projects/ProcessGuestLauncher.cs @@ -0,0 +1,91 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using Aspire.Cli.Utils; +using Microsoft.Extensions.Logging; + +namespace Aspire.Cli.Projects; + +/// +/// Launches a guest language process by starting a local OS process. +/// +internal sealed class ProcessGuestLauncher : IGuestProcessLauncher +{ + private readonly string _language; + private readonly ILogger _logger; + + public ProcessGuestLauncher(string language, ILogger logger) + { + _language = language; + _logger = logger; + } + + public async Task<(int ExitCode, OutputCollector? Output)> LaunchAsync( + string command, + string[] args, + DirectoryInfo workingDirectory, + IDictionary environmentVariables, + CancellationToken cancellationToken) + { + var resolvedCommand = PathLookupHelper.FindFullPathFromPath(command); + if (resolvedCommand is null) + { + _logger.LogError("Command '{Command}' not found in PATH", command); + var errorOutput = new OutputCollector(); + errorOutput.AppendError($"Command '{command}' not found. Please ensure it is installed and in your PATH."); + return (-1, errorOutput); + } + + _logger.LogDebug("Executing: {Command} {Args}", resolvedCommand, string.Join(" ", args)); + + var startInfo = new ProcessStartInfo + { + FileName = resolvedCommand, + WorkingDirectory = workingDirectory.FullName, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true + }; + + foreach (var arg in args) + { + startInfo.ArgumentList.Add(arg); + } + + foreach (var (key, value) in environmentVariables) + { + startInfo.EnvironmentVariables[key] = value; + } + + using var process = new Process { StartInfo = startInfo }; + + var outputCollector = new OutputCollector(); + + process.OutputDataReceived += (sender, e) => + { + if (e.Data is not null) + { + _logger.LogDebug("{Language}({ProcessId}) stdout: {Line}", _language, process.Id, e.Data); + outputCollector.AppendOutput(e.Data); + } + }; + + process.ErrorDataReceived += (sender, e) => + { + if (e.Data is not null) + { + _logger.LogDebug("{Language}({ProcessId}) stderr: {Line}", _language, process.Id, e.Data); + outputCollector.AppendError(e.Data); + } + }; + + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + + await process.WaitForExitAsync(cancellationToken); + return (process.ExitCode, outputCollector); + } +} diff --git a/src/Aspire.Cli/Utils/ExtensionHelper.cs b/src/Aspire.Cli/Utils/ExtensionHelper.cs index a399529301e..58abb00eb1b 100644 --- a/src/Aspire.Cli/Utils/ExtensionHelper.cs +++ b/src/Aspire.Cli/Utils/ExtensionHelper.cs @@ -31,6 +31,7 @@ internal static class KnownCapabilities { public const string DevKit = "devkit"; public const string Project = "project"; + public const string Node = "node"; public const string BuildDotnetUsingCli = "build-dotnet-using-cli"; public const string Baseline = "baseline.v1"; public const string SecretPrompts = "secret-prompts.v1"; diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs index 4efe21f374c..2d03a753c20 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs @@ -152,6 +152,7 @@ public RuntimeSpec GetRuntimeSpec() DisplayName = LanguageDisplayName, CodeGenLanguage = CodeGenTarget, DetectionPatterns = s_detectionPatterns, + ExtensionLaunchCapability = "node", InstallDependencies = new CommandSpec { Command = "npm", diff --git a/src/Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.csproj b/src/Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.csproj index d49d7d13609..3e80a63b27e 100644 --- a/src/Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.csproj +++ b/src/Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Aspire.Hosting.JavaScript/BrowserDebuggerResource.cs b/src/Aspire.Hosting.JavaScript/BrowserDebuggerResource.cs new file mode 100644 index 00000000000..63b8ddd14d2 --- /dev/null +++ b/src/Aspire.Hosting.JavaScript/BrowserDebuggerResource.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Hosting.ApplicationModel; + +namespace Aspire.Hosting.JavaScript; + +internal sealed class BrowserDebuggerResource(string name, string browser, string workingDirectory) + : ExecutableResource(name, browser, workingDirectory) +{ +} diff --git a/src/Aspire.Hosting.JavaScript/BrowserLaunchConfiguration.cs b/src/Aspire.Hosting.JavaScript/BrowserLaunchConfiguration.cs new file mode 100644 index 00000000000..8e2a82c545e --- /dev/null +++ b/src/Aspire.Hosting.JavaScript/BrowserLaunchConfiguration.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json.Serialization; +using Aspire.Hosting.Dcp.Model; + +namespace Aspire.Hosting.JavaScript; + +internal sealed class BrowserLaunchConfiguration() : ExecutableLaunchConfiguration("browser") +{ + [JsonPropertyName("url")] + public string Url { get; set; } = string.Empty; + + [JsonPropertyName("web_root")] + public string WebRoot { get; set; } = string.Empty; + + [JsonPropertyName("browser")] + public string Browser { get; set; } = "msedge"; +} diff --git a/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs b/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs index 3d1eb4b7462..b8e3cc289a3 100644 --- a/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs +++ b/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs @@ -4,9 +4,12 @@ #pragma warning disable ASPIREDOCKERFILEBUILDER001 #pragma warning disable ASPIREPIPELINES001 #pragma warning disable ASPIRECERTIFICATES001 +#pragma warning disable ASPIREEXTENSION001 +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; +using System.Text.Json.Serialization; using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.ApplicationModel.Docker; using Aspire.Hosting.JavaScript; @@ -24,6 +27,7 @@ namespace Aspire.Hosting; /// public static class JavaScriptHostingExtensions { + private const string BrowserCapability = "browser"; private const string DefaultNodeVersion = "22"; // This is the order of config files that Vite will look for by default @@ -258,6 +262,8 @@ public static IResourceBuilder AddNodeApp(this IDistributedAppl resourceBuilder.WithNpm(); } + resourceBuilder.WithVSCodeDebugging(scriptPath); + if (builder.ExecutionContext.IsRunMode) { builder.Eventing.Subscribe((_, _) => @@ -460,6 +466,8 @@ private static IResourceBuilder CreateDefaultJavaScriptAppBuilder WithRunScript(this IResourc return resource.WithAnnotation(new JavaScriptRunScriptAnnotation(scriptName, args)); } + [Experimental("ASPIREEXTENSION001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] + internal static IResourceBuilder WithVSCodeDebugging(this IResourceBuilder builder, string scriptPath) + where T : NodeAppResource + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentException.ThrowIfNullOrEmpty(scriptPath); + + var resource = builder.Resource; + var workingDirectory = Path.GetFullPath(resource.WorkingDirectory); + + return builder.WithDebugSupport( + mode => + { + // Compute at run time so the launch config reflects the final annotation state + var hasRunScript = resource.TryGetLastAnnotation(out _); + var hasPackageManager = resource.TryGetLastAnnotation(out var pmAnnotation); + var runtimeExecutable = hasRunScript && hasPackageManager ? pmAnnotation!.ExecutableName : "node"; + + return new NodeLaunchConfiguration + { + ScriptPath = Path.GetFullPath(scriptPath, workingDirectory), + Mode = mode, + RuntimeExecutable = runtimeExecutable, + WorkingDirectory = workingDirectory + }; + }, + "node"); + } + + [Experimental("ASPIREEXTENSION001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] + internal static IResourceBuilder WithVSCodeDebugging(this IResourceBuilder builder) + where T : JavaScriptAppResource + { + ArgumentNullException.ThrowIfNull(builder); + + var resource = builder.Resource; + var workingDirectory = Path.GetFullPath(resource.WorkingDirectory); + + return builder.WithDebugSupport( + mode => + { + // Compute at run time so the launch config reflects the final annotation state + var packageManager = "npm"; + if (resource.TryGetLastAnnotation(out var pmAnnotation)) + { + packageManager = pmAnnotation.ExecutableName; + } + + return new NodeLaunchConfiguration + { + ScriptPath = string.Empty, + Mode = mode, + RuntimeExecutable = packageManager, + WorkingDirectory = workingDirectory + }; + }, + "node"); + } + + /// + /// Configures a browser debugger for the JavaScript application resource, enabling browser-based debugging + /// through a child resource that launches when the parent application is ready. + /// + /// The type of the JavaScript application resource. + /// The resource builder for the JavaScript application. + /// The browser to use for debugging. Defaults to "msedge". Supported values include "msedge" and "chrome". + /// A reference to the for chaining additional configuration. + /// + /// This method creates a child that waits for the parent JavaScript + /// application to start, then launches a browser debug session targeting the parent's HTTP or HTTPS endpoint. + /// The parent resource must have at least one HTTP or HTTPS endpoint configured. + /// + /// + /// Thrown when the parent resource does not have an HTTP or HTTPS endpoint, or when the IDE extension + /// does not support browser debugging. + /// + /// + /// Add browser debugging to a JavaScript application: + /// + /// var builder = DistributedApplication.CreateBuilder(args); + /// builder.AddViteApp("frontend", "./frontend") + /// .WithBrowserDebugger(); + /// + /// + [Experimental("ASPIREEXTENSION001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] + [AspireExport("withBrowserDebugger", Description = "Configures a browser debugger for the JavaScript application")] + public static IResourceBuilder WithBrowserDebugger( + this IResourceBuilder builder, + string browser = "msedge") + where T : JavaScriptAppResource + { + ArgumentNullException.ThrowIfNull(builder); + + // Validate that the extension supports browser debugging if we're running in an extension context + ValidateBrowserCapability(builder); + + var parentResource = builder.Resource; + var debuggerResourceName = $"{parentResource.Name}-browser"; + + var debuggerResource = new BrowserDebuggerResource(debuggerResourceName, browser, parentResource.WorkingDirectory); + + builder.ApplicationBuilder.AddResource(debuggerResource) + .WithParentRelationship(parentResource) + .WaitFor(builder) + .ExcludeFromManifest() + .WithDebugSupport( + mode => + { + // Resolve endpoint at run time so dynamically added endpoints are reflected + EndpointAnnotation? endpointAnnotation = null; + if (parentResource.TryGetAnnotationsOfType(out var endpoints)) + { + endpointAnnotation = endpoints.FirstOrDefault(e => e.UriScheme == "https") + ?? endpoints.FirstOrDefault(e => e.UriScheme == "http"); + } + + if (endpointAnnotation is null) + { + throw new InvalidOperationException( + $"Resource '{parentResource.Name}' does not have an HTTP or HTTPS endpoint. Browser debugging requires an endpoint to navigate to."); + } + + var endpointReference = parentResource.GetEndpoint(endpointAnnotation.Name); + + return new BrowserLaunchConfiguration + { + Mode = mode, + Url = endpointReference.Url, + WebRoot = parentResource.WorkingDirectory, + Browser = browser + }; + }, + BrowserCapability); + + return builder; + } + + private static void ValidateBrowserCapability(IResourceBuilder builder) where T : IResource + { + var configuration = builder.ApplicationBuilder.Configuration; + + try + { + if (configuration["DEBUG_SESSION_INFO"] is { } debugSessionInfoJson + && JsonSerializer.Deserialize(debugSessionInfoJson) is { } info + && info.SupportedLaunchConfigurations is not null + && !info.SupportedLaunchConfigurations.Contains(BrowserCapability)) + { + throw new InvalidOperationException( + "This version of the Aspire extension does not support browser debugging. Please update the Aspire extension to use browser debugging support with WithBrowserDebugger()."); + } + } + catch (JsonException) + { + // If we can't parse the debug session info, skip validation + } + } + + private sealed class DebugSessionCapabilities + { + [JsonPropertyName("supported_launch_configurations")] + public string[]? SupportedLaunchConfigurations { get; set; } + } + private static void AddInstaller(IResourceBuilder resource, bool install) where TResource : JavaScriptAppResource { // Only install packages if in run mode diff --git a/src/Aspire.Hosting.JavaScript/NodeLaunchConfiguration.cs b/src/Aspire.Hosting.JavaScript/NodeLaunchConfiguration.cs new file mode 100644 index 00000000000..325a843e461 --- /dev/null +++ b/src/Aspire.Hosting.JavaScript/NodeLaunchConfiguration.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json.Serialization; +using Aspire.Hosting.Dcp.Model; + +namespace Aspire.Hosting.JavaScript; + +internal sealed class NodeLaunchConfiguration() : ExecutableLaunchConfiguration("node") +{ + [JsonPropertyName("script_path")] + public string ScriptPath { get; set; } = string.Empty; + + [JsonPropertyName("runtime_executable")] + public string RuntimeExecutable { get; set; } = string.Empty; + + [JsonPropertyName("working_directory")] + public string WorkingDirectory { get; set; } = string.Empty; +} diff --git a/src/Aspire.Hosting.Python/Aspire.Hosting.Python.csproj b/src/Aspire.Hosting.Python/Aspire.Hosting.Python.csproj index 25d5b07fa13..0bdfccf71dc 100644 --- a/src/Aspire.Hosting.Python/Aspire.Hosting.Python.csproj +++ b/src/Aspire.Hosting.Python/Aspire.Hosting.Python.csproj @@ -7,12 +7,6 @@ Python support for Aspire. - - - - - - diff --git a/src/Aspire.Hosting/Aspire.Hosting.csproj b/src/Aspire.Hosting/Aspire.Hosting.csproj index 6d65b91a9d4..bbfb120f7fc 100644 --- a/src/Aspire.Hosting/Aspire.Hosting.csproj +++ b/src/Aspire.Hosting/Aspire.Hosting.csproj @@ -113,6 +113,9 @@ + + + diff --git a/src/Aspire.Hosting/Ats/RuntimeSpec.cs b/src/Aspire.Hosting/Ats/RuntimeSpec.cs index 40510a8a8b7..87784692450 100644 --- a/src/Aspire.Hosting/Ats/RuntimeSpec.cs +++ b/src/Aspire.Hosting/Ats/RuntimeSpec.cs @@ -50,6 +50,13 @@ public sealed class RuntimeSpec /// Gets the command to execute the AppHost for publish. Null to use Execute with args appended. /// public CommandSpec? PublishExecute { get; init; } + + /// + /// Gets the extension capability required to launch this language via the VS Code extension. + /// When set (e.g., "node"), the CLI will use the extension launcher if the extension reports + /// this capability. When null, the CLI always uses the default process-based launcher. + /// + public string? ExtensionLaunchCapability { get; init; } } /// diff --git a/src/Aspire.Hosting/Dcp/DcpExecutor.cs b/src/Aspire.Hosting/Dcp/DcpExecutor.cs index 4edf0ce335d..2c31a3a8b7d 100644 --- a/src/Aspire.Hosting/Dcp/DcpExecutor.cs +++ b/src/Aspire.Hosting/Dcp/DcpExecutor.cs @@ -1323,11 +1323,12 @@ private void PreparePlainExecutables() exe.Annotate(CustomResource.OtelServiceInstanceIdAnnotation, exeInstance.Suffix); exe.Annotate(CustomResource.ResourceNameAnnotation, executable.Name); - if (executable.SupportsDebugging(_configuration, out var supportsDebuggingAnnotation)) + if (executable.SupportsDebugging(_configuration, out _)) { + // Just mark as IDE execution here - the actual launch configuration callback + // will be invoked in CreateExecutableAsync after endpoints are allocated. exe.Spec.ExecutionType = ExecutionType.IDE; exe.Spec.FallbackExecutionTypes = [ ExecutionType.Process ]; - supportsDebuggingAnnotation.LaunchConfigurationAnnotator(exe, _configuration[KnownConfigNames.DebugSessionRunMode] ?? ExecutableLaunchMode.NoDebug); } else { @@ -1747,6 +1748,28 @@ private async Task CreateExecutableAsync(RenderedModelResource er, ILogger resou throw new FailedToApplyEnvironmentException(); } + // Invoke the debug configuration callback now that endpoints are allocated. + // This allows launch configurations to access endpoint URLs that were not + // available during PrepareExecutables(). + // Project resources configure their launch configs in PrepareProjectExecutables() directly, + // so we only invoke the annotator for non-project executables here. + if (er.ModelResource is not ProjectResource + && er.ModelResource.SupportsDebugging(_configuration, out var supportsDebuggingAnnotation)) + { + var mode = _configuration[KnownConfigNames.DebugSessionRunMode] ?? ExecutableLaunchMode.NoDebug; + try + { + // Clear any existing launch configurations (needed for restart scenarios). + exe.Annotate(Executable.LaunchConfigurationsAnnotation, string.Empty); + supportsDebuggingAnnotation.LaunchConfigurationAnnotator(exe, mode); + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to apply launch configuration for resource '{ResourceName}'. Falling back to process execution.", er.ModelResource.Name); + exe.Spec.ExecutionType = ExecutionType.Process; + } + } + await _kubernetesService.CreateAsync(exe, cancellationToken).ConfigureAwait(false); } finally diff --git a/src/Aspire.Hosting/Dcp/Model/ExecutableLaunchConfiguration.cs b/src/Aspire.Hosting/Dcp/Model/ExecutableLaunchConfiguration.cs index 5795877e4b6..12014edf3e6 100644 --- a/src/Aspire.Hosting/Dcp/Model/ExecutableLaunchConfiguration.cs +++ b/src/Aspire.Hosting/Dcp/Model/ExecutableLaunchConfiguration.cs @@ -30,7 +30,7 @@ internal class ExecutableLaunchConfiguration(string type) public string Mode { get; set; } = System.Diagnostics.Debugger.IsAttached ? ExecutableLaunchMode.Debug : ExecutableLaunchMode.NoDebug; } -internal class ProjectLaunchConfiguration() : ExecutableLaunchConfiguration("project") +internal sealed class ProjectLaunchConfiguration() : ExecutableLaunchConfiguration("project") { [JsonPropertyName("launch_profile")] public string LaunchProfile { get; set; } = string.Empty; diff --git a/tests/Aspire.Cli.Tests/Projects/ExtensionGuestLauncherTests.cs b/tests/Aspire.Cli.Tests/Projects/ExtensionGuestLauncherTests.cs new file mode 100644 index 00000000000..dace11a8043 --- /dev/null +++ b/tests/Aspire.Cli.Tests/Projects/ExtensionGuestLauncherTests.cs @@ -0,0 +1,181 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Cli.Backchannel; +using Aspire.Cli.Interaction; +using Aspire.Cli.Projects; + +namespace Aspire.Cli.Tests.Projects; + +public class ExtensionGuestLauncherTests +{ + [Fact] + public async Task LaunchAsync_PrependsCommandAsFirstArg() + { + string? capturedProjectFile = null; + List? capturedArgs = null; + var service = new FakeLaunchExtensionService((projectFile, args, _, _) => + { + capturedProjectFile = projectFile; + capturedArgs = args; + }); + + var launcher = new ExtensionGuestLauncher( + service, + new FileInfo("/tmp/apphost.ts"), + debug: false); + + await launcher.LaunchAsync( + "npx", + ["tsx", "/tmp/apphost.ts"], + new DirectoryInfo("/tmp"), + new Dictionary(), + CancellationToken.None); + + Assert.NotNull(capturedArgs); + Assert.Equal("npx", capturedArgs[0]); + Assert.Equal("tsx", capturedArgs[1]); + Assert.Equal("/tmp/apphost.ts", capturedArgs[2]); + } + + [Fact] + public async Task LaunchAsync_PassesAppHostFileAsProjectFile() + { + string? capturedProjectFile = null; + var service = new FakeLaunchExtensionService((projectFile, _, _, _) => + { + capturedProjectFile = projectFile; + }); + + var appHostFile = new FileInfo("/home/user/project/apphost.ts"); + var launcher = new ExtensionGuestLauncher(service, appHostFile, debug: true); + + await launcher.LaunchAsync("npx", ["tsx"], new DirectoryInfo("/tmp"), new Dictionary(), CancellationToken.None); + + Assert.Equal(appHostFile.FullName, capturedProjectFile); + } + + [Fact] + public async Task LaunchAsync_PassesDebugFlag() + { + bool? capturedDebug = null; + var service = new FakeLaunchExtensionService((_, _, _, debug) => + { + capturedDebug = debug; + }); + + var launcher = new ExtensionGuestLauncher(service, new FileInfo("/tmp/apphost.ts"), debug: true); + await launcher.LaunchAsync("npx", [], new DirectoryInfo("/tmp"), new Dictionary(), CancellationToken.None); + + Assert.True(capturedDebug); + } + + [Fact] + public async Task LaunchAsync_PassesEnvironmentAsEnvVars() + { + List? capturedEnv = null; + var service = new FakeLaunchExtensionService((_, _, env, _) => + { + capturedEnv = env; + }); + + var launcher = new ExtensionGuestLauncher(service, new FileInfo("/tmp/apphost.ts"), debug: false); + var envVars = new Dictionary + { + ["SOCKET_PATH"] = "/tmp/socket", + ["NODE_ENV"] = "development" + }; + + await launcher.LaunchAsync("npx", ["tsx"], new DirectoryInfo("/tmp"), envVars, CancellationToken.None); + + Assert.NotNull(capturedEnv); + Assert.Equal(2, capturedEnv.Count); + Assert.Contains(capturedEnv, e => e.Name == "SOCKET_PATH" && e.Value == "/tmp/socket"); + Assert.Contains(capturedEnv, e => e.Name == "NODE_ENV" && e.Value == "development"); + } + + [Fact] + public async Task LaunchAsync_ReturnsZeroExitCodeAndNullOutput() + { + var service = new FakeLaunchExtensionService((_, _, _, _) => { }); + var launcher = new ExtensionGuestLauncher(service, new FileInfo("/tmp/apphost.ts"), debug: false); + + var (exitCode, output) = await launcher.LaunchAsync("cmd", [], new DirectoryInfo("/tmp"), new Dictionary(), CancellationToken.None); + + Assert.Equal(0, exitCode); + Assert.Null(output); + } + + [Fact] + public async Task LaunchAsync_WithEmptyArgs_OnlyContainsCommand() + { + List? capturedArgs = null; + var service = new FakeLaunchExtensionService((_, args, _, _) => + { + capturedArgs = args; + }); + + var launcher = new ExtensionGuestLauncher(service, new FileInfo("/tmp/apphost.ts"), debug: false); + await launcher.LaunchAsync("python", [], new DirectoryInfo("/tmp"), new Dictionary(), CancellationToken.None); + + Assert.NotNull(capturedArgs); + Assert.Single(capturedArgs); + Assert.Equal("python", capturedArgs[0]); + } + + /// + /// Minimal fake that only implements LaunchAppHostAsync for testing ExtensionGuestLauncher. + /// + private sealed class FakeLaunchExtensionService : IExtensionInteractionService + { + private readonly Action, List, bool> _onLaunch; + + public FakeLaunchExtensionService(Action, List, bool> onLaunch) + { + _onLaunch = onLaunch; + } + + public IExtensionBackchannel Backchannel => throw new NotImplementedException(); + + public Task LaunchAppHostAsync(string projectFile, List arguments, List environment, bool debug) + { + _onLaunch(projectFile, arguments, environment, debug); + return Task.CompletedTask; + } + + // Remaining IExtensionInteractionService members - not used by ExtensionGuestLauncher + public void OpenEditor(string projectPath) => throw new NotImplementedException(); + public void LogMessage(Microsoft.Extensions.Logging.LogLevel logLevel, string message) => throw new NotImplementedException(); + public void DisplayDashboardUrls(DashboardUrlsState dashboardUrls) => throw new NotImplementedException(); + public void NotifyAppHostStartupCompleted() => throw new NotImplementedException(); + public void DisplayConsolePlainText(string message) => throw new NotImplementedException(); + public Task StartDebugSessionAsync(string workingDirectory, string? projectFile, bool debug, DebugSessionOptions? options = null) => throw new NotImplementedException(); + public void WriteDebugSessionMessage(string message, bool stdout, string? textStyle) => throw new NotImplementedException(); + public Task RequestAppHostAttachAsync(int processId, string projectName) => throw new NotImplementedException(); + public void ConsoleDisplaySubtleMessage(string message, bool allowMarkup = false) => throw new NotImplementedException(); + public void WriteConsoleLog(string message, int? lineNumber = null, string? type = null, bool isErrorMessage = false) => throw new NotImplementedException(); + public ConsoleOutput Console { get; set; } + public Task ShowStatusAsync(string statusText, Func> action, KnownEmoji? emoji = null, bool allowMarkup = false) => throw new NotImplementedException(); + public void ShowStatus(string statusText, Action action, KnownEmoji? emoji = null, bool allowMarkup = false) => throw new NotImplementedException(); + public Task PromptForStringAsync(string promptText, string? defaultValue = null, Func? validator = null, bool isSecret = false, bool required = false, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public Task PromptForFilePathAsync(string promptText, string? defaultValue = null, Func? validator = null, bool directory = false, bool required = false, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public Task PromptForSelectionAsync(string promptText, IEnumerable choices, Func choiceFormatter, CancellationToken cancellationToken = default) where T : notnull => throw new NotImplementedException(); + public Task> PromptForSelectionsAsync(string promptText, IEnumerable choices, Func choiceFormatter, IEnumerable? preSelected = null, bool optional = false, CancellationToken cancellationToken = default) where T : notnull => throw new NotImplementedException(); + public int DisplayIncompatibleVersionError(AppHostIncompatibleException ex, string appHostHostingVersion) => throw new NotImplementedException(); + public void DisplayError(string errorMessage) => throw new NotImplementedException(); + public void DisplayMessage(KnownEmoji emoji, string message, bool allowMarkup = false) => throw new NotImplementedException(); + public void DisplaySuccess(string message, bool allowMarkup = false) => throw new NotImplementedException(); + public void DisplayLines(IEnumerable<(string Stream, string Line)> lines) => throw new NotImplementedException(); + public void DisplayCancellationMessage() => throw new NotImplementedException(); + public Task ConfirmAsync(string promptText, bool defaultValue = true, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public void DisplaySubtleMessage(string message, bool allowMarkup = false) => throw new NotImplementedException(); + public void DisplayEmptyLine() => throw new NotImplementedException(); + public void DisplayPlainText(string text) => throw new NotImplementedException(); + public void DisplayRawText(string text, ConsoleOutput? consoleOverride = null) => throw new NotImplementedException(); + public void DisplayMarkdown(string markdown) => throw new NotImplementedException(); + public void DisplayMarkupLine(string markup) => throw new NotImplementedException(); + public void DisplayVersionUpdateNotification(string newerVersion, string? updateCommand = null) => throw new NotImplementedException(); + public void DisplayRenderable(Spectre.Console.Rendering.IRenderable renderable) => throw new NotImplementedException(); + public Task DisplayLiveAsync(Spectre.Console.Rendering.IRenderable initialRenderable, Func, Task> callback) => throw new NotImplementedException(); + } +} diff --git a/tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs b/tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs new file mode 100644 index 00000000000..94400e3d960 --- /dev/null +++ b/tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs @@ -0,0 +1,320 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Cli.Projects; +using Aspire.Cli.Utils; +using Aspire.Hosting.Ats; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Aspire.Cli.Tests.Projects; + +public class GuestRuntimeTests +{ + private static RuntimeSpec CreateTestSpec( + CommandSpec? execute = null, + CommandSpec? watchExecute = null, + CommandSpec? publishExecute = null, + CommandSpec? installDependencies = null) + { + return new RuntimeSpec + { + Language = "test/runtime", + DisplayName = "Test Runtime", + CodeGenLanguage = "Test", + DetectionPatterns = ["apphost.test"], + Execute = execute ?? new CommandSpec + { + Command = "test-cmd", + Args = ["{appHostFile}"] + }, + WatchExecute = watchExecute, + PublishExecute = publishExecute, + InstallDependencies = installDependencies + }; + } + + [Fact] + public void Language_ReturnsSpecLanguage() + { + var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + + Assert.Equal("test/runtime", runtime.Language); + } + + [Fact] + public void DisplayName_ReturnsSpecDisplayName() + { + var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + + Assert.Equal("Test Runtime", runtime.DisplayName); + } + + [Fact] + public void CreateDefaultLauncher_ReturnsProcessGuestLauncher() + { + var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + + var launcher = runtime.CreateDefaultLauncher(); + + Assert.IsType(launcher); + } + + [Fact] + public async Task RunAsync_UsesExecuteSpec() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "my-runner", + Args = ["{appHostFile}"] + }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + var envVars = new Dictionary(); + + await runtime.RunAsync(appHostFile, directory, envVars, watchMode: false, launcher, CancellationToken.None); + + Assert.Equal("my-runner", launcher.LastCommand); + Assert.Contains(appHostFile.FullName, launcher.LastArgs); + } + + [Fact] + public async Task RunAsync_WatchMode_UsesWatchExecuteSpec() + { + var spec = CreateTestSpec( + execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }, + watchExecute: new CommandSpec { Command = "watch-cmd", Args = ["--watch", "{appHostFile}"] } + ); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: true, launcher, CancellationToken.None); + + Assert.Equal("watch-cmd", launcher.LastCommand); + Assert.Contains("--watch", launcher.LastArgs); + } + + [Fact] + public async Task RunAsync_WatchModeWithoutWatchSpec_FallsBackToExecute() + { + var spec = CreateTestSpec(execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: true, launcher, CancellationToken.None); + + Assert.Equal("run-cmd", launcher.LastCommand); + } + + [Fact] + public async Task PublishAsync_UsesPublishExecuteSpec() + { + var spec = CreateTestSpec( + execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }, + publishExecute: new CommandSpec { Command = "publish-cmd", Args = ["{appHostFile}", "{args}"] } + ); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + + await runtime.PublishAsync(appHostFile, directory, new Dictionary(), ["--output", "/out"], launcher, CancellationToken.None); + + Assert.Equal("publish-cmd", launcher.LastCommand); + // {args} placeholder joins multiple args into a single string + Assert.Contains(launcher.LastArgs, a => a.Contains("--output") && a.Contains("/out")); + } + + [Fact] + public async Task PublishAsync_WithoutPublishSpec_FallsBackToExecute() + { + var spec = CreateTestSpec(execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + + await runtime.PublishAsync(appHostFile, directory, new Dictionary(), null, launcher, CancellationToken.None); + + Assert.Equal("run-cmd", launcher.LastCommand); + } + + [Fact] + public async Task RunAsync_MergesSpecEnvironmentVariables() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "test-cmd", + Args = ["{appHostFile}"], + EnvironmentVariables = new Dictionary { ["SPEC_VAR"] = "spec_value" } + }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + var envVars = new Dictionary { ["CALLER_VAR"] = "caller_value" }; + + await runtime.RunAsync(appHostFile, directory, envVars, watchMode: false, launcher, CancellationToken.None); + + Assert.Equal("caller_value", launcher.LastEnvironmentVariables["CALLER_VAR"]); + Assert.Equal("spec_value", launcher.LastEnvironmentVariables["SPEC_VAR"]); + } + + [Fact] + public async Task RunAsync_SpecEnvironmentVariables_TakePrecedence() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "test-cmd", + Args = ["{appHostFile}"], + EnvironmentVariables = new Dictionary { ["SHARED_VAR"] = "from_spec" } + }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + var envVars = new Dictionary { ["SHARED_VAR"] = "from_caller" }; + + await runtime.RunAsync(appHostFile, directory, envVars, watchMode: false, launcher, CancellationToken.None); + + Assert.Equal("from_spec", launcher.LastEnvironmentVariables["SHARED_VAR"]); + } + + [Fact] + public async Task RunAsync_ReplacesAppHostFilePlaceholder() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "npx", + Args = ["tsx", "{appHostFile}"] + }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/home/user/project/apphost.ts"); + var directory = new DirectoryInfo("/home/user/project"); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: false, launcher, CancellationToken.None); + + Assert.Equal("npx", launcher.LastCommand); + Assert.Equal(new[] { "tsx", appHostFile.FullName }, launcher.LastArgs); + } + + [Fact] + public async Task RunAsync_ReplacesAppHostDirPlaceholder() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "test-cmd", + Args = ["--dir", "{appHostDir}"] + }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/home/user/project/apphost.ts"); + var directory = new DirectoryInfo("/home/user/project"); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: false, launcher, CancellationToken.None); + + Assert.Equal(new[] { "--dir", directory.FullName }, launcher.LastArgs); + } + + [Fact] + public async Task PublishAsync_AdditionalArgsAppendedWhenNoPlaceholder() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "test-cmd", + Args = ["{appHostFile}"] + }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + + await runtime.PublishAsync(appHostFile, directory, new Dictionary(), ["--extra", "arg"], launcher, CancellationToken.None); + + Assert.Equal(appHostFile.FullName, launcher.LastArgs[0]); + Assert.Equal("--extra", launcher.LastArgs[1]); + Assert.Equal("arg", launcher.LastArgs[2]); + } + + [Fact] + public async Task RunAsync_EmptyPlaceholderReplacementsAreSkipped() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "test-cmd", + Args = ["{args}"] + }); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: false, launcher, CancellationToken.None); + + Assert.Empty(launcher.LastArgs); + } + + [Fact] + public void ExtensionLaunchCapability_ReturnsSpecValue() + { + var spec = new RuntimeSpec + { + Language = "test/runtime", + DisplayName = "Test Runtime", + CodeGenLanguage = "Test", + DetectionPatterns = ["apphost.test"], + Execute = new CommandSpec { Command = "test-cmd", Args = ["{appHostFile}"] }, + ExtensionLaunchCapability = "node" + }; + var runtime = new GuestRuntime(spec, NullLogger.Instance); + + Assert.Equal("node", runtime.ExtensionLaunchCapability); + } + + [Fact] + public void ExtensionLaunchCapability_DefaultsToNull() + { + var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + + Assert.Null(runtime.ExtensionLaunchCapability); + } + + [Fact] + public async Task InstallDependenciesAsync_WithNoSpec_ReturnsZero() + { + var spec = CreateTestSpec(); + var runtime = new GuestRuntime(spec, NullLogger.Instance); + + var exitCode = await runtime.InstallDependenciesAsync(new DirectoryInfo("/tmp"), CancellationToken.None); + + Assert.Equal(0, exitCode); + } + + private sealed class RecordingLauncher : IGuestProcessLauncher + { + public string LastCommand { get; private set; } = string.Empty; + public string[] LastArgs { get; private set; } = []; + public DirectoryInfo? LastWorkingDirectory { get; private set; } + public IDictionary LastEnvironmentVariables { get; private set; } = new Dictionary(); + + public Task<(int ExitCode, OutputCollector? Output)> LaunchAsync( + string command, + string[] args, + DirectoryInfo workingDirectory, + IDictionary environmentVariables, + CancellationToken cancellationToken) + { + LastCommand = command; + LastArgs = args; + LastWorkingDirectory = workingDirectory; + LastEnvironmentVariables = new Dictionary(environmentVariables); + return Task.FromResult<(int, OutputCollector?)>((0, new OutputCollector())); + } + } +} diff --git a/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs b/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs index f811f730866..35ef7a26439 100644 --- a/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs +++ b/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs @@ -107,39 +107,39 @@ public async Task VerifyDockerfile(bool includePackageJson) var expectedDockerfile = includePackageJson ? """ FROM node:22-alpine AS build - + WORKDIR /app COPY package*.json ./ RUN --mount=type=cache,target=/root/.npm npm ci COPY . . - + FROM node:22-alpine AS runtime - + WORKDIR /app COPY --from=build /app /app - + ENV NODE_ENV=production - + USER node - + ENTRYPOINT ["node","app.js"] """.Replace("\r\n", "\n") : """ FROM node:22-alpine AS build - + WORKDIR /app COPY . . - + FROM node:22-alpine AS runtime - + WORKDIR /app COPY --from=build /app /app - + ENV NODE_ENV=production - + USER node - + ENTRYPOINT ["node","app.js"] """.Replace("\r\n", "\n"); @@ -418,4 +418,128 @@ public async Task VerifyNodeAppWithContainerFilesFromResourceWithDashesGenerates private sealed class MyFilesContainer(string name, string command, string workingDirectory) : ExecutableResource(name, command, workingDirectory), IResourceWithContainerFiles; + +#pragma warning disable ASPIREEXTENSION001 // Type is for evaluation purposes only + + [Fact] + public void NodeApp_WithVSCodeDebugging_AddsSupportsDebuggingAnnotation() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + using var tempDir = new TestTempDirectory(); + + var nodeApp = builder.AddNodeApp("nodeapp", tempDir.Path, "app.js"); + + var annotation = nodeApp.Resource.Annotations.OfType().SingleOrDefault(); + Assert.NotNull(annotation); + Assert.Equal("node", annotation.LaunchConfigurationType); + } + + [Fact] + public void NodeApp_WithVSCodeDebugging_DoesNotAddAnnotationInPublishMode() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); + using var tempDir = new TestTempDirectory(); + + var nodeApp = builder.AddNodeApp("nodeapp", tempDir.Path, "app.js"); + + var annotation = nodeApp.Resource.Annotations.OfType().SingleOrDefault(); + Assert.Null(annotation); + } + + [Fact] + public void ViteApp_WithVSCodeDebugging_AddsSupportsDebuggingAnnotation() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + using var tempDir = new TestTempDirectory(); + + var viteApp = builder.AddViteApp("viteapp", tempDir.Path); + + var annotation = viteApp.Resource.Annotations.OfType().SingleOrDefault(); + Assert.NotNull(annotation); + Assert.Equal("node", annotation.LaunchConfigurationType); + } + + [Fact] + public void ViteApp_WithBrowserDebugger_CreatesChildResource() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + using var tempDir = new TestTempDirectory(); + + var viteApp = builder.AddViteApp("viteapp", tempDir.Path) + .WithBrowserDebugger(); + + using var app = builder.Build(); + var appModel = app.Services.GetRequiredService(); + + var browserDebuggerResource = appModel.Resources.OfType().SingleOrDefault(); + Assert.NotNull(browserDebuggerResource); + Assert.Equal("viteapp-browser", browserDebuggerResource.Name); + + // Verify parent relationship + Assert.True(browserDebuggerResource.TryGetAnnotationsOfType(out var relationships)); + var parentRelationship = Assert.Single(relationships, r => r.Type == "Parent"); + Assert.Same(viteApp.Resource, parentRelationship.Resource); + + // Verify supports debugging annotation + var annotation = browserDebuggerResource.Annotations.OfType().SingleOrDefault(); + Assert.NotNull(annotation); + Assert.Equal("browser", annotation.LaunchConfigurationType); + } + + [Fact] + public void ViteApp_WithBrowserDebugger_DefaultsToEdgeBrowser() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + using var tempDir = new TestTempDirectory(); + + var viteApp = builder.AddViteApp("viteapp", tempDir.Path) + .WithBrowserDebugger(); + + using var app = builder.Build(); + var appModel = app.Services.GetRequiredService(); + + var browserDebuggerResource = appModel.Resources.OfType().Single(); + // The BrowserDebuggerResource's command is the browser name + Assert.Equal("msedge", browserDebuggerResource.Command); + } + + [Fact] + public void ViteApp_WithBrowserDebugger_UsesSpecifiedBrowser() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + using var tempDir = new TestTempDirectory(); + + var viteApp = builder.AddViteApp("viteapp", tempDir.Path) + .WithBrowserDebugger(browser: "chrome"); + + using var app = builder.Build(); + var appModel = app.Services.GetRequiredService(); + + var browserDebuggerResource = appModel.Resources.OfType().Single(); + Assert.Equal("chrome", browserDebuggerResource.Command); + } + + [Fact] + public void ViteApp_WithBrowserDebugger_WithoutEndpoint_DeferredValidation() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + using var tempDir = new TestTempDirectory(); + + // Create a minimal JavaScriptAppResource without endpoints + var resource = new JavaScriptAppResource("jsapp", "npm", tempDir.Path); + var jsApp = builder.AddResource(resource); + + // WithBrowserDebugger no longer throws immediately; endpoint validation is deferred + // to when the launch configuration callback is actually invoked at debug time + jsApp.WithBrowserDebugger(); + + using var app = builder.Build(); + var appModel = app.Services.GetRequiredService(); + + // The browser debugger resource should still be created + var browserDebuggerResource = appModel.Resources.OfType().SingleOrDefault(); + Assert.NotNull(browserDebuggerResource); + } + +#pragma warning restore ASPIREEXTENSION001 // Type is for evaluation purposes only } diff --git a/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppTests.cs b/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppTests.cs index 328cb7b7b06..cea704c8a23 100644 --- a/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppTests.cs +++ b/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppTests.cs @@ -242,8 +242,8 @@ public void AddViteApp_WithViteConfigPath_AppliesConfigArgument() var appModel = app.Services.GetRequiredService(); var nodeResource = Assert.Single(appModel.Resources.OfType()); - // Get the command line args annotation to inspect the args callback - var commandLineArgsAnnotation = nodeResource.Annotations.OfType().Single(); + // Get the first command line args annotation (WithDebugSupport adds additional callbacks) + var commandLineArgsAnnotation = nodeResource.Annotations.OfType().First(); var args = new List(); var context = new CommandLineArgsCallbackContext(args, nodeResource); commandLineArgsAnnotation.Callback(context); @@ -267,8 +267,8 @@ public void AddViteApp_WithoutViteConfigPath_DoesNotApplyConfigArgument() var appModel = app.Services.GetRequiredService(); var nodeResource = Assert.Single(appModel.Resources.OfType()); - // Get the command line args annotation to inspect the args callback - var commandLineArgsAnnotation = nodeResource.Annotations.OfType().Single(); + // Get the first command line args annotation (WithDebugSupport adds additional callbacks) + var commandLineArgsAnnotation = nodeResource.Annotations.OfType().First(); var args = new List(); var context = new CommandLineArgsCallbackContext(args, nodeResource); commandLineArgsAnnotation.Callback(context); diff --git a/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppWithPnpmTests.cs b/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppWithPnpmTests.cs index e0a6f4ce108..b30c587ae83 100644 --- a/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppWithPnpmTests.cs +++ b/tests/Aspire.Hosting.JavaScript.Tests/AddViteAppWithPnpmTests.cs @@ -27,8 +27,8 @@ public void AddViteApp_WithPnpm_DoesNotIncludeSeparator() Assert.Equal("pnpm", packageManager.ExecutableName); Assert.Equal("run", packageManager.ScriptCommand); - // Get the command line args annotation to inspect the args callback - var commandLineArgsAnnotation = nodeResource.Annotations.OfType().Single(); + // Get the first command line args annotation (WithDebugSupport adds additional callbacks) + var commandLineArgsAnnotation = nodeResource.Annotations.OfType().First(); var args = new List(); var context = new CommandLineArgsCallbackContext(args, nodeResource); commandLineArgsAnnotation.Callback(context); @@ -61,8 +61,8 @@ public void AddViteApp_WithBun_DoesNotIncludeSeparator() Assert.Equal("bun", packageManager.ExecutableName); Assert.Equal("run", packageManager.ScriptCommand); - // Get the command line args annotation to inspect the args callback - var commandLineArgsAnnotation = nodeResource.Annotations.OfType().Single(); + // Get the first command line args annotation (WithDebugSupport adds additional callbacks) + var commandLineArgsAnnotation = nodeResource.Annotations.OfType().First(); var args = new List(); var context = new CommandLineArgsCallbackContext(args, nodeResource); commandLineArgsAnnotation.Callback(context); @@ -89,8 +89,8 @@ public void AddViteApp_WithNpm_IncludesSeparator() var nodeResource = Assert.Single(appModel.Resources.OfType()); Assert.Equal("npm", nodeResource.Command); - // Get the command line args annotation to inspect the args callback - var commandLineArgsAnnotation = nodeResource.Annotations.OfType().Single(); + // Get the first command line args annotation (WithDebugSupport adds additional callbacks) + var commandLineArgsAnnotation = nodeResource.Annotations.OfType().First(); var args = new List(); var context = new CommandLineArgsCallbackContext(args, nodeResource); commandLineArgsAnnotation.Callback(context); @@ -122,8 +122,8 @@ public void AddViteApp_WithYarn_IncludesSeparator() Assert.Equal("yarn", packageManager.ExecutableName); Assert.Equal("run", packageManager.ScriptCommand); - // Get the command line args annotation to inspect the args callback - var commandLineArgsAnnotation = nodeResource.Annotations.OfType().Single(); + // Get the first command line args annotation (WithDebugSupport adds additional callbacks) + var commandLineArgsAnnotation = nodeResource.Annotations.OfType().First(); var args = new List(); var context = new CommandLineArgsCallbackContext(args, nodeResource); commandLineArgsAnnotation.Callback(context); diff --git a/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs b/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs index 6eb79c568c6..5331c4e4e24 100644 --- a/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs +++ b/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs @@ -2284,6 +2284,50 @@ private static void HasKnownCommandAnnotations(IResource resource) a => Assert.Equal(KnownResourceCommands.RestartCommand, a.Name)); } + [Fact] + public async Task PlainExecutable_LaunchConfigurationProducerThrows_FallsBackToProcess() + { + var builder = DistributedApplication.CreateBuilder(); + + var debuggableExecutable = new TestExecutableResource("test-working-directory"); + builder.AddResource(debuggableExecutable).WithDebugSupport(_ => throw new InvalidOperationException("Test exception from launch configuration producer"), "test"); + + var runSessionInfo = new RunSessionInfo + { + ProtocolsSupported = ["test"], + SupportedLaunchConfigurations = ["test"] + }; + + var configDict = new Dictionary + { + [DcpExecutor.DebugSessionPortVar] = "12345", + [KnownConfigNames.DebugSessionInfo] = JsonSerializer.Serialize(runSessionInfo), + [KnownConfigNames.ExtensionEndpoint] = "http://localhost:1234" + }; + + var configuration = new ConfigurationBuilder().AddInMemoryCollection(configDict).Build(); + + var kubernetesService = new TestKubernetesService(); + using var app = builder.Build(); + var distributedAppModel = app.Services.GetRequiredService(); + var appExecutor = CreateAppExecutor(distributedAppModel, kubernetesService: kubernetesService, configuration: configuration); + + await appExecutor.RunApplicationAsync(); + + List dcpExes = []; + var haveExes = RetryTillTrueOrTimeout(() => + { + dcpExes.Clear(); + dcpExes.AddRange(kubernetesService.CreatedResources.OfType()); + return dcpExes.Count == 1; + }, TestConstants.DefaultOrchestratorTestTimeout); + Assert.True(haveExes, $"Expected one executable but instead got {dcpExes.Count}"); + + var exe = Assert.Single(dcpExes, e => e.AppModelResourceName == "TestExecutable"); + // Should fall back to Process execution when the launch configuration producer throws + Assert.Equal(ExecutionType.Process, exe.Spec.ExecutionType); + } + private static DcpExecutor CreateAppExecutor( DistributedApplicationModel distributedAppModel, IHostEnvironment? hostEnvironment = null,