From b026fd5b5dec0b0f9f9a18aac83003900426cd6f Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Tue, 24 Mar 2026 13:11:40 -0700 Subject: [PATCH 1/4] update playground aspire configs --- .../AzureFunctionsSample/aspire.config.json | 15 ++++++++------- .../TypeScriptApps/RpsArena/aspire.config.json | 10 +++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/playground/TypeScriptApps/AzureFunctionsSample/aspire.config.json b/playground/TypeScriptApps/AzureFunctionsSample/aspire.config.json index 20eb971cfad..776ee3c965b 100644 --- a/playground/TypeScriptApps/AzureFunctionsSample/aspire.config.json +++ b/playground/TypeScriptApps/AzureFunctionsSample/aspire.config.json @@ -1,12 +1,13 @@ { - "sdk": { - "version": "13.3.0-preview.1.26163.4" + "appHost": { + "path": "AppHost/apphost.ts", + "language": "typescript/nodejs" }, - "channel": "daily", "packages": { - "Aspire.Hosting.Azure.Storage": "13.3.0-preview.1.26167.8", - "Aspire.Hosting.JavaScript": "13.3.0-preview.1.26167.8", - "Aspire.Hosting.Azure": "13.3.0-preview.1.26167.8", - "Aspire.Hosting.Azure.EventHubs": "13.3.0-preview.1.26167.8" + "Aspire.Hosting.Azure.Storage": "13.2.0", + "Aspire.Hosting.JavaScript": "13.2.0", + "Aspire.Hosting.Azure": "13.2.0", + "Aspire.Hosting.Azure.EventHubs": "13.2.0" } + } diff --git a/playground/TypeScriptApps/RpsArena/aspire.config.json b/playground/TypeScriptApps/RpsArena/aspire.config.json index 1bd1eebff0e..f5f751ac336 100644 --- a/playground/TypeScriptApps/RpsArena/aspire.config.json +++ b/playground/TypeScriptApps/RpsArena/aspire.config.json @@ -2,13 +2,9 @@ "appHost": { "path": "apphost.ts" }, - "sdk": { - "version": "13.3.0-preview.1.26163.4" - }, - "channel": "daily", "packages": { - "Aspire.Hosting.Python": "13.3.0-preview.1.26167.8", - "Aspire.Hosting.PostgreSQL": "13.3.0-preview.1.26167.8", - "Aspire.Hosting.JavaScript": "13.3.0-preview.1.26167.8" + "Aspire.Hosting.Python": "13.2.0", + "Aspire.Hosting.PostgreSQL": "13.2.0", + "Aspire.Hosting.JavaScript": "13.2.0" } } From a58fc94b75a512d207e7a104f15e8a402ea631c1 Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Tue, 24 Mar 2026 13:56:21 -0700 Subject: [PATCH 2/4] Implement automatic package restore --- extension/loc/xlf/aspire-vscode.xlf | 18 + extension/package.json | 6 + extension/package.nls.json | 6 + extension/src/extension.ts | 7 + extension/src/loc/strings.ts | 5 + .../src/utils/AspirePackageRestoreProvider.ts | 186 + extension/src/utils/settings.ts | 4 + .../AppHost/.modules/.codegen-hash | 2 +- .../AppHost/.modules/aspire.ts | 8753 ++++++++++++++--- .../AppHost/.modules/base.ts | 74 +- .../AppHost/.modules/transport.ts | 540 +- 11 files changed, 8130 insertions(+), 1471 deletions(-) create mode 100644 extension/src/utils/AspirePackageRestoreProvider.ts diff --git a/extension/loc/xlf/aspire-vscode.xlf b/extension/loc/xlf/aspire-vscode.xlf index 6d452a94459..31681f4d246 100644 --- a/extension/loc/xlf/aspire-vscode.xlf +++ b/extension/loc/xlf/aspire-vscode.xlf @@ -40,6 +40,12 @@ Aspire resource action + + Aspire restore completed + + + Aspire restore completed for {0}. + Aspire terminal @@ -58,6 +64,9 @@ Automatically open the dashboard in the browser. + + Automatically run 'aspire restore' when the workspace opens and whenever aspire.config.json changes (e.g. after switching git branches). Keeps integration packages in sync and prevents editor errors. + Build failed for project {0} with error: {1}. @@ -376,6 +385,12 @@ Running AppHosts + + Running aspire restore ({0}/{1} projects)... + + + Running aspire restore on {0}... + Scaffold a new Aspire project from a starter template. The template includes an apphost orchestrator, a sample API, and a web frontend. [Create new project](command:aspire-vscode.new) @@ -490,5 +505,8 @@ You're all set! Add integrations for databases, messaging, and cloud services, or deploy your app to production. [Add an integration](command:aspire-vscode.add) [Open Aspire docs](https://aspire.dev/docs/) + + aspire restore failed for {0}: {1} + \ No newline at end of file diff --git a/extension/package.json b/extension/package.json index 82e0715cded..f6864412266 100644 --- a/extension/package.json +++ b/extension/package.json @@ -670,6 +670,12 @@ "default": true, "description": "%configuration.aspire.enableGutterDecorations%", "scope": "window" + }, + "aspire.enableAutoRestore": { + "type": "boolean", + "default": true, + "description": "%configuration.aspire.enableAutoRestore%", + "scope": "window" } } }, diff --git a/extension/package.nls.json b/extension/package.nls.json index 241240c5769..53ba70e8a24 100644 --- a/extension/package.nls.json +++ b/extension/package.nls.json @@ -39,6 +39,7 @@ "configuration.aspire.globalAppHostsPollingInterval": "Polling interval in milliseconds for fetching all running apphosts (used in global view). Minimum: 1000.", "configuration.aspire.enableCodeLens": "Show CodeLens actions (state, restart, stop, logs) inline above resource declarations in apphost files.", "configuration.aspire.enableGutterDecorations": "Show colored status dots in the editor gutter next to resource declarations in apphost files.", + "configuration.aspire.enableAutoRestore": "Automatically run 'aspire restore' when the workspace opens and whenever aspire.config.json changes (e.g. after switching git branches). Keeps integration packages in sync and prevents editor errors.", "command.runAppHost": "Run Aspire apphost", "command.debugAppHost": "Debug Aspire apphost", "aspire-vscode.strings.noCsprojFound": "No apphost found in the current workspace.", @@ -117,6 +118,11 @@ "aspire-vscode.strings.selectDirectoryTitle": "Select directory", "aspire-vscode.strings.selectFileTitle": "Select file", "aspire-vscode.strings.enterPipelineStep": "Enter the pipeline step to execute", + "aspire-vscode.strings.runningAspireRestore": "Running aspire restore on {0}...", + "aspire-vscode.strings.runningAspireRestoreProgress": "Running aspire restore ({0}/{1} projects)...", + "aspire-vscode.strings.aspireRestoreCompleted": "Aspire restore completed for {0}.", + "aspire-vscode.strings.aspireRestoreAllCompleted": "Aspire restore completed", + "aspire-vscode.strings.aspireRestoreFailed": "aspire restore failed for {0}: {1}", "viewsContainers.aspirePanel.title": "Aspire", "views.runningAppHosts.name": "Running AppHosts", "views.runningAppHosts.loading": "Searching for running apphosts...", diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 36e3543519f..f7b406f9184 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -25,6 +25,7 @@ import { settingsCommand } from './commands/settings'; import { openLocalSettingsCommand, openGlobalSettingsCommand } from './commands/openSettings'; import { checkCliAvailableOrRedirect, checkForExistingAppHostPathInWorkspace } from './utils/workspace'; import { AspireEditorCommandProvider } from './editor/AspireEditorCommandProvider'; +import { AspirePackageRestoreProvider } from './utils/AspirePackageRestoreProvider'; import { AspireAppHostTreeProvider } from './views/AspireAppHostTreeProvider'; import { AppHostDataRepository } from './views/AppHostDataRepository'; import { installCliStableCommand, installCliDailyCommand, verifyCliInstalledCommand } from './commands/walkthroughCommands'; @@ -191,6 +192,12 @@ export async function activate(context: vscode.ExtensionContext) { // any user-visible errors should be handled within checkForExistingAppHostPathInWorkspace. }); } + + // Auto-restore: run `aspire restore` on workspace open and when aspire.config.json changes + const packageRestoreProvider = new AspirePackageRestoreProvider(terminalProvider); + context.subscriptions.push(packageRestoreProvider); + packageRestoreProvider.activate(); + // Return exported API for tests or other extensions return { rpcServerInfo: rpcServer.connectionInfo, diff --git a/extension/src/loc/strings.ts b/extension/src/loc/strings.ts index b64e1db0c79..7ebc72c346e 100644 --- a/extension/src/loc/strings.ts +++ b/extension/src/loc/strings.ts @@ -96,6 +96,11 @@ export const openCliInstallInstructions = vscode.l10n.t('See CLI installation in export const cliNotAvailable = vscode.l10n.t('Aspire CLI is not available on PATH. Please install it and restart VS Code.'); export const cliFoundAtDefaultPath = (path: string) => vscode.l10n.t('Aspire CLI found at {0}. The extension will use this path.', path); export const selectDirectoryTitle = vscode.l10n.t('Select directory'); +export const runningAspireRestore = (configPath: string) => vscode.l10n.t('Running aspire restore on {0}...', configPath); +export const runningAspireRestoreProgress = (completed: number, total: number) => vscode.l10n.t('Running aspire restore ({0}/{1} projects)...', completed, total); +export const aspireRestoreCompleted = (configPath: string) => vscode.l10n.t('Aspire restore completed for {0}.', configPath); +export const aspireRestoreAllCompleted = vscode.l10n.t('Aspire restore completed'); +export const aspireRestoreFailed = (configPath: string, error: string) => vscode.l10n.t('aspire restore failed for {0}: {1}', configPath, error); export const selectFileTitle = vscode.l10n.t('Select file'); export const enterPipelineStep = vscode.l10n.t('Enter the pipeline step to execute'); diff --git a/extension/src/utils/AspirePackageRestoreProvider.ts b/extension/src/utils/AspirePackageRestoreProvider.ts new file mode 100644 index 00000000000..ab12a0a6fd1 --- /dev/null +++ b/extension/src/utils/AspirePackageRestoreProvider.ts @@ -0,0 +1,186 @@ +import * as vscode from 'vscode'; +import path from 'path'; +import { aspireConfigFileName } from './cliTypes'; +import { findAspireSettingsFiles } from './workspace'; +import { ChildProcessWithoutNullStreams } from 'child_process'; +import { spawnCliProcess } from '../debugger/languages/cli'; +import { AspireTerminalProvider } from './AspireTerminalProvider'; +import { extensionLogOutputChannel } from './logging'; +import { getEnableAutoRestore } from './settings'; +import { runningAspireRestore, runningAspireRestoreProgress, aspireRestoreCompleted, aspireRestoreAllCompleted, aspireRestoreFailed } from '../loc/strings'; + +/** + * Runs `aspire restore` on workspace open and whenever aspire.config.json content changes + * (e.g. after a git branch switch). + */ +export class AspirePackageRestoreProvider implements vscode.Disposable { + private static readonly _maxConcurrency = 4; + + private readonly _disposables: vscode.Disposable[] = []; + private readonly _terminalProvider: AspireTerminalProvider; + private readonly _statusBarItem: vscode.StatusBarItem; + private readonly _lastContent = new Map(); // fsPath → content + private readonly _active = new Map(); // configDir → relativePath + private readonly _childProcesses = new Set(); + private readonly _timeouts = new Set>(); + private _total = 0; + private _completed = 0; + + constructor(terminalProvider: AspireTerminalProvider) { + this._terminalProvider = terminalProvider; + this._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 0); + this._disposables.push(this._statusBarItem); + } + + async activate(): Promise { + if (!getEnableAutoRestore()) { + extensionLogOutputChannel.info('Auto-restore is disabled'); + return; + } + + await this._restoreAll(); + this._watchConfigFiles(); + + this._disposables.push( + vscode.workspace.onDidChangeConfiguration(e => { + if (e.affectsConfiguration('aspire.enableAutoRestore') && getEnableAutoRestore()) { + this._restoreAll(); + } + }) + ); + } + + private async _restoreAll(): Promise { + const allConfigs = await findAspireSettingsFiles(); + const configs = allConfigs.filter(uri => uri.fsPath.endsWith(aspireConfigFileName)); + if (configs.length === 0) { + return; + } + + this._total = configs.length; + this._completed = 0; + + const pending = new Set>(); + for (const uri of configs) { + const p = this._restoreIfChanged(uri, true).finally(() => pending.delete(p)); + pending.add(p); + if (pending.size >= AspirePackageRestoreProvider._maxConcurrency) { + await Promise.race(pending); + } + } + await Promise.all(pending); + } + + private _watchConfigFiles(): void { + for (const folder of vscode.workspace.workspaceFolders ?? []) { + const watcher = vscode.workspace.createFileSystemWatcher( + new vscode.RelativePattern(folder, `**/${aspireConfigFileName}`) + ); + watcher.onDidChange(uri => this._onChanged(uri)); + watcher.onDidCreate(uri => this._onChanged(uri)); + this._disposables.push(watcher); + } + } + + private async _onChanged(uri: vscode.Uri): Promise { + if (!getEnableAutoRestore()) { + return; + } + if (this._active.size === 0) { + this._total = 1; + this._completed = 0; + } + await this._restoreIfChanged(uri, false); + } + + private async _restoreIfChanged(uri: vscode.Uri, isInitial: boolean): Promise { + try { + const content = (await vscode.workspace.fs.readFile(uri)).toString(); + const prev = this._lastContent.get(uri.fsPath); + this._lastContent.set(uri.fsPath, content); + + if (!isInitial && prev === content) { + return; + } + + const configDir = path.dirname(uri.fsPath); + const relativePath = vscode.workspace.asRelativePath(uri); + extensionLogOutputChannel.info(`${isInitial ? 'Initial' : 'Changed'} restore for ${relativePath}`); + await this._runRestore(configDir, relativePath); + } catch (error) { + extensionLogOutputChannel.warn(`Failed to read ${uri.fsPath}: ${error}`); + } + } + + private async _runRestore(configDir: string, relativePath: string): Promise { + if (this._active.has(configDir)) { + return; + } + + this._active.set(configDir, relativePath); + this._showProgress(); + + const cliPath = await this._terminalProvider.getAspireCliExecutablePath(); + await new Promise((resolve, reject) => { + const proc = spawnCliProcess(this._terminalProvider, cliPath, ['restore'], { + workingDirectory: configDir, + noExtensionVariables: true, + exitCallback: code => { + if (code === 0) { + extensionLogOutputChannel.info(aspireRestoreCompleted(relativePath)); + resolve(); + } else { + extensionLogOutputChannel.warn(aspireRestoreFailed(relativePath, `exit code ${code}`)); + reject(); + } + }, + errorCallback: error => { + extensionLogOutputChannel.warn(aspireRestoreFailed(relativePath, error.message)); + reject(error); + }, + }); + this._childProcesses.add(proc); + const timeout = setTimeout(() => { proc.kill(); reject(); }, 120_000); + this._timeouts.add(timeout); + proc.on('close', () => { + clearTimeout(timeout); + this._timeouts.delete(timeout); + this._childProcesses.delete(proc); + }); + }).finally(() => { + this._active.delete(configDir); + this._completed++; + this._showProgress(); + if (this._active.size === 0) { + const hideTimeout = setTimeout(() => { if (this._active.size === 0) { this._statusBarItem.hide(); } }, 5000); + this._timeouts.add(hideTimeout); + } + }); + } + + private _showProgress(): void { + if (this._active.size === 0) { + this._statusBarItem.text = `$(check) ${aspireRestoreAllCompleted}`; + } else if (this._total <= 1) { + this._statusBarItem.text = `$(sync~spin) ${runningAspireRestore([...this._active.values()][0])}`; + } else { + this._statusBarItem.text = `$(sync~spin) ${runningAspireRestoreProgress(this._completed, this._total)}`; + } + this._statusBarItem.show(); + } + + dispose(): void { + for (const proc of this._childProcesses) { + proc.kill(); + } + this._childProcesses.clear(); + for (const timeout of this._timeouts) { + clearTimeout(timeout); + } + this._timeouts.clear(); + for (const d of this._disposables) { + d.dispose(); + } + this._disposables.length = 0; + } +} diff --git a/extension/src/utils/settings.ts b/extension/src/utils/settings.ts index 6c1c8263617..b5f3fee2af7 100644 --- a/extension/src/utils/settings.ts +++ b/extension/src/utils/settings.ts @@ -15,3 +15,7 @@ function getAspireConfig(): vscode.WorkspaceConfiguration { export function getRegisterMcpServerInWorkspace(): boolean { return getAspireConfig().get(registerMcpServerInWorkspaceSettingName, false); } + +export function getEnableAutoRestore(): boolean { + return getAspireConfig().get('enableAutoRestore', true); +} diff --git a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/.codegen-hash b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/.codegen-hash index 1ee039ecb76..df964319f30 100644 --- a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/.codegen-hash +++ b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/.codegen-hash @@ -1 +1 @@ -13EFB4E0B636EDB57EC98A907D476D3EE9C665375083F7BE78598509BA9609EC \ No newline at end of file +796B4D35BC135A4A83400CA2B04B689917458B1DE20E4EEA93EEEA5586C0BC60 \ No newline at end of file diff --git a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/aspire.ts b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/aspire.ts index 2bbf4b17ff5..f79c30bfe6d 100644 --- a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/aspire.ts +++ b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/aspire.ts @@ -9,6 +9,7 @@ import { Handle, MarshalledHandle, AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -99,9 +100,21 @@ type NodeAppResourceHandle = Handle<'Aspire.Hosting.JavaScript/Aspire.Hosting.Ja /** Handle to ViteAppResource */ type ViteAppResourceHandle = Handle<'Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.ViteAppResource'>; +/** Handle to AfterResourcesCreatedEvent */ +type AfterResourcesCreatedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent'>; + +/** Handle to BeforeResourceStartedEvent */ +type BeforeResourceStartedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent'>; + +/** Handle to BeforeStartEvent */ +type BeforeStartEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent'>; + /** Handle to CommandLineArgsCallbackContext */ type CommandLineArgsCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext'>; +/** Handle to ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -111,6 +124,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** Handle to CSharpAppResource */ type CSharpAppResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource'>; +/** Handle to DistributedApplicationModel */ +type DistributedApplicationModelHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel'>; + /** Handle to DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -135,6 +151,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -165,15 +184,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** Handle to ReferenceExpressionBuilder */ type ReferenceExpressionBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder'>; +/** Handle to ResourceEndpointsAllocatedEvent */ +type ResourceEndpointsAllocatedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent'>; + /** Handle to ResourceLoggerService */ type ResourceLoggerServiceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService'>; /** Handle to ResourceNotificationService */ type ResourceNotificationServiceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService'>; +/** Handle to ResourceReadyEvent */ +type ResourceReadyEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent'>; + +/** Handle to ResourceStoppedEvent */ +type ResourceStoppedEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent'>; + /** Handle to ResourceUrlsCallbackContext */ type ResourceUrlsCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext'>; +/** Handle to UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -198,18 +229,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** Handle to IResourceWithContainerFiles */ type IResourceWithContainerFilesHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles'>; -/** Handle to IResourceWithServiceDiscovery */ -type IResourceWithServiceDiscoveryHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery'>; +/** Handle to IUserSecretsManager */ +type IUserSecretsManagerHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IUserSecretsManager'>; + +/** Handle to IReportingStep */ +type IReportingStepHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep'>; + +/** Handle to IReportingTask */ +type IReportingTaskHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask'>; /** Handle to PipelineConfigurationContext */ type PipelineConfigurationContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext'>; +/** Handle to PipelineContext */ +type PipelineContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext'>; + /** 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 PipelineStepFactoryContext */ +type PipelineStepFactoryContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext'>; + +/** Handle to PipelineSummary */ +type PipelineSummaryHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary'>; + /** Handle to ProjectResourceOptions */ type ProjectResourceOptionsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions'>; @@ -222,12 +268,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** Handle to IConfiguration */ type IConfigurationHandle = Handle<'Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration'>; +/** Handle to IConfigurationSection */ +type IConfigurationSectionHandle = Handle<'Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfigurationSection'>; + /** Handle to IHostEnvironment */ type IHostEnvironmentHandle = Handle<'Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment'>; /** Handle to ILogger */ type ILoggerHandle = Handle<'Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger'>; +/** Handle to ILoggerFactory */ +type ILoggerFactoryHandle = Handle<'Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory'>; + /** Handle to string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -446,6 +498,10 @@ export interface AddConsumerGroupOptions { groupName?: string; } +export interface AddContainerRegistryFromStringOptions { + repository?: string; +} + export interface AddContainerRegistryOptions { repository?: ParameterResource; } @@ -475,6 +531,11 @@ export interface AddParameterOptions { secret?: boolean; } +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; + secret?: boolean; +} + export interface AddQueueOptions { queueName?: string; } @@ -491,14 +552,48 @@ export interface AppendValueProviderOptions { format?: string; } +export interface CompleteStepMarkdownOptions { + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CompleteStepOptions { + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CompleteTaskMarkdownOptions { + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CompleteTaskOptions { + completionMessage?: string; + completionState?: string; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; } export interface PublishAsDockerFileOptions { configure?: (obj: ContainerResource) => Promise; } +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; +} + export interface RunAsEmulator1Options { configureContainer?: (obj: AzureStorageEmulatorResource) => Promise; } @@ -508,13 +603,29 @@ export interface RunAsEmulatorOptions { } export interface RunOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface SaveStateJsonOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface UpdateTaskMarkdownOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface UpdateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; } export interface WaitForCompletionOptions { exitCode?: number; } +export interface WaitForResourceStateOptions { + targetState?: string; +} + export interface WithApiVersionCheckOptions { enable?: boolean; } @@ -654,6 +765,7 @@ export interface WithPnpmOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -682,6 +794,43 @@ export interface WithYarnOptions { installArgs?: string[]; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -723,6 +872,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -797,11 +1020,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -816,6 +1040,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -833,9 +1116,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -909,6 +1192,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -931,6 +1225,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @internal */ + async _findResourceByNameInternal(name: string): Promise { + const rpcArgs: Record = { model: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/findResourceByName', + rpcArgs + ); + return new Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -944,6 +1302,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -1074,7 +1443,7 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs @@ -1192,11 +1561,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1226,6 +1618,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1244,22 +1647,93 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, - set: async (value: AbortSignal): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; } +// ============================================================================ +// InitializeResourceEvent +// ============================================================================ + +/** + * Type class for InitializeResourceEvent. + */ +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineConfigurationContext // ============================================================================ @@ -1273,6 +1747,17 @@ export class PipelineConfigurationContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the Steps property */ steps = { get: async (): Promise => { @@ -1289,6 +1774,17 @@ export class PipelineConfigurationContext { } }; + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; @@ -1320,6 +1816,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + set: async (value: AbortSignal | CancellationToken): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.setCancellationToken', + { context: this._handle, value: CancellationToken.fromValue(value) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1407,6 +1990,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1477,6 +2071,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1488,16 +2115,157 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); }, }; + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @internal */ + async _addInternal(key: string, value: string): Promise { + const rpcArgs: Record = { context: this._handle, key, value }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineSummary.add', + rpcArgs + ); + return this; + } + + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @internal */ + async _addMarkdownInternal(key: string, markdownString: string): Promise { + const rpcArgs: Record = { summary: this._handle, key, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/addMarkdown', + rpcArgs + ); + return this; + } + + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + } // ============================================================================ @@ -1681,6 +2449,325 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceLoggerService +// ============================================================================ + +/** + * Type class for ResourceLoggerService. + */ +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Completes the log stream for a resource */ + /** @internal */ + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + } + + /** Completes the log stream by resource name */ + /** @internal */ + async _completeLogByNameInternal(resourceName: string): Promise { + const rpcArgs: Record = { loggerService: this._handle, resourceName }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLogByName', + rpcArgs + ); + return this; + } + + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); + } + + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ + /** @internal */ + async _waitForResourceStateInternal(resourceName: string, targetState?: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + if (targetState !== undefined) rpcArgs.targetState = targetState; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceState', + rpcArgs + ); + return this; + } + + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + const targetState = options?.targetState; + return new ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + } + + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** Waits for all dependencies of a resource to be ready */ + /** @internal */ + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + } + + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ + /** @internal */ + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + if (state !== undefined) rpcArgs.state = state; + if (stateStyle !== undefined) rpcArgs.stateStyle = stateStyle; + await this._client.invokeCapability( + 'Aspire.Hosting/publishResourceUpdate', + rpcArgs + ); + return this; + } + + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + // ============================================================================ // ResourceUrlsCallbackContext // ============================================================================ @@ -1694,6 +2781,17 @@ export class ResourceUrlsCallbackContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Gets the Urls property */ private _urls?: AspireList; get urls(): AspireList { @@ -1710,11 +2808,23 @@ export class ResourceUrlsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); }, }; @@ -1731,6 +2841,132 @@ export class ResourceUrlsCallbackContext { } +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', + rpcArgs + ); + } + + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); + } + + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', + rpcArgs + ); + } + + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); + } + + /** Checks whether a configuration section exists */ + async exists(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/exists', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for Configuration that enables fluent chaining. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + // ============================================================================ // DistributedApplicationBuilder // ============================================================================ @@ -1754,6 +2990,17 @@ export class DistributedApplicationBuilder { }, }; + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + /** Gets the Eventing property */ eventing = { get: async (): Promise => { @@ -1776,6 +3023,17 @@ export class DistributedApplicationBuilder { }, }; + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + /** Builds the distributed application */ /** @internal */ async _buildInternal(): Promise { @@ -1791,6 +3049,21 @@ export class DistributedApplicationBuilder { return new DistributedApplicationPromise(this._buildInternal()); } + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + /** Adds a connection string with a builder callback */ /** @internal */ async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { @@ -1828,6 +3101,23 @@ export class DistributedApplicationBuilder { return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); } + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + /** Adds a container resource */ /** @internal */ async _addContainerInternal(name: string, image: string): Promise { @@ -1907,6 +3197,36 @@ export class DistributedApplicationBuilder { return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); } + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + /** Adds a parameter resource */ /** @internal */ async _addParameterInternal(name: string, secret?: boolean): Promise { @@ -1924,6 +3244,25 @@ export class DistributedApplicationBuilder { return new ParameterResourcePromise(this._addParameterInternal(name, secret)); } + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + /** Adds a parameter sourced from configuration */ /** @internal */ async _addParameterFromConfigurationInternal(name: string, configurationKey: string, secret?: boolean): Promise { @@ -2028,6 +3367,49 @@ export class DistributedApplicationBuilder { return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); } + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + /** Adds an Azure Storage resource */ /** @internal */ async _addAzureStorageInternal(name: string): Promise { @@ -2222,6 +3604,11 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.build())); } + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + /** 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))); @@ -2232,6 +3619,11 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addContainerRegistry(name, endpoint, options))); } + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + /** Adds a container resource */ addContainer(name: string, image: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); @@ -2257,11 +3649,26 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addExternalService(name, url))); } + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + /** Adds a parameter resource */ addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); } + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, 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))); @@ -2292,6 +3699,21 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addCSharpAppWithOptions(name, path, configure))); } + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + /** Adds an Azure Storage resource */ addAzureStorage(name: string): AzureStorageResourcePromise { return new AzureStorageResourcePromise(this._promise.then(obj => obj.addAzureStorage(name))); @@ -2399,6 +3821,814 @@ export class DistributedApplicationEventingPromise implements PromiseLike { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', + rpcArgs + ); + } + + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', + rpcArgs + ); + } + + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); + } + + /** Checks if the environment matches the specified name */ + async isEnvironment(environmentName: string): Promise { + const rpcArgs: Record = { environment: this._handle, environmentName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isEnvironment', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for HostEnvironment that enables fluent chaining. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); + } + + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); + } + + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); + } + + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); + } + +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ + /** @internal */ + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', + rpcArgs + ); + return this; + } + + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._logInformationInternal(message)); + } + + /** Logs a warning message */ + /** @internal */ + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', + rpcArgs + ); + return this; + } + + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._logWarningInternal(message)); + } + + /** Logs an error message */ + /** @internal */ + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', + rpcArgs + ); + return this; + } + + logError(message: string): LoggerPromise { + return new LoggerPromise(this._logErrorInternal(message)); + } + + /** Logs a debug message */ + /** @internal */ + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', + rpcArgs + ); + return this; + } + + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._logDebugInternal(message)); + } + + /** Logs a message with specified level */ + /** @internal */ + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', + rpcArgs + ); + return this; + } + + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._logInternal(level, message)); + } + +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); + } + + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); + } + + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); + } + + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); + } + + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); + } + +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ + /** @internal */ + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', + rpcArgs + ); + return new Logger(result, this._client); + } + + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); + } + +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); + } + +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ + /** @internal */ + async _createTaskInternal(statusText: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, statusText }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createTask', + rpcArgs + ); + return new ReportingTask(result, this._client); + } + + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); + } + + /** Creates a reporting task with Markdown-formatted status text */ + /** @internal */ + async _createMarkdownTaskInternal(markdownString: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, markdownString }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createMarkdownTask', + rpcArgs + ); + return new ReportingTask(result, this._client); + } + + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); + } + + /** Logs a plain-text message for the reporting step */ + /** @internal */ + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', + rpcArgs + ); + return this; + } + + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); + } + + /** Logs a Markdown-formatted message for the reporting step */ + /** @internal */ + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', + rpcArgs + ); + return this; + } + + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); + } + + /** Completes the reporting step with plain-text completion text */ + /** @internal */ + async _completeStepInternal(completionText: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, completionText }; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeStep', + rpcArgs + ); + return this; + } + + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + /** @internal */ + async _completeStepMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingStep: this._handle, markdownString }; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeStepMarkdown', + rpcArgs + ); + return this; + } + + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); + } + +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); + } + + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); + } + + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); + } + + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); + } + + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ + /** @internal */ + async _updateTaskInternal(statusText: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle, statusText }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/updateTask', + rpcArgs + ); + return this; + } + + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); + } + + /** Updates the reporting task with Markdown-formatted status text */ + /** @internal */ + async _updateTaskMarkdownInternal(markdownString: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle, markdownString }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/updateTaskMarkdown', + rpcArgs + ); + return this; + } + + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); + } + + /** Completes the reporting task with plain-text completion text */ + /** @internal */ + async _completeTaskInternal(completionMessage?: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle }; + if (completionMessage !== undefined) rpcArgs.completionMessage = completionMessage; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeTask', + rpcArgs + ); + return this; + } + + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); + } + + /** Completes the reporting task with Markdown-formatted completion text */ + /** @internal */ + async _completeTaskMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { reportingTask: this._handle, markdownString }; + if (completionState !== undefined) rpcArgs.completionState = completionState; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/completeTaskMarkdown', + rpcArgs + ); + return this; + } + + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); + } + +} + +/** + * Thenable wrapper for ReportingTask that enables fluent chaining. + */ +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); + } + + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); + } + + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); + } + + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ServiceProvider +// ============================================================================ + +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); + } + + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); + } + + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); + } + + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); + } + + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); + } + + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); + } + + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); + } + + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); + } + + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); + } + + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); + } + + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); + } + + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); + } + +} + +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); + } + + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); + } + + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); + } + + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); + } + + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); + } + + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); + } + +} + +// ============================================================================ +// UserSecretsManager +// ============================================================================ + +/** + * Type class for UserSecretsManager. + */ +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + async trySetSecret(name: string, value: string): Promise { + const rpcArgs: Record = { context: this._handle, name, value }; + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.trySetSecret', + rpcArgs + ); + } + + /** Saves state to user secrets from a JSON string */ + /** @internal */ + async _saveStateJsonInternal(json: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, json }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/saveStateJson', + rpcArgs + ); + return this; + } + + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + /** @internal */ + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting/getOrSetSecret', + rpcArgs + ); + return this; + } + + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); + } + +} + +/** + * Thenable wrapper for UserSecretsManager that enables fluent chaining. + */ +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); + } + +} + // ============================================================================ // AzureBicepResource // ============================================================================ @@ -2623,7 +4853,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2638,7 +4868,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2758,6 +4988,86 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -2773,6 +5083,135 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -3028,11 +5467,76 @@ export class AzureBicepResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -3175,6 +5679,15 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -3339,7 +5852,7 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBlobStorageContainerResource(result, this._client); @@ -3354,7 +5867,7 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBlobStorageContainerResource(result, this._client); @@ -3474,6 +5987,106 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -3546,6 +6159,11 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -3631,6 +6249,31 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -3733,6 +6376,15 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -3897,7 +6549,7 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBlobStorageResource(result, this._client); @@ -3912,7 +6564,7 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBlobStorageResource(result, this._client); @@ -4032,6 +6684,106 @@ export class AzureBlobStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -4104,6 +6856,11 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -4189,6 +6946,31 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -4291,6 +7073,15 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyValueInternal(name, value)); } + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -4455,7 +7246,7 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureDataLakeStorageFileSystemResource(result, this._client); @@ -4470,7 +7261,7 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureDataLakeStorageFileSystemResource(result, this._client); @@ -4590,6 +7381,106 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -4662,6 +7553,11 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -4747,6 +7643,31 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -4849,6 +7770,15 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -5013,7 +7943,7 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); @@ -5028,7 +7958,7 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); @@ -5148,6 +8078,106 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -5220,6 +8250,11 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -5305,6 +8340,31 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -5541,7 +8601,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -5556,7 +8616,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -5676,6 +8736,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -5853,6 +8993,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -5965,6 +9125,15 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -6129,7 +9298,7 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubConsumerGroupResource(result, this._client); @@ -6144,7 +9313,7 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubConsumerGroupResource(result, this._client); @@ -6264,6 +9433,106 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -6336,6 +9605,11 @@ export class AzureEventHubConsumerGroupResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEventHubConsumerGroupResourcePromise { return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -6421,6 +9695,31 @@ export class AzureEventHubConsumerGroupResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEventHubConsumerGroupResourcePromise { return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -6565,6 +9864,15 @@ export class AzureEventHubResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -6729,7 +10037,7 @@ export class AzureEventHubResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubResource(result, this._client); @@ -6744,7 +10052,7 @@ export class AzureEventHubResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubResource(result, this._client); @@ -6864,6 +10172,106 @@ export class AzureEventHubResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureEventHubResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureEventHubResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureEventHubResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureEventHubResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureEventHubResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -6973,6 +10381,11 @@ export class AzureEventHubResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -7058,6 +10471,31 @@ export class AzureEventHubResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -7296,7 +10734,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -7311,7 +10749,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -7453,41 +10891,11 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureEventHubsEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(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 AzureEventHubsEmulatorResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(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); + private async _withEnvironmentCallbackInternal(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( @@ -7498,43 +10906,38 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase Promise): AzureEventHubsEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -7623,10 +11026,11 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -7638,37 +11042,8 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', - rpcArgs - ); - return new AzureEventHubsEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(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 AzureEventHubsEmulatorResource(result, this._client); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + const name = options?.name; + return new AzureEventHubsEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -7968,7 +11343,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -7998,7 +11373,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8044,7 +11419,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8149,7 +11524,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8180,7 +11555,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8195,7 +11570,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8393,6 +11768,106 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -8632,31 +12107,21 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -8687,16 +12152,6 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -8902,6 +12357,31 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -9048,6 +12528,15 @@ export class AzureEventHubsResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -9373,7 +12862,7 @@ export class AzureEventHubsResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubsResource(result, this._client); @@ -9388,7 +12877,7 @@ export class AzureEventHubsResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubsResource(result, this._client); @@ -9537,6 +13026,126 @@ export class AzureEventHubsResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -9925,6 +13534,11 @@ export class AzureEventHubsResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): AzureEventHubsResourcePromise { return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -10055,6 +13669,36 @@ export class AzureEventHubsResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEventHubsResourcePromise { return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -10396,7 +14040,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -10411,7 +14055,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -10531,6 +14175,86 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -10675,6 +14399,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/configureInfrastructure', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -10930,6 +14674,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -10980,6 +14744,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -11122,6 +14891,15 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -11286,7 +15064,7 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); @@ -11301,7 +15079,7 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); @@ -11421,6 +15199,106 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -11493,6 +15371,11 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -11578,6 +15461,31 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -11680,6 +15588,15 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -11844,7 +15761,7 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureQueueStorageResource(result, this._client); @@ -11859,7 +15776,7 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureQueueStorageResource(result, this._client); @@ -11979,6 +15896,106 @@ export class AzureQueueStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -12051,6 +16068,11 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -12136,6 +16158,31 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -12364,7 +16411,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -12379,7 +16426,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -12521,41 +16568,11 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(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 AzureStorageEmulatorResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(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); + private async _withEnvironmentCallbackInternal(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( @@ -12566,43 +16583,38 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase Promise): AzureStorageEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -12691,10 +16703,11 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -12706,37 +16719,8 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(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 AzureStorageEmulatorResource(result, this._client); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + const name = options?.name; + return new AzureStorageEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -13036,7 +17020,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13066,7 +17050,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13112,7 +17096,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13217,7 +17201,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13248,7 +17232,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13263,7 +17247,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13461,6 +17445,106 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withDataBindMountInternal(path?: string, isReadOnly?: boolean): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -13768,31 +17852,21 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -13823,16 +17897,6 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -14038,6 +18102,31 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Adds a bind mount for the data folder to an Azure Storage emulator resource */ withDataBindMount(options?: WithDataBindMountOptions): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDataBindMount(options))); @@ -14499,7 +18588,7 @@ export class AzureStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureStorageResource(result, this._client); @@ -14514,7 +18603,7 @@ export class AzureStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureStorageResource(result, this._client); @@ -14663,6 +18752,106 @@ export class AzureStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _runAsEmulatorInternal(configureContainer?: (obj: AzureStorageEmulatorResource) => Promise): Promise { const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { @@ -15265,6 +19454,31 @@ export class AzureStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Configures the Azure Storage resource to be emulated using Azurite */ runAsEmulator(options?: RunAsEmulator1Options): AzureStorageResourcePromise { return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsEmulator(options))); @@ -15502,6 +19716,15 @@ export class AzureTableStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -15666,7 +19889,7 @@ export class AzureTableStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureTableStorageResource(result, this._client); @@ -15681,7 +19904,7 @@ export class AzureTableStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureTableStorageResource(result, this._client); @@ -15801,6 +20024,106 @@ export class AzureTableStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -15873,6 +20196,11 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -15958,6 +20286,31 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -16194,7 +20547,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -16209,7 +20562,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -16329,6 +20682,86 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -16748,6 +21181,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -16945,6 +21398,15 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -17057,7 +21519,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17087,7 +21549,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17133,7 +21595,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17186,7 +21648,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17201,7 +21663,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17321,6 +21783,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -17393,6 +21955,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -17503,6 +22070,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -17739,7 +22331,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -17754,7 +22346,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -17874,6 +22466,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -18021,6 +22693,26 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -18057,6 +22749,239 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(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/withParameterBuildArg', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(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/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(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 ContainerResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + /** @internal */ private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -18076,6 +23001,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -18126,58 +23066,43 @@ export class ContainerResource extends ResourceBuilderBase { - 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 }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', 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)); + /** 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 _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 _withEnvironmentCallbackInternal(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( @@ -18188,43 +23113,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: 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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', 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)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -18313,10 +23233,11 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -18328,37 +23249,8 @@ export class ContainerResource extends ResourceBuilderBase { - 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)); + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -18658,7 +23550,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -18688,7 +23580,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -18734,7 +23626,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -18839,7 +23731,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -18870,7 +23762,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -18885,7 +23777,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -19055,6 +23947,25 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -19064,6 +23975,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -19161,11 +24172,91 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -19181,36 +24272,31 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + /** 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 { + withEnvironmentCallback(callback: (arg: 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -19241,16 +24327,6 @@ export class ContainerResourcePromise implements PromiseLike 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))); @@ -19446,11 +24522,41 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -19640,41 +24746,11 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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); + private async _withEnvironmentCallbackInternal(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( @@ -19685,43 +24761,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: 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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', 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)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -19810,10 +24881,11 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -19825,37 +24897,8 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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)); + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -20140,7 +25183,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20170,7 +25213,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20200,7 +25243,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20246,7 +25289,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20351,7 +25394,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20382,7 +25425,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20397,7 +25440,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20576,6 +25619,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -20713,31 +25856,21 @@ export class CSharpAppResourcePromise implements PromiseLike 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 { + withEnvironmentCallback(callback: (arg: 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -20768,16 +25901,6 @@ export class CSharpAppResourcePromise implements PromiseLike 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))); @@ -20983,6 +26106,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -21275,41 +26423,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - 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); + private async _withEnvironmentCallbackInternal(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( @@ -21320,43 +26438,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: 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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', 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)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -21445,10 +26558,11 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -21460,37 +26574,8 @@ export class DotnetToolResource extends ResourceBuilderBase { - 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)); + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -21790,7 +26875,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -21820,7 +26905,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -21866,7 +26951,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -21971,7 +27056,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22002,7 +27087,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22017,7 +27102,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22196,6 +27281,106 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -22368,31 +27553,21 @@ export class DotnetToolResourcePromise implements PromiseLike 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 { + withEnvironmentCallback(callback: (arg: 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -22423,16 +27598,6 @@ export class DotnetToolResourcePromise implements PromiseLike 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))); @@ -22633,6 +27798,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -22703,6 +27893,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(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 ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -22770,41 +28025,11 @@ export class ExecutableResource extends ResourceBuilderBase { - 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); + private async _withEnvironmentCallbackInternal(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( @@ -22815,43 +28040,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: 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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', 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)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -22940,10 +28160,11 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -22955,37 +28176,8 @@ export class ExecutableResource extends ResourceBuilderBase { - 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)); + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -23285,7 +28477,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23315,7 +28507,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23361,7 +28553,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23466,7 +28658,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23497,7 +28689,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23512,7 +28704,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23691,6 +28883,106 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -23793,6 +29085,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -23813,31 +29125,21 @@ export class ExecutableResourcePromise implements PromiseLike 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 { + withEnvironmentCallback(callback: (arg: 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -23868,16 +29170,6 @@ export class ExecutableResourcePromise implements PromiseLike 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))); @@ -24078,6 +29370,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -24348,7 +29665,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -24363,7 +29680,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -24483,6 +29800,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -24635,6 +30032,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -24656,6 +30073,36 @@ export class JavaScriptAppResource extends ResourceBuilderBase => { + 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 }; @@ -24822,41 +30269,11 @@ export class JavaScriptAppResource extends ResourceBuilderBase { - 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); + private async _withEnvironmentCallbackInternal(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( @@ -24867,43 +30284,38 @@ export class JavaScriptAppResource extends ResourceBuilderBase Promise): JavaScriptAppResourcePromise { + withEnvironmentCallback(callback: (arg: 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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', 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)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -24992,10 +30404,11 @@ export class JavaScriptAppResource extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -25007,37 +30420,8 @@ export class JavaScriptAppResource extends ResourceBuilderBase { - 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)); + const name = options?.name; + return new JavaScriptAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -25367,7 +30751,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -25397,7 +30781,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -25443,7 +30827,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -25548,7 +30932,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -25579,7 +30963,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -25594,7 +30978,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -25773,6 +31157,106 @@ export class JavaScriptAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -25788,6 +31272,135 @@ export class JavaScriptAppResource extends ResourceBuilderBase { + 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 JavaScriptAppResource(result, this._client); + } + + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installCommand = options?.installCommand; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromise(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 JavaScriptAppResource(result, this._client); + } + + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromise(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 JavaScriptAppResource(result, this._client); + } + + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromise(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 JavaScriptAppResource(result, this._client); + } + + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): JavaScriptAppResourcePromise { + const install = options?.install; + const installArgs = options?.installArgs; + return new JavaScriptAppResourcePromise(this._withPnpmInternal(install, installArgs)); + } + + /** @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 JavaScriptAppResource(result, this._client); + } + + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): JavaScriptAppResourcePromise { + const args = options?.args; + return new JavaScriptAppResourcePromise(this._withBuildScriptInternal(scriptName, args)); + } + + /** @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', + rpcArgs + ); + return new JavaScriptAppResource(result, this._client); + } + + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): JavaScriptAppResourcePromise { + const args = options?.args; + return new JavaScriptAppResourcePromise(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 JavaScriptAppResource(result, this._client); + } + + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): JavaScriptAppResourcePromise { + const browser = options?.browser; + return new JavaScriptAppResourcePromise(this._withBrowserDebuggerInternal(browser)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -25915,31 +31528,21 @@ export class JavaScriptAppResourcePromise implements PromiseLike 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 { + withEnvironmentCallback(callback: (arg: 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -25970,16 +31573,6 @@ export class JavaScriptAppResourcePromise implements PromiseLike 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))); @@ -26190,11 +31783,71 @@ export class JavaScriptAppResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): JavaScriptAppResourcePromise { return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } + /** Configures npm as the package manager */ + withNpm(options?: WithNpmOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withNpm(options))); + } + + /** Configures Bun as the package manager */ + withBun(options?: WithBunOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withBun(options))); + } + + /** Configures yarn as the package manager */ + withYarn(options?: WithYarnOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withYarn(options))); + } + + /** Configures pnpm as the package manager */ + withPnpm(options?: WithPnpmOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withPnpm(options))); + } + + /** Specifies an npm script to run before starting the application */ + withBuildScript(scriptName: string, options?: WithBuildScriptOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withBuildScript(scriptName, options))); + } + + /** Specifies an npm script to run during development */ + withRunScript(scriptName: string, options?: WithRunScriptOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withRunScript(scriptName, options))); + } + + /** Configures a browser debugger for the JavaScript application */ + withBrowserDebugger(options?: WithBrowserDebuggerOptions): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withBrowserDebugger(options))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): JavaScriptAppResourcePromise { return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -26422,41 +32075,11 @@ export class NodeAppResource extends ResourceBuilderBase } /** @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); + private async _withEnvironmentCallbackInternal(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( @@ -26467,43 +32090,38 @@ export class NodeAppResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + withEnvironmentCallback(callback: (arg: 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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', 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)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -26592,10 +32210,11 @@ export class NodeAppResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -26607,37 +32226,8 @@ export class NodeAppResource extends ResourceBuilderBase 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)); + const name = options?.name; + return new NodeAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -26922,7 +32512,7 @@ export class NodeAppResource extends ResourceBuilderBase 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', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new NodeAppResource(result, this._client); @@ -26982,7 +32572,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new NodeAppResource(result, this._client); @@ -27012,7 +32602,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new NodeAppResource(result, this._client); @@ -27058,7 +32648,7 @@ export class NodeAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new NodeAppResource(result, this._client); @@ -27163,7 +32753,7 @@ export class NodeAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new NodeAppResource(result, this._client); @@ -27194,7 +32784,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new NodeAppResource(result, this._client); @@ -27209,7 +32799,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new NodeAppResource(result, this._client); @@ -27388,6 +32978,106 @@ export class NodeAppResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new NodeAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -27659,31 +33349,21 @@ export class NodeAppResourcePromise implements PromiseLike { return new NodeAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - 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): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -27714,16 +33394,6 @@ export class NodeAppResourcePromise implements PromiseLike { return new NodeAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - 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))); @@ -27939,6 +33609,31 @@ export class NodeAppResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): NodeAppResourcePromise { return new NodeAppResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -28242,7 +33937,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -28257,7 +33952,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -28377,6 +34072,86 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -28529,6 +34304,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -28634,74 +34429,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (configure !== undefined) rpcArgs.configure = configureId; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @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 _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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -28709,15 +34506,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -28735,6 +34532,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -28821,10 +34633,11 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -28836,37 +34649,8 @@ export class ProjectResource extends ResourceBuilderBase withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { const connectionName = options?.connectionName; const optional = options?.optional; - return new ProjectResourcePromise(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 ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - 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)); + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -29151,7 +34935,7 @@ export class ProjectResource extends ResourceBuilderBase 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', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -29181,7 +34965,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -29211,7 +34995,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -29257,7 +35041,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -29362,7 +35146,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -29393,7 +35177,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -29408,7 +35192,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -29587,6 +35371,106 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -29704,29 +35588,29 @@ export class ProjectResourcePromise implements PromiseLike { 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 the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -29734,6 +35618,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -29764,16 +35653,6 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - 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))); @@ -29979,6 +35858,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -30211,41 +36115,11 @@ export class ViteAppResource extends ResourceBuilderBase } /** @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 ViteAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ViteAppResourcePromise { - return new ViteAppResourcePromise(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 ViteAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ViteAppResourcePromise { - return new ViteAppResourcePromise(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); + private async _withEnvironmentCallbackInternal(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( @@ -30256,43 +36130,38 @@ export class ViteAppResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { return new ViteAppResourcePromise(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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', 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 an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -30381,10 +36250,11 @@ export class ViteAppResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -30396,37 +36266,8 @@ export class ViteAppResource extends ResourceBuilderBase withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ViteAppResourcePromise { const connectionName = options?.connectionName; const optional = options?.optional; - return new ViteAppResourcePromise(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 ViteAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ViteAppResourcePromise { - 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)); + const name = options?.name; + return new ViteAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -30756,7 +36597,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ViteAppResource(result, this._client); @@ -30786,7 +36627,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ViteAppResource(result, this._client); @@ -30832,7 +36673,7 @@ export class ViteAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ViteAppResource(result, this._client); @@ -30937,7 +36778,7 @@ export class ViteAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ViteAppResource(result, this._client); @@ -30968,7 +36809,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ViteAppResource(result, this._client); @@ -30983,7 +36824,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ViteAppResource(result, this._client); @@ -31162,6 +37003,106 @@ export class ViteAppResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new ViteAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -31448,31 +37389,21 @@ export class ViteAppResourcePromise implements PromiseLike { 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))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { - 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -31503,16 +37434,6 @@ export class ViteAppResourcePromise implements PromiseLike { return new ViteAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ViteAppResourcePromise { - 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))); @@ -31723,6 +37644,31 @@ export class ViteAppResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -32087,7 +38033,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -32346,7 +38292,7 @@ export class Resource extends ResourceBuilderBase { private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -32361,7 +38307,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -32481,6 +38427,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onInitializeResource', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -32628,6 +38654,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -32777,6 +38823,35 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onConnectionStringAvailable', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -32804,6 +38879,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -33092,6 +39177,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -33159,6 +39264,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -33201,41 +39311,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(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 ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(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); + private async _withEnvironmentCallbackInternal(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( @@ -33246,43 +39326,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(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 }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', 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)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -33316,10 +39391,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; if (connectionName !== undefined) rpcArgs.connectionName = connectionName; if (optional !== undefined) rpcArgs.optional = optional; + if (name !== undefined) rpcArgs.name = name; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReference', rpcArgs @@ -33331,37 +39407,8 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(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 ResourceWithEnvironment(result, this._client); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -33444,7 +39491,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -33528,31 +39575,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => 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 on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** 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))); @@ -33568,16 +39605,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => 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))); @@ -33625,34 +39652,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -33666,7 +39665,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -33696,7 +39695,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -33727,7 +39726,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -33846,7 +39845,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); 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.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, 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.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, 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.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, 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('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureBlobStorageContainerResource', (handle, client) => new AzureBlobStorageContainerResource(handle as AzureBlobStorageContainerResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureBlobStorageResource', (handle, client) => new AzureBlobStorageResource(handle as AzureBlobStorageResourceHandle, client)); @@ -33950,6 +39972,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW 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)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/base.ts b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/base.ts index 9a3427e7e72..b3d8b8be98c 100644 --- a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/base.ts +++ b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +export { Handle, AspireClient, CapabilityError, CancellationToken, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; export type { MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './transport.js'; @@ -138,7 +138,7 @@ export class ReferenceExpression { if (this.isConditional) { return { $expr: { - condition: this._condition instanceof Handle ? this._condition.toJSON() : this._condition, + condition: extractHandleForExpr(this._condition), whenTrue: this._whenTrue!.toJSON(), whenFalse: this._whenFalse!.toJSON(), matchValue: this._matchValue! @@ -154,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * Resolves the expression to its string value on the server. + * Only available on server-returned ReferenceExpression instances (handle mode). + * + * @param cancellationToken - Optional AbortSignal or CancellationToken for cancellation support + * @returns The resolved string value, or null if the expression resolves to null + */ + async getValue(cancellationToken?: AbortSignal | CancellationToken): Promise { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -168,6 +192,10 @@ export class ReferenceExpression { } } +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression', (handle, client) => + new ReferenceExpression(handle, client) +); + /** * Extracts a value for use in reference expressions. * Supports handles (objects) and string literals. @@ -193,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // Objects with marshalled expression/handle payloads + if (typeof value === 'object' && value !== null && ('$handle' in value || '$expr' in value)) { return value; } - // Objects with toJSON that returns a handle + // Objects with toJSON that returns a marshalled expression or handle if (typeof value === 'object' && value !== null && 'toJSON' in value && typeof value.toJSON === 'function') { const json = value.toJSON(); - if (json && typeof json === 'object' && '$handle' in json) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -364,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + async toTransportValue(): Promise { + const handle = await this._ensureHandle(); + return handle.toJSON(); + } + + toJSON(): MarshalledHandle { + if (!this._resolvedHandle) { + throw new Error( + 'AspireList must be resolved before it can be serialized directly. ' + + 'Pass it to generated SDK methods instead of calling JSON.stringify directly.' + ); } - return this._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -523,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + async toTransportValue(): Promise { const handle = await this._ensureHandle(); return handle.toJSON(); } + + toJSON(): MarshalledHandle { + if (!this._resolvedHandle) { + throw new Error( + 'AspireDict must be resolved before it can be serialized directly. ' + + 'Pass it to generated SDK methods instead of calling JSON.stringify directly.' + ); + } + + return this._resolvedHandle.toJSON(); + } } diff --git a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/transport.ts b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/transport.ts index 7ee1ba87e3f..6d29cf289d9 100644 --- a/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/transport.ts +++ b/playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +function isPlainObject(value: unknown): value is Record { + if (value === null || typeof value !== 'object') { + return false; + } + + const prototype = Object.getPrototypeOf(value); + return prototype === Object.prototype || prototype === null; +} + +function hasTransportValue(value: unknown): value is { toTransportValue(): unknown | Promise } { + return ( + value !== null && + typeof value === 'object' && + 'toTransportValue' in value && + typeof (value as { toTransportValue?: unknown }).toTransportValue === 'function' + ); +} + +function createAbortError(message: string): Error { + const error = new Error(message); + error.name = 'AbortError'; + return error; +} + +function createCircularReferenceError(capabilityId: string, path: string): AppHostUsageError { + return new AppHostUsageError( + `Argument '${path}' passed to capability '${capabilityId}' contains a circular reference. ` + + 'Circular references are not supported by the AppHost transport.' + ); +} + // ============================================================================ // Handle // ============================================================================ @@ -136,6 +178,92 @@ export class Handle { } } +// ============================================================================ +// CancellationToken +// ============================================================================ + +/** + * Represents a transport-safe cancellation token value for the generated SDK. + * + * Use a plain {@link AbortSignal} when you create cancellation in user code. + * Generated APIs accept either an {@link AbortSignal} or a {@link CancellationToken}. + * + * Values returned from generated callbacks and context/property getters are + * {@link CancellationToken} instances because they may reference remote + * cancellation token handles received from the AppHost. + * + * @example + * ```typescript + * const controller = new AbortController(); + * await connectionStringExpression.getValue(controller.signal); + * ``` + * + * @example + * ```typescript + * const cancellationToken = await context.cancellationToken.get(); + * const connectionStringExpression = await db.uriExpression.get(); + * const connectionString = await connectionStringExpression.getValue(cancellationToken); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + static from(signal?: AbortSignal): CancellationToken { + return new CancellationToken(signal); + } + + /** + * Creates a cancellation token from a transport value. + * Generated code uses this to materialize values that come from the AppHost. + */ + static fromValue(value: unknown): CancellationToken { + if (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - if (isMarshalledHandle(value)) { - const handle = new Handle(value); - const typeId = value.$type; - - // Try to find a registered wrapper factory for this type - if (typeId && client) { - const factory = handleWrapperRegistry.get(typeId); - if (factory) { - return factory(handle, client); - } + if (isMarshalledHandle(value)) { + const handle = new Handle(value); + const typeId = value.$type; + + // Try to find a registered wrapper factory for this type + if (typeId && client) { + const factory = handleWrapperRegistry.get(typeId); + if (factory) { + return factory(handle, client); } + } + + return handle; + } - return handle; + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + value[i] = wrapIfHandle(value[i], client); + } + + return value; + } + + if (isPlainObject(value)) { + for (const [key, nestedValue] of Object.entries(value)) { + value[key] = wrapIfHandle(nestedValue, client); } } + return value; } @@ -240,9 +381,7 @@ function validateCapabilityArgs( return; } - const seen = new Set(); - - const validateValue = (value: unknown, path: string): void => { + const validateValue = (value: unknown, path: string, ancestors: Set): void => { if (value === null || value === undefined) { return; } @@ -259,26 +398,29 @@ function validateCapabilityArgs( return; } - if (seen.has(value)) { - return; + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); } - seen.add(value); - - if (Array.isArray(value)) { - for (let i = 0; i < value.length; i++) { - validateValue(value[i], `${path}[${i}]`); + ancestors.add(value); + try { + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + validateValue(value[i], `${path}[${i}]`, ancestors); + } + return; } - return; - } - for (const [key, nestedValue] of Object.entries(value)) { - validateValue(nestedValue, `${path}.${key}`); + for (const [key, nestedValue] of Object.entries(value)) { + validateValue(nestedValue, `${path}.${key}`, ancestors); + } + } finally { + ancestors.delete(value); } }; for (const [key, value] of Object.entries(args)) { - validateValue(value, key); + validateValue(value, key, new Set()); } } @@ -393,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + if (client) { + return client; + } + + if (connectedClients.size === 1) { + return connectedClients.values().next().value as AspireClient; + } + + if (connectedClients.size === 0) { + throw new Error( + 'registerCancellation(signal) requires a connected AspireClient. ' + + 'Pass the client explicitly or connect the client first.' + ); + } + + throw new Error( + 'registerCancellation(signal) is ambiguous when multiple AspireClient instances are connected. ' + + 'Pass the client explicitly.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * Registers cancellation support for a local signal or SDK cancellation token. + * Returns a cancellation ID that should be passed to methods accepting cancellation input. * * When the AbortSignal is aborted, sends a cancelToken request to the host. * - * @param signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @param client - The AspireClient that should route the cancellation request + * @param signalOrToken - The signal or token to register (optional) + * @returns The cancellation ID, or undefined if no value was provided or the token maps to CancellationToken.None + */ +export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | CancellationToken): string | undefined; +/** + * Registers cancellation support using the single connected AspireClient. + * + * @param signalOrToken - The signal or token to register (optional) + * @returns The cancellation ID, or undefined if no value was provided or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -415,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -430,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -450,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + const cancellationId = value.register(client); + if (cancellationId !== undefined) { + cancellationIds.push(cancellationId); + } + + return cancellationId; + } + + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); + } + + const nextAncestors = new Set(ancestors); + nextAncestors.add(value); + + if (hasTransportValue(value)) { + return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, nextAncestors); + } + + if (Array.isArray(value)) { + return await Promise.all( + value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, nextAncestors)) + ); + } + + if (isPlainObject(value)) { + const entries = await Promise.all( + Object.entries(value).map(async ([key, nestedValue]) => + [key, await marshalTransportValue(nestedValue, client, cancellationIds, capabilityId, `${path}.${key}`, nextAncestors)] as const) + ); + + return Object.fromEntries(entries); + } + + return value; +} + /** * Unregister a cancellation token by its ID. * Call this when the operation completes to clean up resources. @@ -480,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -491,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -501,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + if (this.connected) { + return Promise.resolve(); + } - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + if (this._connectPromise) { + return this._connectPromise; + } + + this._disconnectNotified = false; + + // On Windows, use named pipes; on Unix, use Unix domain sockets + const isWindows = process.platform === 'win32'; + const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; - this.socket = net.createConnection(pipePath); + this._connectPromise = new Promise((resolve, reject) => { + const socket = net.createConnection(pipePath); + this.socket = socket; - this.socket.once('error', (error: Error) => { + let settled = false; + + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; + + const failConnect = (error: Error) => { + if (settled) { + return; + } + + settled = true; clearTimeout(timeout); + cleanupPendingListeners(); + this._connectPromise = null; + + if (this.socket === socket) { + this.socket = null; + } + + if (!socket.destroyed) { + socket.destroy(); + } + reject(error); - }); + }; + + const onConnectedSocketError = (error: Error) => { + console.error('Socket error:', error); + }; + + const onConnectedSocketClose = () => { + socket.removeListener('error', onConnectedSocketError); + + if (this.socket && this.socket !== socket) { + return; + } + + const connection = this.connection; + this.connection = null; + this._connectPromise = null; + + if (this.socket === socket) { + this.socket = null; + } + + connectedClients.delete(this); + + try { + connection?.dispose(); + } catch { + // Ignore connection disposal errors during shutdown. + } + + this.notifyDisconnect(); + }; + + const onPendingError = (error: Error) => { + failConnect(error); + }; + + const onPendingClose = () => { + failConnect(new Error('Connection closed before JSON-RPC was established')); + }; + + const onConnect = async () => { + if (settled) { + return; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + const reader = new rpc.SocketMessageReader(socket); + const writer = new rpc.SocketMessageWriter(socket); this.connection = rpc.createMessageConnection(reader, writer); this.connection.onClose(() => { this.connection = null; - this.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -544,26 +864,39 @@ export class AspireClient { } }); + socket.on('error', onConnectedSocketError); + socket.on('close', onConnectedSocketClose); + + const authToken = process.env.ASPIRE_REMOTE_APPHOST_TOKEN; + if (!authToken) { + throw new Error('ASPIRE_REMOTE_APPHOST_TOKEN environment variable is not set.'); + } this.connection.listen(); + const authenticated = await this.connection.sendRequest('authenticate', authToken); + if (!authenticated) { + throw new Error('Failed to authenticate to the AppHost server.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + const timeout = setTimeout(() => { + failConnect(new Error('Connection timeout')); + }, timeoutMs); + + socket.once('error', onPendingError); + socket.once('close', onPendingClose); + socket.once('connect', onConnect); }); + + return this._connectPromise; } ping(): Promise { @@ -603,40 +936,65 @@ export class AspireClient { } validateCapabilityArgs(capabilityId, args); - - // Ref counting: The vscode-jsonrpc socket keeps Node's event loop alive. - // We ref() during RPC calls so the process doesn't exit mid-call, and - // unref() when idle so the process can exit naturally after all work completes. - if (this._pendingCalls === 0) { - this.socket?.ref(); - } - this._pendingCalls++; + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // Ref counting: The vscode-jsonrpc socket keeps Node's event loop alive. + // We ref() during RPC calls so the process doesn't exit mid-call, and + // unref() when idle so the process can exit naturally after all work completes. + if (this._pendingCalls === 0) { + this.socket?.ref(); } + this._pendingCalls++; + + try { + const result = await this.connection.sendRequest( + 'invokeCapability', + capabilityId, + rpcArgs + ); + + // Check for structured error response + if (isAtsError(result)) { + throw new CapabilityError(result.$error); + } - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + // Wrap handles automatically + return wrapIfHandle(result, this) as T; + } finally { + this._pendingCalls--; + if (this._pendingCalls === 0) { + this.socket?.unref(); + } + } } finally { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + const connection = this.connection; + const socket = this.socket; + + this.connection = null; + this.socket = null; + this._connectPromise = null; + connectedClients.delete(this); + + try { + connection?.dispose(); + } catch { + // Ignore connection disposal errors during shutdown. + } + + if (socket && !socket.destroyed) { + socket.end(); + socket.destroy(); + } } get connected(): boolean { From c91c4f71c7c4cec8f53e0b3be4348e9f0cb9263b Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Tue, 24 Mar 2026 14:31:13 -0700 Subject: [PATCH 3/4] Address PR review comments: fix activate() early return, queue pending restores, separate errors, fix timeout leak, handle unhandled promise --- extension/src/extension.ts | 4 +- .../src/utils/AspirePackageRestoreProvider.ts | 68 ++++++++++++------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/extension/src/extension.ts b/extension/src/extension.ts index f7b406f9184..14eb82deddd 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -196,7 +196,9 @@ export async function activate(context: vscode.ExtensionContext) { // Auto-restore: run `aspire restore` on workspace open and when aspire.config.json changes const packageRestoreProvider = new AspirePackageRestoreProvider(terminalProvider); context.subscriptions.push(packageRestoreProvider); - packageRestoreProvider.activate(); + void packageRestoreProvider.activate().catch(err => { + extensionLogOutputChannel.warn(`Auto-restore activation failed: ${String(err)}`); + }); // Return exported API for tests or other extensions return { diff --git a/extension/src/utils/AspirePackageRestoreProvider.ts b/extension/src/utils/AspirePackageRestoreProvider.ts index ab12a0a6fd1..31db746a3a9 100644 --- a/extension/src/utils/AspirePackageRestoreProvider.ts +++ b/extension/src/utils/AspirePackageRestoreProvider.ts @@ -23,6 +23,7 @@ export class AspirePackageRestoreProvider implements vscode.Disposable { private readonly _active = new Map(); // configDir → relativePath private readonly _childProcesses = new Set(); private readonly _timeouts = new Set>(); + private readonly _pendingRestore = new Set(); // configDirs needing re-restore private _total = 0; private _completed = 0; @@ -33,14 +34,6 @@ export class AspirePackageRestoreProvider implements vscode.Disposable { } async activate(): Promise { - if (!getEnableAutoRestore()) { - extensionLogOutputChannel.info('Auto-restore is disabled'); - return; - } - - await this._restoreAll(); - this._watchConfigFiles(); - this._disposables.push( vscode.workspace.onDidChangeConfiguration(e => { if (e.affectsConfiguration('aspire.enableAutoRestore') && getEnableAutoRestore()) { @@ -48,6 +41,14 @@ export class AspirePackageRestoreProvider implements vscode.Disposable { } }) ); + + if (!getEnableAutoRestore()) { + extensionLogOutputChannel.info('Auto-restore is disabled'); + return; + } + + await this._restoreAll(); + this._watchConfigFiles(); } private async _restoreAll(): Promise { @@ -94,29 +95,43 @@ export class AspirePackageRestoreProvider implements vscode.Disposable { } private async _restoreIfChanged(uri: vscode.Uri, isInitial: boolean): Promise { + let content: string; try { - const content = (await vscode.workspace.fs.readFile(uri)).toString(); - const prev = this._lastContent.get(uri.fsPath); - this._lastContent.set(uri.fsPath, content); - - if (!isInitial && prev === content) { - return; - } - - const configDir = path.dirname(uri.fsPath); - const relativePath = vscode.workspace.asRelativePath(uri); - extensionLogOutputChannel.info(`${isInitial ? 'Initial' : 'Changed'} restore for ${relativePath}`); - await this._runRestore(configDir, relativePath); + content = (await vscode.workspace.fs.readFile(uri)).toString(); } catch (error) { extensionLogOutputChannel.warn(`Failed to read ${uri.fsPath}: ${error}`); + return; } - } - private async _runRestore(configDir: string, relativePath: string): Promise { + const prev = this._lastContent.get(uri.fsPath); + if (!isInitial && prev === content) { + return; + } + + const configDir = path.dirname(uri.fsPath); + const relativePath = vscode.workspace.asRelativePath(uri); + extensionLogOutputChannel.info(`${isInitial ? 'Initial' : 'Changed'} restore for ${relativePath}`); + + // Don't update baseline until restore succeeds; queue re-restore if one is already active if (this._active.has(configDir)) { + this._pendingRestore.add(configDir); return; } + this._lastContent.set(uri.fsPath, content); + try { + await this._runRestore(configDir, relativePath); + } catch (error) { + extensionLogOutputChannel.warn(`Restore failed for ${relativePath}: ${error}`); + } + + // If a change arrived while we were restoring, re-read and restore again + if (this._pendingRestore.delete(configDir)) { + await this._restoreIfChanged(uri, false); + } + } + + private async _runRestore(configDir: string, relativePath: string): Promise { this._active.set(configDir, relativePath); this._showProgress(); @@ -131,7 +146,7 @@ export class AspirePackageRestoreProvider implements vscode.Disposable { resolve(); } else { extensionLogOutputChannel.warn(aspireRestoreFailed(relativePath, `exit code ${code}`)); - reject(); + reject(new Error(`exit code ${code}`)); } }, errorCallback: error => { @@ -140,7 +155,7 @@ export class AspirePackageRestoreProvider implements vscode.Disposable { }, }); this._childProcesses.add(proc); - const timeout = setTimeout(() => { proc.kill(); reject(); }, 120_000); + const timeout = setTimeout(() => { proc.kill(); reject(new Error('restore timed out')); }, 120_000); this._timeouts.add(timeout); proc.on('close', () => { clearTimeout(timeout); @@ -152,7 +167,10 @@ export class AspirePackageRestoreProvider implements vscode.Disposable { this._completed++; this._showProgress(); if (this._active.size === 0) { - const hideTimeout = setTimeout(() => { if (this._active.size === 0) { this._statusBarItem.hide(); } }, 5000); + const hideTimeout = setTimeout(() => { + this._timeouts.delete(hideTimeout); + if (this._active.size === 0) { this._statusBarItem.hide(); } + }, 5000); this._timeouts.add(hideTimeout); } }); From a3b763165d7553d84257bc723ee80d78a8948bd6 Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Wed, 25 Mar 2026 12:37:37 -0700 Subject: [PATCH 4/4] Update extension/package.nls.json Co-authored-by: Ankit Jain --- extension/package.nls.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/package.nls.json b/extension/package.nls.json index 53ba70e8a24..f3c9e231142 100644 --- a/extension/package.nls.json +++ b/extension/package.nls.json @@ -118,7 +118,7 @@ "aspire-vscode.strings.selectDirectoryTitle": "Select directory", "aspire-vscode.strings.selectFileTitle": "Select file", "aspire-vscode.strings.enterPipelineStep": "Enter the pipeline step to execute", - "aspire-vscode.strings.runningAspireRestore": "Running aspire restore on {0}...", + "aspire-vscode.strings.runningAspireRestore": "Running aspire restore on {0} ...", "aspire-vscode.strings.runningAspireRestoreProgress": "Running aspire restore ({0}/{1} projects)...", "aspire-vscode.strings.aspireRestoreCompleted": "Aspire restore completed for {0}.", "aspire-vscode.strings.aspireRestoreAllCompleted": "Aspire restore completed",