From b286f89807119696eebd21082141709dd8cca213 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 26 Mar 2026 15:55:43 -0700 Subject: [PATCH 1/4] Fix TypeScript codegen typing for reusable packages - generate structural handle-bearing input types for interface-handle parameters - align generated wrapper property objects with setter capabilities - update snapshots and regenerate tracked TypeScript validation apphost modules Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 19 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 19 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 19 + .../ValidationAppHost/aspire.config.json | 19 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 19 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 19 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 19 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../.modules/.codegen-hash | 1 + .../.modules/aspire.ts | 21672 ++++++++++++++++ .../Aspire.Hosting.SqlServer/.modules/base.ts | 586 + .../.modules/transport.ts | 1019 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/aspire.config.json | 21 + .../AtsTypeScriptCodeGenerator.cs | 282 +- .../Resources/base.ts | 42 +- .../Resources/transport.ts | 36 +- .../AtsTypeScriptCodeGeneratorTests.cs | 24 +- .../Snapshots/AtsGeneratedAspire.verified.ts | 471 +- ...TwoPassScanningGeneratedAspire.verified.ts | 9936 ++++--- .../WithDataVolumeOptionsMerged.verified.ts | 2 +- .../Snapshots/base.verified.ts | 40 +- .../Snapshots/transport.verified.ts | 36 +- 61 files changed, 30731 insertions(+), 4290 deletions(-) create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..90a92f76c30 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.AppConfiguration": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..c0b2dab06a6 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json @@ -0,0 +1,19 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:49511;http://localhost:51415", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:48887", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:33229" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.AppContainers": "", + "Aspire.Hosting.Azure.OperationalInsights": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..4b3029c52fd --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:49511;http://localhost:51415", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:48887", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:33229" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.AppService": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..dccb0d3c2ed --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json @@ -0,0 +1,19 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:43145;http://localhost:38016", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:43154", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:41056" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.ApplicationInsights": "", + "Aspire.Hosting.Azure.OperationalInsights": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..8a35fe619ef --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:55134;http://localhost:18351", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:34251", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:60108" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.CognitiveServices": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..09e159192da --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json @@ -0,0 +1,19 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.ContainerRegistry": "", + "Aspire.Hosting.Azure.AppContainers": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..999262fdac7 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json @@ -0,0 +1,19 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:52066;http://localhost:47700", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62976", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34207" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.CosmosDB": "", + "Aspire.Hosting.Azure.KeyVault": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..b1f8bd42a1e --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.EventHubs": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..7af441395ff --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json @@ -0,0 +1,19 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:43912;http://localhost:19322", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:30254", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:15931" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.Functions": "", + "Aspire.Hosting.Azure.Storage": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..c72f101e58f --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:52800;http://localhost:51322", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10120", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:11479" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.KeyVault": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..2f865da8beb --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.Kusto": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..02118f93186 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:52066;http://localhost:47700", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62976", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34207" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.OperationalInsights": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..20b26516d67 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:52067;http://localhost:47701", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62977", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34208" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.PostgreSQL": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..2f25f8f4007 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json @@ -0,0 +1,19 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.Redis": "", + "Aspire.Hosting.Azure.KeyVault": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..5e2741ff33a --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.Search": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..90a06a55176 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:24190;http://localhost:42530", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:60807", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:16724" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.ServiceBus": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..9a3103790a9 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.SignalR": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..ce2c8af01da --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json @@ -0,0 +1,19 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:58695;http://localhost:30637", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:44501", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:55515" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.Sql": "", + "Aspire.Hosting.Azure.Storage": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..ceee2f18d08 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:52066;http://localhost:47700", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62976", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34207" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.Storage": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..eead8e72b01 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure.WebPubSub": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..711232c0e1a --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..7533e4034df --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.DevTunnels": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..a38b51803e0 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29650;http://localhost:28831", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10875", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13219" + } + } + }, + "packages": { + "Aspire.Hosting.Docker": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..c072bdb4e2b --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Foundry": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..25ad85a7f62 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Garnet": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..4ffbf86d15a --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.GitHub.Models": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..dc13f6ddea4 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29670;http://localhost:28851", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10895", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13239" + } + } + }, + "packages": { + "Aspire.Hosting.JavaScript": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..848ee3d0fce --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:16114;http://localhost:53304", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:18137", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:39824" + } + } + }, + "packages": { + "Aspire.Hosting.Kafka": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..47a723d877d --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:44486;http://localhost:17648", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:12771", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:44457" + } + } + }, + "packages": { + "Aspire.Hosting.Keycloak": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..de646c6a39b --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29650;http://localhost:28831", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10875", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13219" + } + } + }, + "packages": { + "Aspire.Hosting.Kubernetes": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..bdab4f58165 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:17001;http://localhost:17000", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:17003", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17004" + } + } + }, + "packages": { + "Aspire.Hosting.Maui": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..1cb1e8bca7a --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Milvus": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..7d07f8c3f87 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.MongoDB": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..4bcc40ab752 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.MySql": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..d8640d44a58 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Nats": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..1e855592fc3 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.OpenAI": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..7589b8e04ad --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Oracle": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..46bb4da9991 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Orleans": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..7e80ed7454a --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:33490;http://localhost:28305", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21575", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17364" + } + } + }, + "packages": { + "Aspire.Hosting.PostgreSQL": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..accb86a6fa4 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Python": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..bd9623a4f7d --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Qdrant": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..1fa13dd959e --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:18076;http://localhost:48822", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:56384", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:64883" + } + } + }, + "packages": { + "Aspire.Hosting.RabbitMQ": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..ced7648752f --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29650;http://localhost:28831", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10875", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13219" + } + } + }, + "packages": { + "Aspire.Hosting.Redis": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..609d38e1e0a --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Seq": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash new file mode 100644 index 00000000000..3f17e86e478 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash @@ -0,0 +1 @@ +154718CD9A4E1EEC05481800BD54DCC8B0899333A6698A5BE99F75680DCE5C8F \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts new file mode 100644 index 00000000000..82809546dcb --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts @@ -0,0 +1,21672 @@ +// aspire.ts - Capability-based Aspire SDK +// This SDK uses the ATS (Aspire Type System) capability API. +// Capabilities are endpoints like 'Aspire.Hosting/createBuilder'. +// +// GENERATED CODE - DO NOT EDIT + +import { + AspireClient as AspireClientRpc, + Handle, + MarshalledHandle, + AppHostUsageError, + CancellationToken, + CapabilityError, + registerCallback, + wrapIfHandle, + registerHandleWrapper +} from './transport.js'; + +import type { + ICancellationToken, + IReferenceExpression +} from './base.js'; + +import { + ResourceBuilderBase, + ReferenceExpression, + refExpr, + AspireDict, + AspireList +} from './base.js'; + +// ============================================================================ +// Handle Type Aliases (Internal - not exported to users) +// ============================================================================ + +/** Handle to SqlServerDatabaseResource */ +type SqlServerDatabaseResourceHandle = Handle<'Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerDatabaseResource'>; + +/** Handle to SqlServerServerResource */ +type SqlServerServerResourceHandle = Handle<'Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerServerResource'>; + +/** 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'>; + +/** Handle to ContainerResource */ +type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource'>; + +/** Handle to CSharpAppResource */ +type CSharpAppResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource'>; + +/** Handle to DistributedApplicationModel */ +type DistributedApplicationModelHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel'>; + +/** Handle to DotnetToolResource */ +type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; + +/** Handle to EndpointReference */ +type EndpointReferenceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference'>; + +/** Handle to EndpointReferenceExpression */ +type EndpointReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression'>; + +/** Handle to EnvironmentCallbackContext */ +type EnvironmentCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext'>; + +/** Handle to ExecutableResource */ +type ExecutableResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource'>; + +/** Handle to ExecuteCommandContext */ +type ExecuteCommandContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext'>; + +/** Handle to IComputeResource */ +type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource'>; + +/** Handle to IContainerFilesDestinationResource */ +type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; + +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + +/** Handle to IResource */ +type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; + +/** Handle to IResourceWithArgs */ +type IResourceWithArgsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs'>; + +/** Handle to IResourceWithConnectionString */ +type IResourceWithConnectionStringHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString'>; + +/** Handle to IResourceWithEndpoints */ +type IResourceWithEndpointsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints'>; + +/** Handle to IResourceWithEnvironment */ +type IResourceWithEnvironmentHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment'>; + +/** Handle to IResourceWithWaitSupport */ +type IResourceWithWaitSupportHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport'>; + +/** Handle to ParameterResource */ +type ParameterResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource'>; + +/** Handle to ProjectResource */ +type ProjectResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource'>; + +/** Handle to ReferenceExpression */ +type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression'>; + +/** Handle to ReferenceExpressionBuilder */ +type ReferenceExpressionBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder'>; + +/** Handle to 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'>; + +/** Handle to DistributedApplication */ +type DistributedApplicationHandle = Handle<'Aspire.Hosting/Aspire.Hosting.DistributedApplication'>; + +/** Handle to DistributedApplicationExecutionContext */ +type DistributedApplicationExecutionContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext'>; + +/** Handle to DistributedApplicationEventSubscription */ +type DistributedApplicationEventSubscriptionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Eventing.DistributedApplicationEventSubscription'>; + +/** Handle to IDistributedApplicationEventing */ +type IDistributedApplicationEventingHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing'>; + +/** Handle to ExternalServiceResource */ +type ExternalServiceResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ExternalServiceResource'>; + +/** Handle to IDistributedApplicationBuilder */ +type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder'>; + +/** Handle to IResourceWithContainerFiles */ +type IResourceWithContainerFilesHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles'>; + +/** Handle to 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'>; + +/** Handle to Dict */ +type DictstringanyHandle = Handle<'Aspire.Hosting/Dict'>; + +/** Handle to List */ +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[]'>; + +/** Handle to IServiceProvider */ +type IServiceProviderHandle = Handle<'System.ComponentModel/System.IServiceProvider'>; + +// ============================================================================ +// Enum Types +// ============================================================================ + +/** Enum type for CertificateTrustScope */ +export enum CertificateTrustScope { + None = "None", + Append = "Append", + Override = "Override", + System = "System", +} + +/** Enum type for ContainerLifetime */ +export enum ContainerLifetime { + Session = "Session", + Persistent = "Persistent", +} + +/** Enum type for DistributedApplicationOperation */ +export enum DistributedApplicationOperation { + Run = "Run", + Publish = "Publish", +} + +/** Enum type for EndpointProperty */ +export enum EndpointProperty { + Url = "Url", + Host = "Host", + IPV4Host = "IPV4Host", + Port = "Port", + Scheme = "Scheme", + TargetPort = "TargetPort", + HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", +} + +/** Enum type for IconVariant */ +export enum IconVariant { + Regular = "Regular", + Filled = "Filled", +} + +/** Enum type for ImagePullPolicy */ +export enum ImagePullPolicy { + Default = "Default", + Always = "Always", + Missing = "Missing", + Never = "Never", +} + +/** Enum type for OtlpProtocol */ +export enum OtlpProtocol { + Grpc = "Grpc", + HttpProtobuf = "HttpProtobuf", + HttpJson = "HttpJson", +} + +/** Enum type for ProbeType */ +export enum ProbeType { + Startup = "Startup", + Readiness = "Readiness", + Liveness = "Liveness", +} + +/** Enum type for ProtocolType */ +export enum ProtocolType { + IP = "IP", + IPv6HopByHopOptions = "IPv6HopByHopOptions", + Unspecified = "Unspecified", + Icmp = "Icmp", + Igmp = "Igmp", + Ggp = "Ggp", + IPv4 = "IPv4", + Tcp = "Tcp", + Pup = "Pup", + Udp = "Udp", + Idp = "Idp", + IPv6 = "IPv6", + IPv6RoutingHeader = "IPv6RoutingHeader", + IPv6FragmentHeader = "IPv6FragmentHeader", + IPSecEncapsulatingSecurityPayload = "IPSecEncapsulatingSecurityPayload", + IPSecAuthenticationHeader = "IPSecAuthenticationHeader", + IcmpV6 = "IcmpV6", + IPv6NoNextHeader = "IPv6NoNextHeader", + IPv6DestinationOptions = "IPv6DestinationOptions", + ND = "ND", + Raw = "Raw", + Ipx = "Ipx", + Spx = "Spx", + SpxII = "SpxII", + Unknown = "Unknown", +} + +/** Enum type for UrlDisplayLocation */ +export enum UrlDisplayLocation { + SummaryAndDetails = "SummaryAndDetails", + DetailsOnly = "DetailsOnly", +} + +/** Enum type for WaitBehavior */ +export enum WaitBehavior { + WaitOnResourceUnavailable = "WaitOnResourceUnavailable", + StopOnResourceUnavailable = "StopOnResourceUnavailable", +} + +// ============================================================================ +// DTO Interfaces +// ============================================================================ + +/** DTO interface for CommandOptions */ +export interface CommandOptions { + description?: string; + parameter?: any; + confirmationMessage?: string; + iconName?: string; + iconVariant?: IconVariant; + isHighlighted?: boolean; + updateState?: any; +} + +/** DTO interface for CreateBuilderOptions */ +export interface CreateBuilderOptions { + args?: string[]; + projectDirectory?: string; + appHostFilePath?: string; + containerRegistryOverride?: string; + disableDashboard?: boolean; + dashboardApplicationName?: string; + allowUnsecuredTransport?: boolean; + enableResourceLogging?: boolean; +} + +/** DTO interface for ExecuteCommandResult */ +export interface ExecuteCommandResult { + success?: boolean; + canceled?: boolean; + errorMessage?: string; +} + +/** DTO interface for ResourceEventDto */ +export interface ResourceEventDto { + resourceName?: string; + resourceId?: string; + state?: string; + stateStyle?: string; + healthStatus?: string; + exitCode?: number; +} + +/** DTO interface for ResourceUrlAnnotation */ +export interface ResourceUrlAnnotation { + url?: string; + displayText?: string; + endpoint?: EndpointReferenceHandle; + displayLocation?: UrlDisplayLocation; +} + +// ============================================================================ +// Options Interfaces +// ============================================================================ + +export interface AddConnectionStringOptions { + environmentVariableName?: string; +} + +export interface AddContainerRegistryFromStringOptions { + repository?: string; +} + +export interface AddContainerRegistryOptions { + repository?: IParameterResource; +} + +export interface AddDatabaseOptions { + databaseName?: string; +} + +export interface AddDockerfileOptions { + dockerfilePath?: string; + stage?: string; +} + +export interface AddParameterFromConfigurationOptions { + secret?: boolean; +} + +export interface AddParameterOptions { + secret?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; + secret?: boolean; +} + +export interface AddSqlServerOptions { + password?: IParameterResource; + port?: number; +} + +export interface AppendFormattedOptions { + format?: string; +} + +export interface AppendValueProviderOptions { + format?: string; +} + +export interface CompleteStepMarkdownOptions { + completionState?: string; + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface CompleteStepOptions { + completionState?: string; + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface CompleteTaskMarkdownOptions { + completionState?: string; + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface CompleteTaskOptions { + completionMessage?: string; + completionState?: string; + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface GetValueAsyncOptions { + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: IContainerResource) => Promise; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; +} + +export interface RunOptions { + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface SaveStateJsonOptions { + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface UpdateTaskMarkdownOptions { + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface UpdateTaskOptions { + cancellationToken?: AbortSignal | ICancellationToken; +} + +export interface WaitForCompletionOptions { + exitCode?: number; +} + +export interface WaitForResourceStateOptions { + targetState?: string; +} + +export interface WithBindMountOptions { + isReadOnly?: boolean; +} + +export interface WithCommandOptions { + commandOptions?: CommandOptions; +} + +export interface WithDataBindMountOptions { + isReadOnly?: boolean; +} + +export interface WithDataVolumeOptions { + name?: string; + isReadOnly?: boolean; +} + +export interface WithDescriptionOptions { + enableMarkdown?: boolean; +} + +export interface WithDockerfileBaseImageOptions { + buildImage?: string; + runtimeImage?: string; +} + +export interface WithDockerfileOptions { + dockerfilePath?: string; + stage?: string; +} + +export interface WithEndpointOptions { + port?: number; + targetPort?: number; + scheme?: string; + name?: string; + env?: string; + isProxied?: boolean; + isExternal?: boolean; + protocol?: ProtocolType; +} + +export interface WithExternalServiceHttpHealthCheckOptions { + path?: string; + statusCode?: number; +} + +export interface WithHostPortOptions { + port?: number; +} + +export interface WithHttpEndpointOptions { + port?: number; + targetPort?: number; + name?: string; + env?: string; + isProxied?: boolean; +} + +export interface WithHttpHealthCheckOptions { + path?: string; + statusCode?: number; + endpointName?: string; +} + +export interface WithHttpProbeOptions { + path?: string; + initialDelaySeconds?: number; + periodSeconds?: number; + timeoutSeconds?: number; + failureThreshold?: number; + successThreshold?: number; + endpointName?: string; +} + +export interface WithHttpsDeveloperCertificateOptions { + password?: IParameterResource; +} + +export interface WithHttpsEndpointOptions { + port?: number; + targetPort?: number; + name?: string; + env?: string; + isProxied?: boolean; +} + +export interface WithIconNameOptions { + iconVariant?: IconVariant; +} + +export interface WithImageOptions { + tag?: string; +} + +export interface WithMcpServerOptions { + path?: string; + endpointName?: string; +} + +export interface WithPipelineStepFactoryOptions { + dependsOn?: string[]; + requiredBy?: string[]; + tags?: string[]; + description?: string; +} + +export interface WithReferenceOptions { + connectionName?: string; + optional?: boolean; + name?: string; +} + +export interface WithRequiredCommandOptions { + helpLink?: string; +} + +export interface WithUrlExpressionOptions { + displayText?: string; +} + +export interface WithUrlOptions { + displayText?: string; +} + +export interface WithVolumeOptions { + name?: string; + isReadOnly?: boolean; +} + +// ============================================================================ +// IAfterResourcesCreatedEvent +// ============================================================================ + +export interface IAfterResourcesCreatedEvent { + toJSON(): MarshalledHandle; + services: { + get: () => Promise; + }; + model: { + get: () => Promise; + }; +} + +// ============================================================================ +// 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); + }, + }; + +} + +// ============================================================================ +// IBeforeResourceStartedEvent +// ============================================================================ + +export interface IBeforeResourceStartedEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + +// ============================================================================ +// 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); + }, + }; + +} + +// ============================================================================ +// IBeforeStartEvent +// ============================================================================ + +export interface IBeforeStartEvent { + toJSON(): MarshalledHandle; + services: { + get: () => Promise; + }; + model: { + get: () => Promise; + }; +} + +// ============================================================================ +// 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); + }, + }; + +} + +// ============================================================================ +// ICommandLineArgsCallbackContext +// ============================================================================ + +export interface ICommandLineArgsCallbackContext { + toJSON(): MarshalledHandle; + readonly args: AspireList; + cancellationToken: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + set: (value: IDistributedApplicationExecutionContext) => Promise; + }; + logger: { + get: () => Promise; + set: (value: ILogger) => Promise; + }; + resource: { + get: () => Promise; + }; +} + +// ============================================================================ +// CommandLineArgsCallbackContext +// ============================================================================ + +/** + * Type class for CommandLineArgsCallbackContext. + */ +export class CommandLineArgsCallbackContext { + constructor(private _handle: CommandLineArgsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Args property */ + private _args?: AspireList; + get args(): AspireList { + if (!this._args) { + this._args = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.args', + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.args' + ); + } + return this._args; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + set: async (value: IDistributedApplicationExecutionContext): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setExecutionContext', + { context: this._handle, value } + ); + } + }; + + /** 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); + }, + set: async (value: ILogger): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setLogger', + { context: this._handle, value } + ); + } + }; + + /** 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); + }, + }; + +} + +// ============================================================================ +// IConnectionStringAvailableEvent +// ============================================================================ + +export interface IConnectionStringAvailableEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + +// ============================================================================ +// 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); + }, + }; + +} + +// ============================================================================ +// IDistributedApplication +// ============================================================================ + +export interface IDistributedApplication { + toJSON(): MarshalledHandle; + run(options?: RunOptions): IDistributedApplicationPromise; +} + +export interface IDistributedApplicationPromise extends PromiseLike { + run(options?: RunOptions): IDistributedApplicationPromise; +} + +// ============================================================================ +// DistributedApplication +// ============================================================================ + +/** + * Type class for DistributedApplication. + */ +export class DistributedApplication { + constructor(private _handle: DistributedApplicationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Runs the distributed application */ + /** @internal */ + async _runInternal(cancellationToken?: AbortSignal | ICancellationToken): Promise { + const rpcArgs: Record = { context: this._handle }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + await this._client.invokeCapability( + 'Aspire.Hosting/run', + rpcArgs + ); + return this; + } + + run(options?: RunOptions): DistributedApplicationPromise { + const cancellationToken = options?.cancellationToken; + return new DistributedApplicationPromise(this._runInternal(cancellationToken)); + } + +} + +/** + * Thenable wrapper for DistributedApplication that enables fluent chaining. + */ +export class DistributedApplicationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplication) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Runs the distributed application */ + run(options?: RunOptions): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.run(options))); + } + +} + +// ============================================================================ +// IDistributedApplicationExecutionContext +// ============================================================================ + +export interface IDistributedApplicationExecutionContext { + toJSON(): MarshalledHandle; + publisherName: { + get: () => Promise; + set: (value: string) => Promise; + }; + operation: { + get: () => Promise; + }; + serviceProvider: { + get: () => Promise; + }; + isPublishMode: { + get: () => Promise; + }; + isRunMode: { + get: () => Promise; + }; +} + +// ============================================================================ +// DistributedApplicationExecutionContext +// ============================================================================ + +/** + * Type class for DistributedApplicationExecutionContext. + */ +export class DistributedApplicationExecutionContext { + constructor(private _handle: DistributedApplicationExecutionContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PublisherName property */ + publisherName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.publisherName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.setPublisherName', + { context: this._handle, value } + ); + } + }; + + /** Gets the Operation property */ + operation = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.operation', + { context: this._handle } + ); + }, + }; + + /** 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 => { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.isPublishMode', + { context: this._handle } + ); + }, + }; + + /** Gets the IsRunMode property */ + isRunMode = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.isRunMode', + { context: this._handle } + ); + }, + }; + +} + +// ============================================================================ +// IDistributedApplicationModel +// ============================================================================ + +export interface IDistributedApplicationModel { + toJSON(): MarshalledHandle; + getResources(): Promise; + findResourceByName(name: string): IResourcePromise; +} + +export interface IDistributedApplicationModelPromise extends PromiseLike { + getResources(): Promise; + findResourceByName(name: string): IResourcePromise; +} + +// ============================================================================ +// 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))); + } + +} + +// ============================================================================ +// IEndpointReference +// ============================================================================ + +export interface IEndpointReference { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + endpointName: { + get: () => Promise; + }; + errorMessage: { + get: () => Promise; + set: (value: string) => Promise; + }; + isAllocated: { + get: () => Promise; + }; + exists: { + get: () => Promise; + }; + isHttp: { + get: () => Promise; + }; + isHttps: { + get: () => Promise; + }; + tlsEnabled: { + get: () => Promise; + }; + port: { + get: () => Promise; + }; + targetPort: { + get: () => Promise; + }; + host: { + get: () => Promise; + }; + scheme: { + get: () => Promise; + }; + url: { + get: () => Promise; + }; + getValueAsync(options?: GetValueAsyncOptions): Promise; + getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; +} + +export interface IEndpointReferencePromise extends PromiseLike { + getValueAsync(options?: GetValueAsyncOptions): Promise; + getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; +} + +// ============================================================================ +// EndpointReference +// ============================================================================ + +/** + * Type class for EndpointReference. + */ +export class EndpointReference { + constructor(private _handle: EndpointReferenceHandle, 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/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + + /** Gets the EndpointName property */ + endpointName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.endpointName', + { context: this._handle } + ); + }, + }; + + /** Gets the ErrorMessage property */ + errorMessage = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.errorMessage', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.setErrorMessage', + { context: this._handle, value } + ); + } + }; + + /** Gets the IsAllocated property */ + isAllocated = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.isAllocated', + { context: this._handle } + ); + }, + }; + + /** Gets the Exists property */ + exists = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.exists', + { context: this._handle } + ); + }, + }; + + /** Gets the IsHttp property */ + isHttp = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.isHttp', + { context: this._handle } + ); + }, + }; + + /** Gets the IsHttps property */ + isHttps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.isHttps', + { context: this._handle } + ); + }, + }; + + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + }, + }; + + /** Gets the Port property */ + port = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.port', + { context: this._handle } + ); + }, + }; + + /** Gets the TargetPort property */ + targetPort = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.targetPort', + { context: this._handle } + ); + }, + }; + + /** Gets the Host property */ + host = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.host', + { context: this._handle } + ); + }, + }; + + /** Gets the Scheme property */ + scheme = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.scheme', + { context: this._handle } + ); + }, + }; + + /** Gets the Url property */ + url = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.url', + { context: this._handle } + ); + }, + }; + + /** Gets the URL of the endpoint asynchronously */ + async getValueAsync(options?: GetValueAsyncOptions): Promise { + const cancellationToken = options?.cancellationToken; + const rpcArgs: Record = { context: this._handle }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValueAsync', + rpcArgs + ); + } + + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + async getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { + const rpcArgs: Record = { context: this._handle, enabledValue, disabledValue }; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.getTlsValue', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for EndpointReference that enables fluent chaining. + */ +export class EndpointReferencePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: EndpointReference) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets the URL of the endpoint asynchronously */ + getValueAsync(options?: GetValueAsyncOptions): Promise { + return this._promise.then(obj => obj.getValueAsync(options)); + } + + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + +} + +// ============================================================================ +// IEndpointReferenceExpression +// ============================================================================ + +export interface IEndpointReferenceExpression { + toJSON(): MarshalledHandle; + endpoint: { + get: () => Promise; + }; + property: { + get: () => Promise; + }; + valueExpression: { + get: () => Promise; + }; +} + +// ============================================================================ +// EndpointReferenceExpression +// ============================================================================ + +/** + * Type class for EndpointReferenceExpression. + */ +export class EndpointReferenceExpression { + constructor(private _handle: EndpointReferenceExpressionHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Endpoint property */ + endpoint = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.endpoint', + { context: this._handle } + ); + return new EndpointReference(handle, this._client); + }, + }; + + /** Gets the Property property */ + property = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.property', + { context: this._handle } + ); + }, + }; + + /** Gets the ValueExpression property */ + valueExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.valueExpression', + { context: this._handle } + ); + }, + }; + +} + +// ============================================================================ +// IEnvironmentCallbackContext +// ============================================================================ + +export interface IEnvironmentCallbackContext { + toJSON(): MarshalledHandle; + readonly environmentVariables: AspireDict; + cancellationToken: { + get: () => Promise; + }; + logger: { + get: () => Promise; + set: (value: ILogger) => Promise; + }; + resource: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; +} + +// ============================================================================ +// EnvironmentCallbackContext +// ============================================================================ + +/** + * Type class for EnvironmentCallbackContext. + */ +export class EnvironmentCallbackContext { + constructor(private _handle: EnvironmentCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the EnvironmentVariables property */ + private _environmentVariables?: AspireDict; + get environmentVariables(): AspireDict { + if (!this._environmentVariables) { + this._environmentVariables = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.environmentVariables', + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.environmentVariables' + ); + } + return this._environmentVariables; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + 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); + }, + set: async (value: ILogger): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.setLogger', + { context: this._handle, value } + ); + } + }; + + /** 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); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + +} + +// ============================================================================ +// IExecuteCommandContext +// ============================================================================ + +export interface IExecuteCommandContext { + toJSON(): MarshalledHandle; + serviceProvider: { + get: () => Promise; + set: (value: IServiceProvider) => Promise; + }; + resourceName: { + get: () => Promise; + set: (value: string) => Promise; + }; + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | ICancellationToken) => Promise; + }; +} + +// ============================================================================ +// ExecuteCommandContext +// ============================================================================ + +/** + * Type class for ExecuteCommandContext. + */ +export class ExecuteCommandContext { + constructor(private _handle: ExecuteCommandContextHandle, 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/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + set: async (value: IServiceProvider): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setServiceProvider', + { context: this._handle, value } + ); + } + }; + + /** Gets the ResourceName property */ + resourceName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.resourceName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setResourceName', + { context: this._handle, value } + ); + } + }; + + /** Gets the CancellationToken property */ + cancellationToken = { + 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 | ICancellationToken): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', + { context: this._handle, value: CancellationToken.fromValue(value) } + ); + } + }; + +} + +// ============================================================================ +// IInitializeResourceEvent +// ============================================================================ + +export interface IInitializeResourceEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + eventing: { + get: () => Promise; + }; + logger: { + get: () => Promise; + }; + notifications: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + +// ============================================================================ +// 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); + }, + }; + +} + +// ============================================================================ +// IPipelineConfigurationContext +// ============================================================================ + +export interface IPipelineConfigurationContext { + toJSON(): MarshalledHandle; + services: { + get: () => Promise; + set: (value: IServiceProvider) => Promise; + }; + steps: { + get: () => Promise; + set: (value: IPipelineStep[]) => Promise; + }; + model: { + get: () => Promise; + set: (value: IDistributedApplicationModel) => Promise; + }; + getStepsByTag(tag: string): Promise; +} + +export interface IPipelineConfigurationContextPromise extends PromiseLike { + getStepsByTag(tag: string): Promise; +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, 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.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + set: async (value: IServiceProvider): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setServices', + { context: this._handle, value } + ); + } + }; + + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + { context: this._handle } + ); + }, + set: async (value: IPipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } + ); + } + }; + + /** 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); + }, + set: async (value: IDistributedApplicationModel): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setModel', + { context: this._handle, value } + ); + } + }; + + /** Gets pipeline steps with the specified tag */ + async getStepsByTag(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/getStepsByTag', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for PipelineConfigurationContext that enables fluent chaining. + */ +export class PipelineConfigurationContextPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineConfigurationContext) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets pipeline steps with the specified tag */ + getStepsByTag(tag: string): Promise { + return this._promise.then(obj => obj.getStepsByTag(tag)); + } + +} + +// ============================================================================ +// IPipelineContext +// ============================================================================ + +export interface IPipelineContext { + toJSON(): MarshalledHandle; + model: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; + logger: { + get: () => Promise; + }; + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | ICancellationToken) => Promise; + }; + summary: { + get: () => Promise; + }; +} + +// ============================================================================ +// PipelineContext +// ============================================================================ + +/** + * Type class for PipelineContext. + */ +export class PipelineContext { + constructor(private _handle: PipelineContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Model property */ + model = { + get: async (): Promise => { + 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 | ICancellationToken): 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); + }, + }; + +} + +// ============================================================================ +// IPipelineStep +// ============================================================================ + +export interface IPipelineStep { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + description: { + get: () => Promise; + set: (value: string) => Promise; + }; + readonly dependsOnSteps: AspireList; + readonly requiredBySteps: AspireList; + readonly tags: AspireList; + resource: { + get: () => Promise; + set: (value: IResource) => Promise; + }; + dependsOn(stepName: string): IPipelineStepPromise; + requiredBy(stepName: string): IPipelineStepPromise; +} + +export interface IPipelineStepPromise extends PromiseLike { + dependsOn(stepName: string): IPipelineStepPromise; + requiredBy(stepName: string): IPipelineStepPromise; +} + +// ============================================================================ +// PipelineStep +// ============================================================================ + +/** + * Type class for PipelineStep. + */ +export class PipelineStep { + constructor(private _handle: PipelineStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.name', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.setName', + { context: this._handle, value } + ); + } + }; + + /** Gets the Description property */ + description = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.description', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.setDescription', + { context: this._handle, value } + ); + } + }; + + /** Gets the DependsOnSteps property */ + private _dependsOnSteps?: AspireList; + get dependsOnSteps(): AspireList { + if (!this._dependsOnSteps) { + this._dependsOnSteps = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Pipelines/PipelineStep.dependsOnSteps', + 'Aspire.Hosting.Pipelines/PipelineStep.dependsOnSteps' + ); + } + return this._dependsOnSteps; + } + + /** Gets the RequiredBySteps property */ + private _requiredBySteps?: AspireList; + get requiredBySteps(): AspireList { + if (!this._requiredBySteps) { + this._requiredBySteps = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Pipelines/PipelineStep.requiredBySteps', + 'Aspire.Hosting.Pipelines/PipelineStep.requiredBySteps' + ); + } + return this._requiredBySteps; + } + + /** Gets the Tags property */ + private _tags?: AspireList; + get tags(): AspireList { + if (!this._tags) { + this._tags = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.Pipelines/PipelineStep.tags', + 'Aspire.Hosting.Pipelines/PipelineStep.tags' + ); + } + return this._tags; + } + + /** 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); + }, + set: async (value: IResource): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.setResource', + { context: this._handle, value } + ); + } + }; + + /** Adds a dependency on another step by name */ + /** @internal */ + async _dependsOnInternal(stepName: string): Promise { + const rpcArgs: Record = { context: this._handle, stepName }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/dependsOn', + rpcArgs + ); + return this; + } + + dependsOn(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._dependsOnInternal(stepName)); + } + + /** Specifies that another step requires this step by name */ + /** @internal */ + async _requiredByInternal(stepName: string): Promise { + const rpcArgs: Record = { context: this._handle, stepName }; + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/requiredBy', + rpcArgs + ); + return this; + } + + requiredBy(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._requiredByInternal(stepName)); + } + +} + +/** + * Thenable wrapper for PipelineStep that enables fluent chaining. + */ +export class PipelineStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Adds a dependency on another step by name */ + dependsOn(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._promise.then(obj => obj.dependsOn(stepName))); + } + + /** Specifies that another step requires this step by name */ + requiredBy(stepName: string): PipelineStepPromise { + return new PipelineStepPromise(this._promise.then(obj => obj.requiredBy(stepName))); + } + +} + +// ============================================================================ +// IPipelineStepContext +// ============================================================================ + +export interface IPipelineStepContext { + toJSON(): MarshalledHandle; + pipelineContext: { + get: () => Promise; + set: (value: IPipelineContext) => Promise; + }; + reportingStep: { + get: () => Promise; + set: (value: IReportingStep) => Promise; + }; + model: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; + logger: { + get: () => Promise; + }; + cancellationToken: { + get: () => Promise; + }; + summary: { + get: () => Promise; + }; +} + +// ============================================================================ +// PipelineStepContext +// ============================================================================ + +/** + * Type class for PipelineStepContext. + */ +export class PipelineStepContext { + constructor(private _handle: PipelineStepContextHandle, 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/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + set: async (value: IPipelineContext): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.setPipelineContext', + { context: this._handle, value } + ); + } + }; + + /** 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); + }, + set: async (value: IReportingStep): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.setReportingStep', + { context: this._handle, value } + ); + } + }; + + /** 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 => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.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/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 => { + 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); + }, + }; + +} + +// ============================================================================ +// IPipelineStepFactoryContext +// ============================================================================ + +export interface IPipelineStepFactoryContext { + toJSON(): MarshalledHandle; + pipelineContext: { + get: () => Promise; + set: (value: IPipelineContext) => Promise; + }; + resource: { + get: () => Promise; + set: (value: IResource) => Promise; + }; +} + +// ============================================================================ +// 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); + }, + set: async (value: IPipelineContext): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setPipelineContext', + { context: this._handle, value } + ); + } + }; + + /** 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); + }, + set: async (value: IResource): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setResource', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// IPipelineSummary +// ============================================================================ + +export interface IPipelineSummary { + toJSON(): MarshalledHandle; + add(key: string, value: string): IPipelineSummaryPromise; + addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; +} + +export interface IPipelineSummaryPromise extends PromiseLike { + add(key: string, value: string): IPipelineSummaryPromise; + addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; +} + +// ============================================================================ +// 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))); + } + +} + +// ============================================================================ +// IProjectResourceOptions +// ============================================================================ + +export interface IProjectResourceOptions { + toJSON(): MarshalledHandle; + launchProfileName: { + get: () => Promise; + set: (value: string) => Promise; + }; + excludeLaunchProfile: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + excludeKestrelEndpoints: { + get: () => Promise; + set: (value: boolean) => Promise; + }; +} + +// ============================================================================ +// ProjectResourceOptions +// ============================================================================ + +/** + * Type class for ProjectResourceOptions. + */ +export class ProjectResourceOptions { + constructor(private _handle: ProjectResourceOptionsHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the LaunchProfileName property */ + launchProfileName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.launchProfileName', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setLaunchProfileName', + { context: this._handle, value } + ); + } + }; + + /** Gets the ExcludeLaunchProfile property */ + excludeLaunchProfile = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeLaunchProfile', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setExcludeLaunchProfile', + { context: this._handle, value } + ); + } + }; + + /** Gets the ExcludeKestrelEndpoints property */ + excludeKestrelEndpoints = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeKestrelEndpoints', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.setExcludeKestrelEndpoints', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// IReferenceExpressionBuilder +// ============================================================================ + +export interface IReferenceExpressionBuilder { + toJSON(): MarshalledHandle; + isEmpty: { + get: () => Promise; + }; + appendLiteral(value: string): IReferenceExpressionBuilderPromise; + appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; + build(): Promise; +} + +export interface IReferenceExpressionBuilderPromise extends PromiseLike { + appendLiteral(value: string): IReferenceExpressionBuilderPromise; + appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; + build(): Promise; +} + +// ============================================================================ +// ReferenceExpressionBuilder +// ============================================================================ + +/** + * Type class for ReferenceExpressionBuilder. + */ +export class ReferenceExpressionBuilder { + constructor(private _handle: ReferenceExpressionBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the IsEmpty property */ + isEmpty = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ReferenceExpressionBuilder.isEmpty', + { context: this._handle } + ); + }, + }; + + /** Appends a literal string to the reference expression */ + /** @internal */ + async _appendLiteralInternal(value: string): Promise { + const rpcArgs: Record = { context: this._handle, value }; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendLiteral', + rpcArgs + ); + return this; + } + + appendLiteral(value: string): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._appendLiteralInternal(value)); + } + + /** Appends a formatted string value to the reference expression */ + /** @internal */ + async _appendFormattedInternal(value: string, format?: string): Promise { + const rpcArgs: Record = { context: this._handle, value }; + if (format !== undefined) rpcArgs.format = format; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendFormatted', + rpcArgs + ); + return this; + } + + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { + const format = options?.format; + return new ReferenceExpressionBuilderPromise(this._appendFormattedInternal(value, format)); + } + + /** Appends a value provider to the reference expression */ + /** @internal */ + async _appendValueProviderInternal(valueProvider: any, format?: string): Promise { + const rpcArgs: Record = { context: this._handle, valueProvider }; + if (format !== undefined) rpcArgs.format = format; + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/appendValueProvider', + rpcArgs + ); + return this; + } + + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { + const format = options?.format; + return new ReferenceExpressionBuilderPromise(this._appendValueProviderInternal(valueProvider, format)); + } + + /** Builds the reference expression */ + async build(): Promise { + const rpcArgs: Record = { context: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/build', + rpcArgs + ); + } + +} + +/** + * Thenable wrapper for ReferenceExpressionBuilder that enables fluent chaining. + */ +export class ReferenceExpressionBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReferenceExpressionBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Appends a literal string to the reference expression */ + appendLiteral(value: string): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendLiteral(value))); + } + + /** Appends a formatted string value to the reference expression */ + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendFormatted(value, options))); + } + + /** Appends a value provider to the reference expression */ + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { + return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendValueProvider(valueProvider, options))); + } + + /** Builds the reference expression */ + build(): Promise { + return this._promise.then(obj => obj.build()); + } + +} + +// ============================================================================ +// IResourceEndpointsAllocatedEvent +// ============================================================================ + +export interface IResourceEndpointsAllocatedEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + +// ============================================================================ +// ResourceEndpointsAllocatedEvent +// ============================================================================ + +/** + * Type class for ResourceEndpointsAllocatedEvent. + */ +export class ResourceEndpointsAllocatedEvent { + constructor(private _handle: ResourceEndpointsAllocatedEventHandle, 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/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); + }, + }; + +} + +// ============================================================================ +// IResourceLoggerService +// ============================================================================ + +export interface IResourceLoggerService { + toJSON(): MarshalledHandle; + completeLog(resource: IResource): IResourceLoggerServicePromise; + completeLogByName(resourceName: string): IResourceLoggerServicePromise; +} + +export interface IResourceLoggerServicePromise extends PromiseLike { + completeLog(resource: IResource): IResourceLoggerServicePromise; + completeLogByName(resourceName: string): IResourceLoggerServicePromise; +} + +// ============================================================================ +// 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: IResource): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: IResource): 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: IResource): 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))); + } + +} + +// ============================================================================ +// IResourceNotificationService +// ============================================================================ + +export interface IResourceNotificationService { + toJSON(): MarshalledHandle; + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): IResourceNotificationServicePromise; + waitForResourceStates(resourceName: string, targetStates: string[]): Promise; + waitForResourceHealthy(resourceName: string): Promise; + waitForDependencies(resource: IResource): IResourceNotificationServicePromise; + tryGetResourceState(resourceName: string): Promise; + publishResourceUpdate(resource: IResource, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; +} + +export interface IResourceNotificationServicePromise extends PromiseLike { + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): IResourceNotificationServicePromise; + waitForResourceStates(resourceName: string, targetStates: string[]): Promise; + waitForResourceHealthy(resourceName: string): Promise; + waitForDependencies(resource: IResource): IResourceNotificationServicePromise; + tryGetResourceState(resourceName: string): Promise; + publishResourceUpdate(resource: IResource, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; +} + +// ============================================================================ +// 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: IResource): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: IResource): 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: IResource, 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: IResource, 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: IResource): 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: IResource, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// IResourceReadyEvent +// ============================================================================ + +export interface IResourceReadyEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + +// ============================================================================ +// 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); + }, + }; + +} + +// ============================================================================ +// IResourceStoppedEvent +// ============================================================================ + +export interface IResourceStoppedEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + +// ============================================================================ +// 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); + }, + }; + +} + +// ============================================================================ +// IResourceUrlsCallbackContext +// ============================================================================ + +export interface IResourceUrlsCallbackContext { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + readonly urls: AspireList; + cancellationToken: { + get: () => Promise; + }; + logger: { + get: () => Promise; + set: (value: ILogger) => Promise; + }; + executionContext: { + get: () => Promise; + }; +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, 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/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + 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); + }, + set: async (value: ILogger): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.setLogger', + { context: this._handle, value } + ); + } + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + +} + +// ============================================================================ +// IUpdateCommandStateContext +// ============================================================================ + +export interface IUpdateCommandStateContext { + toJSON(): MarshalledHandle; + serviceProvider: { + get: () => Promise; + set: (value: IServiceProvider) => Promise; + }; +} + +// ============================================================================ +// 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); + }, + set: async (value: IServiceProvider): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.setServiceProvider', + { context: this._handle, value } + ); + } + }; + +} + +// ============================================================================ +// IConfiguration +// ============================================================================ + +export interface IConfiguration { + toJSON(): MarshalledHandle; + getConfigValue(key: string): Promise; + getConnectionString(name: string): Promise; + getSection(key: string): Promise; + getChildren(): Promise; + exists(key: string): Promise; +} + +export interface IConfigurationPromise extends PromiseLike { + getConfigValue(key: string): Promise; + getConnectionString(name: string): Promise; + getSection(key: string): Promise; + getChildren(): Promise; + exists(key: string): Promise; +} + +// ============================================================================ +// 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)); + } + +} + +// ============================================================================ +// IDistributedApplicationBuilder +// ============================================================================ + +export interface IDistributedApplicationBuilder { + toJSON(): MarshalledHandle; + appHostDirectory: { + get: () => Promise; + }; + environment: { + get: () => Promise; + }; + eventing: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; + userSecretsManager: { + get: () => Promise; + }; + build(): IDistributedApplicationPromise; + addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; + addContainer(name: string, image: string): IContainerResourcePromise; + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; + addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; + addExternalService(name: string, url: string): IExternalServiceResourcePromise; + addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; + addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; + addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; + addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; + addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; + addCSharpApp(name: string, path: string): IProjectResourcePromise; + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; + getConfiguration(): IConfigurationPromise; + subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; + subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; + addSqlServer(name: string, options?: AddSqlServerOptions): ISqlServerServerResourcePromise; +} + +export interface IDistributedApplicationBuilderPromise extends PromiseLike { + build(): IDistributedApplicationPromise; + addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; + addContainer(name: string, image: string): IContainerResourcePromise; + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; + addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; + addExternalService(name: string, url: string): IExternalServiceResourcePromise; + addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; + addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; + addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; + addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; + addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; + addCSharpApp(name: string, path: string): IProjectResourcePromise; + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; + getConfiguration(): IConfigurationPromise; + subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; + subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; + addSqlServer(name: string, options?: AddSqlServerOptions): ISqlServerServerResourcePromise; +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the 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 => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** 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 { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: IReferenceExpression): 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: IReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: IParameterResource, repository?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistry', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + 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 { + const rpcArgs: Record = { builder: this._handle, name, image }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + addContainer(name: string, image: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @internal */ + async _addDockerfileInternal(name: string, contextPath: string, dockerfilePath?: string, stage?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, contextPath }; + if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; + if (stage !== undefined) rpcArgs.stage = stage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addDockerfile', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @internal */ + async _addDotnetToolInternal(name: string, packageId: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, packageId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addDotnetTool', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @internal */ + async _addExecutableInternal(name: string, command: string, workingDirectory: string, args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, command, workingDirectory, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExecutable', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds 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: IParameterResource): 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: IParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter 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 { + const rpcArgs: Record = { builder: this._handle, name, configurationKey }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterFromConfiguration', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { + 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: IBeforeStartEvent) => 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: IAfterResourcesCreatedEvent) => 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 a SQL Server container resource */ + /** @internal */ + async _addSqlServerInternal(name: string, password?: IParameterResource, port?: number): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (password !== undefined) rpcArgs.password = password; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/addSqlServer', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { + const password = options?.password; + const port = options?.port; + return new SqlServerServerResourcePromise(this._addSqlServerInternal(name, password, port)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): 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: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => 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))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds 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: IParameterResource): 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))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => 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: IBeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds a SQL Server container resource */ + addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.addSqlServer(name, options))); + } + +} + +// ============================================================================ +// IDistributedApplicationEventing +// ============================================================================ + +export interface IDistributedApplicationEventing { + toJSON(): MarshalledHandle; + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): IDistributedApplicationEventingPromise; +} + +export interface IDistributedApplicationEventingPromise extends PromiseLike { + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): IDistributedApplicationEventingPromise; +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @internal */ + async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { + const rpcArgs: Record = { context: this._handle, subscription }; + await this._client.invokeCapability( + 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', + rpcArgs + ); + return this; + } + + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// IHostEnvironment +// ============================================================================ + +export interface IHostEnvironment { + toJSON(): MarshalledHandle; + isDevelopment(): Promise; + isProduction(): Promise; + isStaging(): Promise; + isEnvironment(environmentName: string): Promise; +} + +export interface IHostEnvironmentPromise extends PromiseLike { + isDevelopment(): Promise; + isProduction(): Promise; + isStaging(): Promise; + isEnvironment(environmentName: string): Promise; +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + 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)); + } + +} + +// ============================================================================ +// ILogger +// ============================================================================ + +export interface ILogger { + toJSON(): MarshalledHandle; + logInformation(message: string): ILoggerPromise; + logWarning(message: string): ILoggerPromise; + logError(message: string): ILoggerPromise; + logDebug(message: string): ILoggerPromise; + log(level: string, message: string): ILoggerPromise; +} + +export interface ILoggerPromise extends PromiseLike { + logInformation(message: string): ILoggerPromise; + logWarning(message: string): ILoggerPromise; + logError(message: string): ILoggerPromise; + logDebug(message: string): ILoggerPromise; + log(level: string, message: string): ILoggerPromise; +} + +// ============================================================================ +// 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))); + } + +} + +// ============================================================================ +// ILoggerFactory +// ============================================================================ + +export interface ILoggerFactory { + toJSON(): MarshalledHandle; + createLogger(categoryName: string): ILoggerPromise; +} + +export interface ILoggerFactoryPromise extends PromiseLike { + createLogger(categoryName: string): ILoggerPromise; +} + +// ============================================================================ +// 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))); + } + +} + +// ============================================================================ +// IReportingStep +// ============================================================================ + +export interface IReportingStep { + toJSON(): MarshalledHandle; + createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; + logStep(level: string, message: string): IReportingStepPromise; + logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; + completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; +} + +export interface IReportingStepPromise extends PromiseLike { + createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; + logStep(level: string, message: string): IReportingStepPromise; + logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; + completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; +} + +// ============================================================================ +// 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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))); + } + +} + +// ============================================================================ +// IReportingTask +// ============================================================================ + +export interface IReportingTask { + toJSON(): MarshalledHandle; + updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; + completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; +} + +export interface IReportingTaskPromise extends PromiseLike { + updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; + completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; +} + +// ============================================================================ +// 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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))); + } + +} + +// ============================================================================ +// IServiceProvider +// ============================================================================ + +export interface IServiceProvider { + toJSON(): MarshalledHandle; + getEventing(): IDistributedApplicationEventingPromise; + getLoggerFactory(): ILoggerFactoryPromise; + getResourceLoggerService(): IResourceLoggerServicePromise; + getDistributedApplicationModel(): IDistributedApplicationModelPromise; + getResourceNotificationService(): IResourceNotificationServicePromise; + getUserSecretsManager(): IUserSecretsManagerPromise; +} + +export interface IServiceProviderPromise extends PromiseLike { + getEventing(): IDistributedApplicationEventingPromise; + getLoggerFactory(): ILoggerFactoryPromise; + getResourceLoggerService(): IResourceLoggerServicePromise; + getDistributedApplicationModel(): IDistributedApplicationModelPromise; + getResourceNotificationService(): IResourceNotificationServicePromise; + getUserSecretsManager(): IUserSecretsManagerPromise; +} + +// ============================================================================ +// 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())); + } + +} + +// ============================================================================ +// IUserSecretsManager +// ============================================================================ + +export interface IUserSecretsManager { + toJSON(): MarshalledHandle; + isAvailable: { + get: () => Promise; + }; + filePath: { + get: () => Promise; + }; + trySetSecret(name: string, value: string): Promise; + saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; + getOrSetSecret(resourceBuilder: IResource, name: string, value: string): IUserSecretsManagerPromise; +} + +export interface IUserSecretsManagerPromise extends PromiseLike { + trySetSecret(name: string, value: string): Promise; + saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; + getOrSetSecret(resourceBuilder: IResource, name: string, value: string): IUserSecretsManagerPromise; +} + +// ============================================================================ +// 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 | ICancellationToken): 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: IResource, 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: IResource, 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: IResource, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); + } + +} + +// ============================================================================ +// IConnectionStringResource +// ============================================================================ + +export interface IConnectionStringResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IConnectionStringResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; + withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; + getConnectionProperty(key: string): Promise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; + excludeFromManifest(): IConnectionStringResourcePromise; + waitFor(dependency: IResource): IConnectionStringResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + waitForStart(dependency: IResource): IConnectionStringResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + withExplicitStart(): IConnectionStringResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; + withHealthCheck(key: string): IConnectionStringResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; + withParentRelationship(parent: IResource): IConnectionStringResourcePromise; + withChildRelationship(child: IResource): IConnectionStringResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; + excludeFromMcp(): IConnectionStringResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; +} + +export interface IConnectionStringResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IConnectionStringResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; + withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; + getConnectionProperty(key: string): Promise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; + excludeFromManifest(): IConnectionStringResourcePromise; + waitFor(dependency: IResource): IConnectionStringResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + waitForStart(dependency: IResource): IConnectionStringResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + withExplicitStart(): IConnectionStringResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; + withHealthCheck(key: string): IConnectionStringResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; + withParentRelationship(parent: IResource): IConnectionStringResourcePromise; + withChildRelationship(child: IResource): IConnectionStringResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; + excludeFromMcp(): IConnectionStringResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; +} + +// ============================================================================ +// ConnectionStringResource +// ============================================================================ + +export class ConnectionStringResource extends ResourceBuilderBase { + constructor(handle: ConnectionStringResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ConnectionStringResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { + const helpLink = options?.helpLink; + return new ConnectionStringResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** 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: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { + const displayText = options?.displayText; + return new ConnectionStringResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { + const displayText = options?.displayText; + return new ConnectionStringResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { + const exitCode = options?.exitCode; + return new ConnectionStringResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + const commandOptions = options?.commandOptions; + return new ConnectionStringResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { + const iconVariant = options?.iconVariant; + return new ConnectionStringResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ConnectionStringResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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: IConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for ConnectionStringResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ConnectionStringResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ConnectionStringResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** 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: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IContainerRegistryResource +// ============================================================================ + +export interface IContainerRegistryResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IContainerRegistryResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; + excludeFromManifest(): IContainerRegistryResourcePromise; + withExplicitStart(): IContainerRegistryResourcePromise; + withHealthCheck(key: string): IContainerRegistryResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; + withParentRelationship(parent: IResource): IContainerRegistryResourcePromise; + withChildRelationship(child: IResource): IContainerRegistryResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; + excludeFromMcp(): IContainerRegistryResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; +} + +export interface IContainerRegistryResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IContainerRegistryResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; + excludeFromManifest(): IContainerRegistryResourcePromise; + withExplicitStart(): IContainerRegistryResourcePromise; + withHealthCheck(key: string): IContainerRegistryResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; + withParentRelationship(parent: IResource): IContainerRegistryResourcePromise; + withChildRelationship(child: IResource): IContainerRegistryResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; + excludeFromMcp(): IContainerRegistryResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; +} + +// ============================================================================ +// ContainerRegistryResource +// ============================================================================ + +export class ContainerRegistryResource extends ResourceBuilderBase { + constructor(handle: ContainerRegistryResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ContainerRegistryResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { + const helpLink = options?.helpLink; + return new ContainerRegistryResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + const displayText = options?.displayText; + return new ContainerRegistryResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + const displayText = options?.displayText; + return new ContainerRegistryResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + const commandOptions = options?.commandOptions; + return new ContainerRegistryResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ContainerRegistryResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for ContainerRegistryResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ContainerRegistryResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ContainerRegistryResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IContainerResource +// ============================================================================ + +export interface IContainerResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IContainerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; + withEntrypoint(entrypoint: string): IContainerResourcePromise; + withImageTag(tag: string): IContainerResourcePromise; + withImageRegistry(registry: string): IContainerResourcePromise; + withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; + withImageSHA256(sha256: string): IContainerResourcePromise; + withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; + withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; + publishAsContainer(): IContainerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; + withContainerName(name: string): IContainerResourcePromise; + withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; + withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; + withContainerNetworkAlias(alias: string): IContainerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; + withOtlpExporter(): IContainerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; + publishAsConnectionString(): IContainerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IContainerResourcePromise; + withArgs(args: string[]): IContainerResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IContainerResourcePromise; + withReferenceUri(name: string, uri: string): IContainerResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; + withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; + withExternalHttpEndpoints(): IContainerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IContainerResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; + excludeFromManifest(): IContainerResourcePromise; + waitFor(dependency: IResource): IContainerResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; + waitForStart(dependency: IResource): IContainerResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; + withExplicitStart(): IContainerResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IContainerResourcePromise; + withHealthCheck(key: string): IContainerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; + withoutHttpsCertificate(): IContainerResourcePromise; + withParentRelationship(parent: IResource): IContainerResourcePromise; + withChildRelationship(child: IResource): IContainerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; + excludeFromMcp(): IContainerResourcePromise; + withRemoteImageName(remoteImageName: string): IContainerResourcePromise; + withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; +} + +export interface IContainerResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IContainerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; + withEntrypoint(entrypoint: string): IContainerResourcePromise; + withImageTag(tag: string): IContainerResourcePromise; + withImageRegistry(registry: string): IContainerResourcePromise; + withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; + withImageSHA256(sha256: string): IContainerResourcePromise; + withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; + withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; + publishAsContainer(): IContainerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; + withContainerName(name: string): IContainerResourcePromise; + withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; + withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; + withContainerNetworkAlias(alias: string): IContainerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; + withOtlpExporter(): IContainerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; + publishAsConnectionString(): IContainerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IContainerResourcePromise; + withArgs(args: string[]): IContainerResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IContainerResourcePromise; + withReferenceUri(name: string, uri: string): IContainerResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; + withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; + withExternalHttpEndpoints(): IContainerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IContainerResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; + excludeFromManifest(): IContainerResourcePromise; + waitFor(dependency: IResource): IContainerResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; + waitForStart(dependency: IResource): IContainerResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; + withExplicitStart(): IContainerResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IContainerResourcePromise; + withHealthCheck(key: string): IContainerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; + withoutHttpsCertificate(): IContainerResourcePromise; + withParentRelationship(parent: IResource): IContainerResourcePromise; + withChildRelationship(child: IResource): IContainerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; + excludeFromMcp(): IContainerResourcePromise; + withRemoteImageName(remoteImageName: string): IContainerResourcePromise; + withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export class ContainerResource extends ResourceBuilderBase { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new 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: IParameterResource): 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: IParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: IParameterResource): 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: IParameterResource): 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 }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + 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 }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ContainerResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise { + return new ContainerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new 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 _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IResource, 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 + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ContainerResourcePromise { + return new ContainerResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { + const displayText = options?.displayText; + return new ContainerResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { + const displayText = options?.displayText; + return new ContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerResourcePromise { + return new ContainerResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ContainerResourcePromise { + const exitCode = options?.exitCode; + return new ContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new ContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { + return new ContainerResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { + const password = options?.password; + return new ContainerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ContainerResourcePromise { + return new ContainerResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ContainerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerResourcePromise { + return new ContainerResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new 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 }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for ContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ContainerResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ContainerResourcePromise { + 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: IParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: IParameterResource): 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))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** 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 environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { + 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: IBeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// ICSharpAppResource +// ============================================================================ + +export interface ICSharpAppResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): ICSharpAppResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; + withOtlpExporter(): ICSharpAppResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; + withReplicas(replicas: number): ICSharpAppResourcePromise; + disableForwardedHeaders(): ICSharpAppResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ICSharpAppResourcePromise; + withArgs(args: string[]): ICSharpAppResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): ICSharpAppResourcePromise; + withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; + withExternalHttpEndpoints(): ICSharpAppResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ICSharpAppResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ICSharpAppResourcePromise; + excludeFromManifest(): ICSharpAppResourcePromise; + waitFor(dependency: IResource): ICSharpAppResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + waitForStart(dependency: IResource): ICSharpAppResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + withExplicitStart(): ICSharpAppResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; + withHealthCheck(key: string): ICSharpAppResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; + withoutHttpsCertificate(): ICSharpAppResourcePromise; + withParentRelationship(parent: IResource): ICSharpAppResourcePromise; + withChildRelationship(child: IResource): ICSharpAppResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; + excludeFromMcp(): ICSharpAppResourcePromise; + withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; + withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; +} + +export interface ICSharpAppResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): ICSharpAppResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; + withOtlpExporter(): ICSharpAppResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; + withReplicas(replicas: number): ICSharpAppResourcePromise; + disableForwardedHeaders(): ICSharpAppResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ICSharpAppResourcePromise; + withArgs(args: string[]): ICSharpAppResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): ICSharpAppResourcePromise; + withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; + withExternalHttpEndpoints(): ICSharpAppResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ICSharpAppResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ICSharpAppResourcePromise; + excludeFromManifest(): ICSharpAppResourcePromise; + waitFor(dependency: IResource): ICSharpAppResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + waitForStart(dependency: IResource): ICSharpAppResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + withExplicitStart(): ICSharpAppResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; + withHealthCheck(key: string): ICSharpAppResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; + withoutHttpsCertificate(): ICSharpAppResourcePromise; + withParentRelationship(parent: IResource): ICSharpAppResourcePromise; + withChildRelationship(child: IResource): ICSharpAppResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; + excludeFromMcp(): ICSharpAppResourcePromise; + withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; + withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; +} + +// ============================================================================ +// CSharpAppResource +// ============================================================================ + +export class CSharpAppResource extends ResourceBuilderBase { + constructor(handle: CSharpAppResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new CSharpAppResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReplicas', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the number of replicas */ + withReplicas(replicas: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReplicasInternal(replicas)); + } + + /** @internal */ + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/disableForwardedHeaders', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._disableForwardedHeadersInternal()); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure?: (obj: IContainerResource) => 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/publishProjectAsDockerFileWithConfigure', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IResource, 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 + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new CSharpAppResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new CSharpAppResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new CSharpAppResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { + const displayText = options?.displayText; + return new CSharpAppResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { + const displayText = options?.displayText; + return new CSharpAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: IResourceWithContainerFiles, destinationPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFilesFromResource', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + const exitCode = options?.exitCode; + return new CSharpAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + const commandOptions = options?.commandOptions; + return new CSharpAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { + const password = options?.password; + return new CSharpAppResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { + const iconVariant = options?.iconVariant; + return new CSharpAppResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new CSharpAppResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new CSharpAppResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for CSharpAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class CSharpAppResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: CSharpAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Sets the number of replicas */ + withReplicas(replicas: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); + } + + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); + } + + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IDotnetToolResource +// ============================================================================ + +export interface IDotnetToolResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IDotnetToolResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; + withToolPackage(packageId: string): IDotnetToolResourcePromise; + withToolVersion(version: string): IDotnetToolResourcePromise; + withToolPrerelease(): IDotnetToolResourcePromise; + withToolSource(source: string): IDotnetToolResourcePromise; + withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; + withToolIgnoreFailedSources(): IDotnetToolResourcePromise; + publishAsDockerFile(): IDotnetToolResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; + withExecutableCommand(command: string): IDotnetToolResourcePromise; + withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; + withOtlpExporter(): IDotnetToolResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IDotnetToolResourcePromise; + withArgs(args: string[]): IDotnetToolResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IDotnetToolResourcePromise; + withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; + withExternalHttpEndpoints(): IDotnetToolResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IDotnetToolResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; + excludeFromManifest(): IDotnetToolResourcePromise; + waitFor(dependency: IResource): IDotnetToolResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + waitForStart(dependency: IResource): IDotnetToolResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + withExplicitStart(): IDotnetToolResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; + withHealthCheck(key: string): IDotnetToolResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; + withoutHttpsCertificate(): IDotnetToolResourcePromise; + withParentRelationship(parent: IResource): IDotnetToolResourcePromise; + withChildRelationship(child: IResource): IDotnetToolResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; + excludeFromMcp(): IDotnetToolResourcePromise; + withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; + withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; +} + +export interface IDotnetToolResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IDotnetToolResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; + withToolPackage(packageId: string): IDotnetToolResourcePromise; + withToolVersion(version: string): IDotnetToolResourcePromise; + withToolPrerelease(): IDotnetToolResourcePromise; + withToolSource(source: string): IDotnetToolResourcePromise; + withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; + withToolIgnoreFailedSources(): IDotnetToolResourcePromise; + publishAsDockerFile(): IDotnetToolResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; + withExecutableCommand(command: string): IDotnetToolResourcePromise; + withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; + withOtlpExporter(): IDotnetToolResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IDotnetToolResourcePromise; + withArgs(args: string[]): IDotnetToolResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IDotnetToolResourcePromise; + withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; + withExternalHttpEndpoints(): IDotnetToolResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IDotnetToolResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; + excludeFromManifest(): IDotnetToolResourcePromise; + waitFor(dependency: IResource): IDotnetToolResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + waitForStart(dependency: IResource): IDotnetToolResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + withExplicitStart(): IDotnetToolResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; + withHealthCheck(key: string): IDotnetToolResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; + withoutHttpsCertificate(): IDotnetToolResourcePromise; + withParentRelationship(parent: IResource): IDotnetToolResourcePromise; + withChildRelationship(child: IResource): IDotnetToolResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; + excludeFromMcp(): IDotnetToolResourcePromise; + withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; + withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; +} + +// ============================================================================ +// DotnetToolResource +// ============================================================================ + +export class DotnetToolResource extends ResourceBuilderBase { + constructor(handle: DotnetToolResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new DotnetToolResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withToolPackageInternal(packageId: string): Promise { + const rpcArgs: Record = { builder: this._handle, packageId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolPackage', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the tool package ID */ + withToolPackage(packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolPackageInternal(packageId)); + } + + /** @internal */ + private async _withToolVersionInternal(version: string): Promise { + const rpcArgs: Record = { builder: this._handle, version }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolVersion', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the tool version */ + withToolVersion(version: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolVersionInternal(version)); + } + + /** @internal */ + private async _withToolPrereleaseInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolPrerelease', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Allows prerelease tool versions */ + withToolPrerelease(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolPrereleaseInternal()); + } + + /** @internal */ + private async _withToolSourceInternal(source: string): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolSource', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a NuGet source for the tool */ + withToolSource(source: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolSourceInternal(source)); + } + + /** @internal */ + private async _withToolIgnoreExistingFeedsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolIgnoreExistingFeeds', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Ignores existing NuGet feeds */ + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolIgnoreExistingFeedsInternal()); + } + + /** @internal */ + private async _withToolIgnoreFailedSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withToolIgnoreFailedSources', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Ignores failed NuGet sources */ + withToolIgnoreFailedSources(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withToolIgnoreFailedSourcesInternal()); + } + + /** @internal */ + private async _publishAsDockerFileInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: IContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @internal */ + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExecutableCommand', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @internal */ + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withWorkingDirectory', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { + const helpLink = options?.helpLink; + return new DotnetToolResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IResource, 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 + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new DotnetToolResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DotnetToolResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new DotnetToolResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { + const displayText = options?.displayText; + return new DotnetToolResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { + const displayText = options?.displayText; + return new DotnetToolResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + const exitCode = options?.exitCode; + return new DotnetToolResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + const commandOptions = options?.commandOptions; + return new DotnetToolResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { + const password = options?.password; + return new DotnetToolResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { + const iconVariant = options?.iconVariant; + return new DotnetToolResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new DotnetToolResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new DotnetToolResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for DotnetToolResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class DotnetToolResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Sets the tool package ID */ + withToolPackage(packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPackage(packageId))); + } + + /** Sets the tool version */ + withToolVersion(version: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolVersion(version))); + } + + /** Allows prerelease tool versions */ + withToolPrerelease(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPrerelease())); + } + + /** Adds a NuGet source for the tool */ + withToolSource(source: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolSource(source))); + } + + /** Ignores existing NuGet feeds */ + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreExistingFeeds())); + } + + /** Ignores failed NuGet sources */ + withToolIgnoreFailedSources(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreFailedSources())); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IExecutableResource +// ============================================================================ + +export interface IExecutableResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IExecutableResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; + publishAsDockerFile(): IExecutableResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; + withExecutableCommand(command: string): IExecutableResourcePromise; + withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; + withOtlpExporter(): IExecutableResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IExecutableResourcePromise; + withArgs(args: string[]): IExecutableResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IExecutableResourcePromise; + withReferenceUri(name: string, uri: string): IExecutableResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; + withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; + withExternalHttpEndpoints(): IExecutableResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IExecutableResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; + excludeFromManifest(): IExecutableResourcePromise; + waitFor(dependency: IResource): IExecutableResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; + waitForStart(dependency: IResource): IExecutableResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; + withExplicitStart(): IExecutableResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IExecutableResourcePromise; + withHealthCheck(key: string): IExecutableResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; + withoutHttpsCertificate(): IExecutableResourcePromise; + withParentRelationship(parent: IResource): IExecutableResourcePromise; + withChildRelationship(child: IResource): IExecutableResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; + excludeFromMcp(): IExecutableResourcePromise; + withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; + withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; +} + +export interface IExecutableResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IExecutableResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; + publishAsDockerFile(): IExecutableResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; + withExecutableCommand(command: string): IExecutableResourcePromise; + withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; + withOtlpExporter(): IExecutableResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IExecutableResourcePromise; + withArgs(args: string[]): IExecutableResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IExecutableResourcePromise; + withReferenceUri(name: string, uri: string): IExecutableResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; + withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; + withExternalHttpEndpoints(): IExecutableResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IExecutableResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; + excludeFromManifest(): IExecutableResourcePromise; + waitFor(dependency: IResource): IExecutableResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; + waitForStart(dependency: IResource): IExecutableResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; + withExplicitStart(): IExecutableResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IExecutableResourcePromise; + withHealthCheck(key: string): IExecutableResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; + withoutHttpsCertificate(): IExecutableResourcePromise; + withParentRelationship(parent: IResource): IExecutableResourcePromise; + withChildRelationship(child: IResource): IExecutableResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; + excludeFromMcp(): IExecutableResourcePromise; + withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; + withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; +} + +// ============================================================================ +// ExecutableResource +// ============================================================================ + +export class ExecutableResource extends ResourceBuilderBase { + constructor(handle: ExecutableResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ExecutableResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _publishAsDockerFileInternal(): Promise { + 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: IContainerResource) => 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: IContainerResource) => 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 }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ExecutableResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { + const helpLink = options?.helpLink; + return new ExecutableResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IResource, 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 + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ExecutableResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ExecutableResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ExecutableResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { + const displayText = options?.displayText; + return new ExecutableResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { + const displayText = options?.displayText; + return new ExecutableResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ExecutableResourcePromise { + const exitCode = options?.exitCode; + return new ExecutableResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ExecutableResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { + const commandOptions = options?.commandOptions; + return new ExecutableResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { + const password = options?.password; + return new ExecutableResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { + const iconVariant = options?.iconVariant; + return new ExecutableResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ExecutableResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for ExecutableResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ExecutableResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ExecutableResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** 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: IContainerResource) => 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))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IExternalServiceResource +// ============================================================================ + +export interface IExternalServiceResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IExternalServiceResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; + excludeFromManifest(): IExternalServiceResourcePromise; + withExplicitStart(): IExternalServiceResourcePromise; + withHealthCheck(key: string): IExternalServiceResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; + withParentRelationship(parent: IResource): IExternalServiceResourcePromise; + withChildRelationship(child: IResource): IExternalServiceResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; + excludeFromMcp(): IExternalServiceResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; +} + +export interface IExternalServiceResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IExternalServiceResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; + excludeFromManifest(): IExternalServiceResourcePromise; + withExplicitStart(): IExternalServiceResourcePromise; + withHealthCheck(key: string): IExternalServiceResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; + withParentRelationship(parent: IResource): IExternalServiceResourcePromise; + withChildRelationship(child: IResource): IExternalServiceResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; + excludeFromMcp(): IExternalServiceResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; +} + +// ============================================================================ +// ExternalServiceResource +// ============================================================================ + +export class ExternalServiceResource extends ResourceBuilderBase { + constructor(handle: ExternalServiceResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ExternalServiceResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withExternalServiceHttpHealthCheckInternal(path?: string, statusCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalServiceHttpHealthCheck', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds an HTTP health check to an external service */ + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + return new ExternalServiceResourcePromise(this._withExternalServiceHttpHealthCheckInternal(path, statusCode)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { + const helpLink = options?.helpLink; + return new ExternalServiceResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { + const displayText = options?.displayText; + return new ExternalServiceResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { + const displayText = options?.displayText; + return new ExternalServiceResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + const commandOptions = options?.commandOptions; + return new ExternalServiceResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { + const iconVariant = options?.iconVariant; + return new ExternalServiceResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ExternalServiceResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for ExternalServiceResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ExternalServiceResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ExternalServiceResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds an HTTP health check to an external service */ + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExternalServiceHttpHealthCheck(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IParameterResource +// ============================================================================ + +export interface IParameterResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IParameterResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; + withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; + excludeFromManifest(): IParameterResourcePromise; + withExplicitStart(): IParameterResourcePromise; + withHealthCheck(key: string): IParameterResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; + withParentRelationship(parent: IResource): IParameterResourcePromise; + withChildRelationship(child: IResource): IParameterResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; + excludeFromMcp(): IParameterResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; +} + +export interface IParameterResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IParameterResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; + withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; + excludeFromManifest(): IParameterResourcePromise; + withExplicitStart(): IParameterResourcePromise; + withHealthCheck(key: string): IParameterResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; + withParentRelationship(parent: IResource): IParameterResourcePromise; + withChildRelationship(child: IResource): IParameterResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; + excludeFromMcp(): IParameterResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; +} + +// ============================================================================ +// ParameterResource +// ============================================================================ + +export class ParameterResource extends ResourceBuilderBase { + constructor(handle: ParameterResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ParameterResourcePromise { + return new ParameterResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ParameterResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withDescriptionInternal(description: string, enableMarkdown?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, description }; + if (enableMarkdown !== undefined) rpcArgs.enableMarkdown = enableMarkdown; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDescription', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Sets a parameter description */ + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { + const enableMarkdown = options?.enableMarkdown; + return new ParameterResourcePromise(this._withDescriptionInternal(description, enableMarkdown)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { + const helpLink = options?.helpLink; + return new ParameterResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { + const displayText = options?.displayText; + return new ParameterResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { + const displayText = options?.displayText; + return new ParameterResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ParameterResourcePromise { + return new ParameterResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ParameterResourcePromise { + return new ParameterResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + const commandOptions = options?.commandOptions; + return new ParameterResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ParameterResourcePromise { + return new ParameterResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ParameterResourcePromise { + return new ParameterResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { + const iconVariant = options?.iconVariant; + return new ParameterResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ParameterResourcePromise { + return new ParameterResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for ParameterResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ParameterResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ParameterResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Sets a parameter description */ + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withDescription(description, options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IProjectResource +// ============================================================================ + +export interface IProjectResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IProjectResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; + withOtlpExporter(): IProjectResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; + withReplicas(replicas: number): IProjectResourcePromise; + disableForwardedHeaders(): IProjectResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IProjectResourcePromise; + withArgs(args: string[]): IProjectResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IProjectResourcePromise; + withReferenceUri(name: string, uri: string): IProjectResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; + withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; + withExternalHttpEndpoints(): IProjectResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IProjectResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IProjectResourcePromise; + excludeFromManifest(): IProjectResourcePromise; + waitFor(dependency: IResource): IProjectResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; + waitForStart(dependency: IResource): IProjectResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; + withExplicitStart(): IProjectResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IProjectResourcePromise; + withHealthCheck(key: string): IProjectResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; + withoutHttpsCertificate(): IProjectResourcePromise; + withParentRelationship(parent: IResource): IProjectResourcePromise; + withChildRelationship(child: IResource): IProjectResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; + excludeFromMcp(): IProjectResourcePromise; + withRemoteImageName(remoteImageName: string): IProjectResourcePromise; + withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; +} + +export interface IProjectResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IProjectResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; + withOtlpExporter(): IProjectResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; + withReplicas(replicas: number): IProjectResourcePromise; + disableForwardedHeaders(): IProjectResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IProjectResourcePromise; + withArgs(args: string[]): IProjectResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): IProjectResourcePromise; + withReferenceUri(name: string, uri: string): IProjectResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; + withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; + withExternalHttpEndpoints(): IProjectResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IProjectResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IProjectResourcePromise; + excludeFromManifest(): IProjectResourcePromise; + waitFor(dependency: IResource): IProjectResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; + waitForStart(dependency: IResource): IProjectResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; + withExplicitStart(): IProjectResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IProjectResourcePromise; + withHealthCheck(key: string): IProjectResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; + withoutHttpsCertificate(): IProjectResourcePromise; + withParentRelationship(parent: IResource): IProjectResourcePromise; + withChildRelationship(child: IResource): IProjectResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; + excludeFromMcp(): IProjectResourcePromise; + withRemoteImageName(remoteImageName: string): IProjectResourcePromise; + withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; +} + +// ============================================================================ +// ProjectResource +// ============================================================================ + +export class ProjectResource extends ResourceBuilderBase { + constructor(handle: ProjectResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ProjectResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ProjectResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ProjectResourcePromise { + return new ProjectResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { + return new ProjectResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReplicas', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); + } + + /** @internal */ + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/disableForwardedHeaders', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); + } + + /** @internal */ + private async _publishAsDockerFileInternal(configure?: (obj: IContainerResource) => 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/publishProjectAsDockerFileWithConfigure', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** 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 _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new 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)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): ProjectResourcePromise { + return new ProjectResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IResource, 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 + ); + return new ProjectResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ProjectResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ProjectResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ProjectResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ProjectResourcePromise { + return new ProjectResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ProjectResourcePromise { + return new ProjectResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise { + const displayText = options?.displayText; + return new ProjectResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { + const displayText = options?.displayText; + return new ProjectResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: IResourceWithContainerFiles, destinationPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFilesFromResource', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ProjectResourcePromise { + return new ProjectResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ProjectResourcePromise { + return new ProjectResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ProjectResourcePromise { + const exitCode = options?.exitCode; + return new ProjectResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ProjectResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + const commandOptions = options?.commandOptions; + return new ProjectResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { + return new ProjectResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { + return new ProjectResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { + const password = options?.password; + return new ProjectResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ProjectResourcePromise { + return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { + const iconVariant = options?.iconVariant; + return new ProjectResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ProjectResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ProjectResourcePromise { + return new ProjectResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for ProjectResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ProjectResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ProjectResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); + } + + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); + } + + /** 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))); + } + + /** 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 callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds arguments */ + withArgs(args: string[]): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// ISqlServerDatabaseResource +// ============================================================================ + +export interface ISqlServerDatabaseResource { + toJSON(): MarshalledHandle; + parent: { + get: () => Promise; + }; + connectionStringExpression: { + get: () => Promise; + }; + uriExpression: { + get: () => Promise; + }; + jdbcConnectionString: { + get: () => Promise; + }; + databaseName: { + get: () => Promise; + }; + name: { + get: () => Promise; + }; + withContainerRegistry(registry: IResource): ISqlServerDatabaseResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerDatabaseResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerDatabaseResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerDatabaseResourcePromise; + withConnectionPropertyValue(name: string, value: string): ISqlServerDatabaseResourcePromise; + getConnectionProperty(key: string): Promise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ISqlServerDatabaseResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerDatabaseResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerDatabaseResourcePromise; + excludeFromManifest(): ISqlServerDatabaseResourcePromise; + withExplicitStart(): ISqlServerDatabaseResourcePromise; + withHealthCheck(key: string): ISqlServerDatabaseResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerDatabaseResourcePromise; + withParentRelationship(parent: IResource): ISqlServerDatabaseResourcePromise; + withChildRelationship(child: IResource): ISqlServerDatabaseResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerDatabaseResourcePromise; + excludeFromMcp(): ISqlServerDatabaseResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerDatabaseResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerDatabaseResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerDatabaseResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerDatabaseResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerDatabaseResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerDatabaseResourcePromise; + withCreationScript(script: string): ISqlServerDatabaseResourcePromise; +} + +export interface ISqlServerDatabaseResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): ISqlServerDatabaseResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerDatabaseResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerDatabaseResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerDatabaseResourcePromise; + withConnectionPropertyValue(name: string, value: string): ISqlServerDatabaseResourcePromise; + getConnectionProperty(key: string): Promise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ISqlServerDatabaseResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerDatabaseResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerDatabaseResourcePromise; + excludeFromManifest(): ISqlServerDatabaseResourcePromise; + withExplicitStart(): ISqlServerDatabaseResourcePromise; + withHealthCheck(key: string): ISqlServerDatabaseResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerDatabaseResourcePromise; + withParentRelationship(parent: IResource): ISqlServerDatabaseResourcePromise; + withChildRelationship(child: IResource): ISqlServerDatabaseResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerDatabaseResourcePromise; + excludeFromMcp(): ISqlServerDatabaseResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerDatabaseResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerDatabaseResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerDatabaseResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerDatabaseResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerDatabaseResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerDatabaseResourcePromise; + withCreationScript(script: string): ISqlServerDatabaseResourcePromise; +} + +// ============================================================================ +// SqlServerDatabaseResource +// ============================================================================ + +export class SqlServerDatabaseResource extends ResourceBuilderBase { + constructor(handle: SqlServerDatabaseResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** Gets the Parent property */ + parent = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.parent', + { context: this._handle } + ); + return new SqlServerServerResource(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + + /** Gets the UriExpression property */ + uriExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.uriExpression', + { context: this._handle } + ); + }, + }; + + /** Gets the JdbcConnectionString property */ + jdbcConnectionString = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.jdbcConnectionString', + { context: this._handle } + ); + }, + }; + + /** Gets the DatabaseName property */ + databaseName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.databaseName', + { context: this._handle } + ); + }, + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.name', + { context: this._handle } + ); + }, + }; + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerDatabaseResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new SqlServerDatabaseResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerDatabaseResourcePromise { + const helpLink = options?.helpLink; + return new SqlServerDatabaseResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(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: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): SqlServerDatabaseResourcePromise { + const displayText = options?.displayText; + return new SqlServerDatabaseResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerDatabaseResourcePromise { + const displayText = options?.displayText; + return new SqlServerDatabaseResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerDatabaseResourcePromise { + const commandOptions = options?.commandOptions; + return new SqlServerDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): SqlServerDatabaseResourcePromise { + const iconVariant = options?.iconVariant; + return new SqlServerDatabaseResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerDatabaseResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new SqlServerDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withCreationScriptInternal(script: string): Promise { + const rpcArgs: Record = { builder: this._handle, script }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/withCreationScript', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Defines the SQL script used to create the database */ + withCreationScript(script: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withCreationScriptInternal(script)); + } + +} + +/** + * Thenable wrapper for SqlServerDatabaseResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class SqlServerDatabaseResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: SqlServerDatabaseResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(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: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Defines the SQL script used to create the database */ + withCreationScript(script: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withCreationScript(script))); + } + +} + +// ============================================================================ +// ISqlServerServerResource +// ============================================================================ + +export interface ISqlServerServerResource { + toJSON(): MarshalledHandle; + primaryEndpoint: { + get: () => Promise; + }; + host: { + get: () => Promise; + }; + port: { + get: () => Promise; + }; + passwordParameter: { + get: () => Promise; + set: (value: IParameterResource) => Promise; + }; + userNameReference: { + get: () => Promise; + }; + uriExpression: { + get: () => Promise; + }; + jdbcConnectionString: { + get: () => Promise; + }; + connectionStringExpression: { + get: () => Promise; + }; + readonly databases: AspireDict; + entrypoint: { + get: () => Promise; + set: (value: string) => Promise; + }; + shellExecution: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + name: { + get: () => Promise; + }; + withContainerRegistry(registry: IResource): ISqlServerServerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ISqlServerServerResourcePromise; + withEntrypoint(entrypoint: string): ISqlServerServerResourcePromise; + withImageTag(tag: string): ISqlServerServerResourcePromise; + withImageRegistry(registry: string): ISqlServerServerResourcePromise; + withImage(image: string, options?: WithImageOptions): ISqlServerServerResourcePromise; + withImageSHA256(sha256: string): ISqlServerServerResourcePromise; + withContainerRuntimeArgs(args: string[]): ISqlServerServerResourcePromise; + withLifetime(lifetime: ContainerLifetime): ISqlServerServerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ISqlServerServerResourcePromise; + publishAsContainer(): ISqlServerServerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ISqlServerServerResourcePromise; + withContainerName(name: string): ISqlServerServerResourcePromise; + withBuildArg(name: string, value: IParameterResource): ISqlServerServerResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ISqlServerServerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ISqlServerServerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerServerResourcePromise; + withContainerNetworkAlias(alias: string): ISqlServerServerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ISqlServerServerResourcePromise; + withOtlpExporter(): ISqlServerServerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ISqlServerServerResourcePromise; + publishAsConnectionString(): ISqlServerServerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerServerResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ISqlServerServerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ISqlServerServerResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ISqlServerServerResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ISqlServerServerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ISqlServerServerResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerServerResourcePromise; + withConnectionPropertyValue(name: string, value: string): ISqlServerServerResourcePromise; + withArgs(args: string[]): ISqlServerServerResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): ISqlServerServerResourcePromise; + getConnectionProperty(key: string): Promise; + withReferenceUri(name: string, uri: string): ISqlServerServerResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ISqlServerServerResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ISqlServerServerResourcePromise; + withEndpoint(options?: WithEndpointOptions): ISqlServerServerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ISqlServerServerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ISqlServerServerResourcePromise; + withExternalHttpEndpoints(): ISqlServerServerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ISqlServerServerResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ISqlServerServerResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerServerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerServerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ISqlServerServerResourcePromise; + excludeFromManifest(): ISqlServerServerResourcePromise; + waitFor(dependency: IResource): ISqlServerServerResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; + waitForStart(dependency: IResource): ISqlServerServerResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; + withExplicitStart(): ISqlServerServerResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ISqlServerServerResourcePromise; + withHealthCheck(key: string): ISqlServerServerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ISqlServerServerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerServerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ISqlServerServerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ISqlServerServerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ISqlServerServerResourcePromise; + withoutHttpsCertificate(): ISqlServerServerResourcePromise; + withParentRelationship(parent: IResource): ISqlServerServerResourcePromise; + withChildRelationship(child: IResource): ISqlServerServerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerServerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ISqlServerServerResourcePromise; + excludeFromMcp(): ISqlServerServerResourcePromise; + withRemoteImageName(remoteImageName: string): ISqlServerServerResourcePromise; + withRemoteImageTag(remoteImageTag: string): ISqlServerServerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerServerResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ISqlServerServerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerServerResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerServerResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerServerResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerServerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ISqlServerServerResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerServerResourcePromise; + addDatabase(name: string, options?: AddDatabaseOptions): ISqlServerDatabaseResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ISqlServerServerResourcePromise; + withDataBindMount(source: string, options?: WithDataBindMountOptions): ISqlServerServerResourcePromise; + withPassword(password: IParameterResource): ISqlServerServerResourcePromise; + withHostPort(options?: WithHostPortOptions): ISqlServerServerResourcePromise; +} + +export interface ISqlServerServerResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): ISqlServerServerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ISqlServerServerResourcePromise; + withEntrypoint(entrypoint: string): ISqlServerServerResourcePromise; + withImageTag(tag: string): ISqlServerServerResourcePromise; + withImageRegistry(registry: string): ISqlServerServerResourcePromise; + withImage(image: string, options?: WithImageOptions): ISqlServerServerResourcePromise; + withImageSHA256(sha256: string): ISqlServerServerResourcePromise; + withContainerRuntimeArgs(args: string[]): ISqlServerServerResourcePromise; + withLifetime(lifetime: ContainerLifetime): ISqlServerServerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ISqlServerServerResourcePromise; + publishAsContainer(): ISqlServerServerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ISqlServerServerResourcePromise; + withContainerName(name: string): ISqlServerServerResourcePromise; + withBuildArg(name: string, value: IParameterResource): ISqlServerServerResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ISqlServerServerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ISqlServerServerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerServerResourcePromise; + withContainerNetworkAlias(alias: string): ISqlServerServerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ISqlServerServerResourcePromise; + withOtlpExporter(): ISqlServerServerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ISqlServerServerResourcePromise; + publishAsConnectionString(): ISqlServerServerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerServerResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ISqlServerServerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ISqlServerServerResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ISqlServerServerResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ISqlServerServerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ISqlServerServerResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerServerResourcePromise; + withConnectionPropertyValue(name: string, value: string): ISqlServerServerResourcePromise; + withArgs(args: string[]): ISqlServerServerResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withReference(source: IResource, options?: WithReferenceOptions): ISqlServerServerResourcePromise; + getConnectionProperty(key: string): Promise; + withReferenceUri(name: string, uri: string): ISqlServerServerResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ISqlServerServerResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ISqlServerServerResourcePromise; + withEndpoint(options?: WithEndpointOptions): ISqlServerServerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ISqlServerServerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ISqlServerServerResourcePromise; + withExternalHttpEndpoints(): ISqlServerServerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ISqlServerServerResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ISqlServerServerResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerServerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerServerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ISqlServerServerResourcePromise; + excludeFromManifest(): ISqlServerServerResourcePromise; + waitFor(dependency: IResource): ISqlServerServerResourcePromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; + waitForStart(dependency: IResource): ISqlServerServerResourcePromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; + withExplicitStart(): ISqlServerServerResourcePromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ISqlServerServerResourcePromise; + withHealthCheck(key: string): ISqlServerServerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ISqlServerServerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerServerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ISqlServerServerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ISqlServerServerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ISqlServerServerResourcePromise; + withoutHttpsCertificate(): ISqlServerServerResourcePromise; + withParentRelationship(parent: IResource): ISqlServerServerResourcePromise; + withChildRelationship(child: IResource): ISqlServerServerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerServerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ISqlServerServerResourcePromise; + excludeFromMcp(): ISqlServerServerResourcePromise; + withRemoteImageName(remoteImageName: string): ISqlServerServerResourcePromise; + withRemoteImageTag(remoteImageTag: string): ISqlServerServerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerServerResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ISqlServerServerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerServerResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerServerResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerServerResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerServerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ISqlServerServerResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerServerResourcePromise; + addDatabase(name: string, options?: AddDatabaseOptions): ISqlServerDatabaseResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ISqlServerServerResourcePromise; + withDataBindMount(source: string, options?: WithDataBindMountOptions): ISqlServerServerResourcePromise; + withPassword(password: IParameterResource): ISqlServerServerResourcePromise; + withHostPort(options?: WithHostPortOptions): ISqlServerServerResourcePromise; +} + +// ============================================================================ +// SqlServerServerResource +// ============================================================================ + +export class SqlServerServerResource extends ResourceBuilderBase { + constructor(handle: SqlServerServerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** Gets the PrimaryEndpoint property */ + primaryEndpoint = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.primaryEndpoint', + { context: this._handle } + ); + return new EndpointReference(handle, this._client); + }, + }; + + /** Gets the Host property */ + host = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.host', + { context: this._handle } + ); + return new EndpointReferenceExpression(handle, this._client); + }, + }; + + /** Gets the Port property */ + port = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.port', + { context: this._handle } + ); + return new EndpointReferenceExpression(handle, this._client); + }, + }; + + /** Gets the PasswordParameter property */ + passwordParameter = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.passwordParameter', + { context: this._handle } + ); + return new ParameterResource(handle, this._client); + }, + set: async (value: IParameterResource): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.setPasswordParameter', + { context: this._handle, value } + ); + } + }; + + /** Gets the UserNameReference property */ + userNameReference = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.userNameReference', + { context: this._handle } + ); + }, + }; + + /** Gets the UriExpression property */ + uriExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.uriExpression', + { context: this._handle } + ); + }, + }; + + /** Gets the JdbcConnectionString property */ + jdbcConnectionString = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.jdbcConnectionString', + { context: this._handle } + ); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + + /** Gets the Databases property */ + private _databases?: AspireDict; + get databases(): AspireDict { + if (!this._databases) { + this._databases = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.databases', + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.databases' + ); + } + return this._databases; + } + + /** Gets the Entrypoint property */ + entrypoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.entrypoint', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.setEntrypoint', + { context: this._handle, value } + ); + } + }; + + /** Gets the ShellExecution property */ + shellExecution = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.shellExecution', + { context: this._handle } + ); + }, + set: async (value: boolean): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.setShellExecution', + { context: this._handle, value } + ); + } + }; + + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.name', + { context: this._handle } + ); + }, + }; + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source, target }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBindMount', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): SqlServerServerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): SqlServerServerResourcePromise { + const tag = options?.tag; + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): SqlServerServerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Sets the container name */ + withContainerName(name: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withContainerNameInternal(name)); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildArg', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerServerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new SqlServerServerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withContainerNetworkAliasInternal(alias: string): Promise { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): SqlServerServerResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new SqlServerServerResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerServerResourcePromise { + const helpLink = options?.helpLink; + return new SqlServerServerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IResource, 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 + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): SqlServerServerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new SqlServerServerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + } + + /** 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 _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): SqlServerServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new SqlServerServerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): SqlServerServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new SqlServerServerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): SqlServerServerResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new SqlServerServerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): SqlServerServerResourcePromise { + const displayText = options?.displayText; + return new SqlServerServerResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerServerResourcePromise { + const displayText = options?.displayText; + return new SqlServerServerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): SqlServerServerResourcePromise { + const exitCode = options?.exitCode; + return new SqlServerServerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): SqlServerServerResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new SqlServerServerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerServerResourcePromise { + const commandOptions = options?.commandOptions; + return new SqlServerServerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): SqlServerServerResourcePromise { + const password = options?.password; + return new SqlServerServerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): SqlServerServerResourcePromise { + const iconVariant = options?.iconVariant; + return new SqlServerServerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): SqlServerServerResourcePromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new SqlServerServerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerServerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new SqlServerServerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** @internal */ + private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { resource: this._handle, target }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withVolume', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): SqlServerServerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new SqlServerServerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _addDatabaseInternal(name: string, databaseName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (databaseName !== undefined) rpcArgs.databaseName = databaseName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/addDatabase', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a SQL Server database resource */ + addDatabase(name: string, options?: AddDatabaseOptions): SqlServerDatabaseResourcePromise { + const databaseName = options?.databaseName; + return new SqlServerDatabaseResourcePromise(this._addDatabaseInternal(name, databaseName)); + } + + /** @internal */ + private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/withDataVolume', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a named volume for the SQL Server data folder */ + withDataVolume(options?: WithDataVolumeOptions): SqlServerServerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new SqlServerServerResourcePromise(this._withDataVolumeInternal(name, isReadOnly)); + } + + /** @internal */ + private async _withDataBindMountInternal(source: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, source }; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/withDataBindMount', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a bind mount for the SQL Server data folder */ + withDataBindMount(source: string, options?: WithDataBindMountOptions): SqlServerServerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new SqlServerServerResourcePromise(this._withDataBindMountInternal(source, isReadOnly)); + } + + /** @internal */ + private async _withPasswordInternal(password: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, password }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/withPassword', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Configures the password for the SQL Server resource */ + withPassword(password: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withPasswordInternal(password)); + } + + /** @internal */ + private async _withHostPortInternal(port?: number): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/withHostPort', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets the host port for the SQL Server resource */ + withHostPort(options?: WithHostPortOptions): SqlServerServerResourcePromise { + const port = options?.port; + return new SqlServerServerResourcePromise(this._withHostPortInternal(port)); + } + +} + +/** + * Thenable wrapper for SqlServerServerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class SqlServerServerResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: SqlServerServerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a parameter resource */ + withBuildArg(name: string, value: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Publishes the resource as a connection string */ + publishAsConnectionString(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Adds arguments */ + withArgs(args: string[]): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(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: IBeforeResourceStartedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Adds a SQL Server database resource */ + addDatabase(name: string, options?: AddDatabaseOptions): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.addDatabase(name, options))); + } + + /** Adds a named volume for the SQL Server data folder */ + withDataVolume(options?: WithDataVolumeOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); + } + + /** Adds a bind mount for the SQL Server data folder */ + withDataBindMount(source: string, options?: WithDataBindMountOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDataBindMount(source, options))); + } + + /** Configures the password for the SQL Server resource */ + withPassword(password: IParameterResource): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPassword(password))); + } + + /** Sets the host port for the SQL Server resource */ + withHostPort(options?: WithHostPortOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHostPort(options))); + } + +} + +// ============================================================================ +// IComputeResource +// ============================================================================ + +export interface IComputeResource { + toJSON(): MarshalledHandle; + withRemoteImageName(remoteImageName: string): IComputeResourcePromise; + withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; +} + +export interface IComputeResourcePromise extends PromiseLike { + withRemoteImageName(remoteImageName: string): IComputeResourcePromise; + withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; +} + +// ============================================================================ +// ComputeResource +// ============================================================================ + +export class ComputeResource extends ResourceBuilderBase { + constructor(handle: IComputeResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withRemoteImageNameInternal(remoteImageName: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageName', + rpcArgs + ); + return new ComputeResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @internal */ + private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { + const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRemoteImageTag', + rpcArgs + ); + return new ComputeResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + +} + +/** + * Thenable wrapper for ComputeResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ComputeResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ComputeResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + +} + +// ============================================================================ +// IContainerFilesDestinationResource +// ============================================================================ + +export interface IContainerFilesDestinationResource { + toJSON(): MarshalledHandle; + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IContainerFilesDestinationResourcePromise; +} + +export interface IContainerFilesDestinationResourcePromise extends PromiseLike { + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IContainerFilesDestinationResourcePromise; +} + +// ============================================================================ +// ContainerFilesDestinationResource +// ============================================================================ + +export class ContainerFilesDestinationResource extends ResourceBuilderBase { + constructor(handle: IContainerFilesDestinationResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _publishWithContainerFilesInternal(source: IResourceWithContainerFiles, destinationPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, source, destinationPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishWithContainerFilesFromResource', + rpcArgs + ); + return new ContainerFilesDestinationResource(result, this._client); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + } + +} + +/** + * Thenable wrapper for ContainerFilesDestinationResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ContainerFilesDestinationResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ContainerFilesDestinationResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures the resource to copy container files from the specified source during publishing */ + publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + } + +} + +// ============================================================================ +// IResource +// ============================================================================ + +export interface IResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IResource): IResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; + excludeFromManifest(): IResourcePromise; + withExplicitStart(): IResourcePromise; + withHealthCheck(key: string): IResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; + withParentRelationship(parent: IResource): IResourcePromise; + withChildRelationship(child: IResource): IResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; + excludeFromMcp(): IResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; +} + +export interface IResourcePromise extends PromiseLike { + withContainerRegistry(registry: IResource): IResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; + excludeFromManifest(): IResourcePromise; + withExplicitStart(): IResourcePromise; + withHealthCheck(key: string): IResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; + withParentRelationship(parent: IResource): IResourcePromise; + withChildRelationship(child: IResource): IResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; + excludeFromMcp(): IResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; +} + +// ============================================================================ +// Resource +// ============================================================================ + +export class Resource extends ResourceBuilderBase { + constructor(handle: IResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ResourcePromise { + return new ResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @internal */ + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new ResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @internal */ + private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withRequiredCommand', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { + const helpLink = options?.helpLink; + return new ResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrl', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ResourcePromise { + const displayText = options?.displayText; + return new ResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlExpression', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { + const displayText = options?.displayText; + return new ResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { + return new ResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ResourcePromise { + return new ResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ResourcePromise { + return new ResourcePromise(this._withExplicitStartInternal()); + } + + /** @internal */ + private async _withHealthCheckInternal(key: string): Promise { + const rpcArgs: Record = { builder: this._handle, key }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHealthCheck', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ResourcePromise { + return new ResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @internal */ + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + const executeCommandId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; + const arg = new ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); + }); + const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; + if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + const commandOptions = options?.commandOptions; + return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ResourcePromise { + return new ResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ResourcePromise { + return new ResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @internal */ + private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withIconName', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { + const iconVariant = options?.iconVariant; + return new ResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ResourcePromise { + return new ResourcePromise(this._excludeFromMcpInternal()); + } + + /** @internal */ + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; + const arg = new PipelineStepContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; + if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; + if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; + if (tags !== undefined) rpcArgs.tags = tags; + if (description !== undefined) rpcArgs.description = description; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new ResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); + } + + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + +} + +/** + * Thenable wrapper for Resource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Resource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IResource): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: IResource): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: IResource): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// IResourceWithArgs +// ============================================================================ + +export interface IResourceWithArgs { + toJSON(): MarshalledHandle; + withArgs(args: string[]): IResourceWithArgsPromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; +} + +export interface IResourceWithArgsPromise extends PromiseLike { + withArgs(args: string[]): IResourceWithArgsPromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; +} + +// ============================================================================ +// ResourceWithArgs +// ============================================================================ + +export class ResourceWithArgs extends ResourceBuilderBase { + constructor(handle: IResourceWithArgsHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withArgsInternal(args: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, args }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgs', + rpcArgs + ); + return new ResourceWithArgs(result, this._client); + } + + /** Adds arguments */ + withArgs(args: string[]): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._withArgsInternal(args)); + } + + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallback', + rpcArgs + ); + return new ResourceWithArgs(result, this._client); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._withArgsCallbackInternal(callback)); + } + + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ResourceWithArgs(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._withArgsCallbackAsyncInternal(callback)); + } + +} + +/** + * Thenable wrapper for ResourceWithArgs that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourceWithArgsPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceWithArgs) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Adds arguments */ + withArgs(args: string[]): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgs(args))); + } + + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallback(callback))); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + +} + +// ============================================================================ +// IResourceWithConnectionString +// ============================================================================ + +export interface IResourceWithConnectionString { + toJSON(): MarshalledHandle; + withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; + getConnectionProperty(key: string): Promise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; +} + +export interface IResourceWithConnectionStringPromise extends PromiseLike { + withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; + getConnectionProperty(key: string): Promise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; +} + +// ============================================================================ +// ResourceWithConnectionString +// ============================================================================ + +export class ResourceWithConnectionString extends ResourceBuilderBase { + constructor(handle: IResourceWithConnectionStringHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionProperty', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** 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 _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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: IConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + +} + +/** + * Thenable wrapper for ResourceWithConnectionString that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourceWithConnectionStringPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceWithConnectionString) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** 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: IConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + +} + +// ============================================================================ +// IResourceWithContainerFiles +// ============================================================================ + +export interface IResourceWithContainerFiles { + toJSON(): MarshalledHandle; + withContainerFilesSource(sourcePath: string): IResourceWithContainerFilesPromise; + clearContainerFilesSources(): IResourceWithContainerFilesPromise; +} + +export interface IResourceWithContainerFilesPromise extends PromiseLike { + withContainerFilesSource(sourcePath: string): IResourceWithContainerFilesPromise; + clearContainerFilesSources(): IResourceWithContainerFilesPromise; +} + +// ============================================================================ +// ResourceWithContainerFiles +// ============================================================================ + +export class ResourceWithContainerFiles extends ResourceBuilderBase { + constructor(handle: IResourceWithContainerFilesHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerFilesSourceInternal(sourcePath: string): Promise { + const rpcArgs: Record = { builder: this._handle, sourcePath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerFilesSource', + rpcArgs + ); + return new ResourceWithContainerFiles(result, this._client); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._withContainerFilesSourceInternal(sourcePath)); + } + + /** @internal */ + private async _clearContainerFilesSourcesInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/clearContainerFilesSources', + rpcArgs + ); + return new ResourceWithContainerFiles(result, this._client); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._clearContainerFilesSourcesInternal()); + } + +} + +/** + * Thenable wrapper for ResourceWithContainerFiles that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourceWithContainerFilesPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceWithContainerFiles) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Sets the source directory for container files */ + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._promise.then(obj => obj.withContainerFilesSource(sourcePath))); + } + + /** Clears all container file sources */ + clearContainerFilesSources(): ResourceWithContainerFilesPromise { + return new ResourceWithContainerFilesPromise(this._promise.then(obj => obj.clearContainerFilesSources())); + } + +} + +// ============================================================================ +// IResourceWithEndpoints +// ============================================================================ + +export interface IResourceWithEndpoints { + toJSON(): MarshalledHandle; + withMcpServer(options?: WithMcpServerOptions): IResourceWithEndpointsPromise; + withEndpoint(options?: WithEndpointOptions): IResourceWithEndpointsPromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IResourceWithEndpointsPromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IResourceWithEndpointsPromise; + withExternalHttpEndpoints(): IResourceWithEndpointsPromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IResourceWithEndpointsPromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; +} + +export interface IResourceWithEndpointsPromise extends PromiseLike { + withMcpServer(options?: WithMcpServerOptions): IResourceWithEndpointsPromise; + withEndpoint(options?: WithEndpointOptions): IResourceWithEndpointsPromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IResourceWithEndpointsPromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IResourceWithEndpointsPromise; + withExternalHttpEndpoints(): IResourceWithEndpointsPromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IResourceWithEndpointsPromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; +} + +// ============================================================================ +// ResourceWithEndpoints +// ============================================================================ + +export class ResourceWithEndpoints extends ResourceBuilderBase { + constructor(handle: IResourceWithEndpointsHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withMcpServer', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (scheme !== undefined) rpcArgs.scheme = scheme; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + if (isExternal !== undefined) rpcArgs.isExternal = isExternal; + if (protocol !== undefined) rpcArgs.protocol = protocol; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEndpoint', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { + const port = options?.port; + const targetPort = options?.targetPort; + const scheme = options?.scheme; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + const isExternal = options?.isExternal; + const protocol = options?.protocol; + return new ResourceWithEndpointsPromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + } + + /** @internal */ + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpEndpoint', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ResourceWithEndpointsPromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (port !== undefined) rpcArgs.port = port; + if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (name !== undefined) rpcArgs.name = name; + if (env !== undefined) rpcArgs.env = env; + if (isProxied !== undefined) rpcArgs.isProxied = isProxied; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpsEndpoint', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new ResourceWithEndpointsPromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + } + + /** @internal */ + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); + } + + /** @internal */ + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (statusCode !== undefined) rpcArgs.statusCode = statusCode; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpHealthCheck', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + } + + /** @internal */ + private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, probeType }; + if (path !== undefined) rpcArgs.path = path; + if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; + if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; + if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; + if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; + if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; + if (endpointName !== undefined) rpcArgs.endpointName = endpointName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withHttpProbe', + rpcArgs + ); + return new ResourceWithEndpoints(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { + const path = options?.path; + const initialDelaySeconds = options?.initialDelaySeconds; + const periodSeconds = options?.periodSeconds; + const timeoutSeconds = options?.timeoutSeconds; + const failureThreshold = options?.failureThreshold; + const successThreshold = options?.successThreshold; + const endpointName = options?.endpointName; + return new ResourceWithEndpointsPromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + +} + +/** + * Thenable wrapper for ResourceWithEndpoints that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourceWithEndpointsPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceWithEndpoints) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withMcpServer(options))); + } + + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withEndpoint(options))); + } + + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + } + + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + } + + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + } + + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + +} + +// ============================================================================ +// IResourceWithEnvironment +// ============================================================================ + +export interface IResourceWithEnvironment { + toJSON(): MarshalledHandle; + withOtlpExporter(): IResourceWithEnvironmentPromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IResourceWithEnvironmentPromise; + withReference(source: IResource, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; + withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; + withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; + withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; + withoutHttpsCertificate(): IResourceWithEnvironmentPromise; +} + +export interface IResourceWithEnvironmentPromise extends PromiseLike { + withOtlpExporter(): IResourceWithEnvironmentPromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IResourceWithEnvironmentPromise; + withReference(source: IResource, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; + withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; + withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; + withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; + withoutHttpsCertificate(): IResourceWithEnvironmentPromise; +} + +// ============================================================================ +// ResourceWithEnvironment +// ============================================================================ + +export class ResourceWithEnvironment extends ResourceBuilderBase { + constructor(handle: IResourceWithEnvironmentHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withOtlpExporterInternal()); + } + + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withOtlpExporterProtocolInternal(protocol)); + } + + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + } + + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + 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 on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentParameterInternal(name, parameter)); + } + + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + } + + /** @internal */ + private async _withReferenceInternal(source: IResource, 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 + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); + } + + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceUriInternal(name, uri)); + } + + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceExternalServiceInternal(externalService)); + } + + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEndpointInternal(endpointReference)); + } + + /** @internal */ + private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, trust }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDeveloperCertificateTrust', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @internal */ + private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { + const rpcArgs: Record = { builder: this._handle, scope }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withCertificateTrustScope', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withCertificateTrustScopeInternal(scope)); + } + + /** @internal */ + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { + const password = options?.password; + return new ResourceWithEnvironmentPromise(this._withHttpsDeveloperCertificateInternal(password)); + } + + /** @internal */ + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withoutHttpsCertificateInternal()); + } + +} + +/** + * Thenable wrapper for ResourceWithEnvironment that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourceWithEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceWithEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures OTLP telemetry export */ + withOtlpExporter(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withOtlpExporter())); + } + + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: IParameterResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + } + + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + } + + /** Adds a reference to another resource */ + withReference(source: IResource, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); + } + + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + } + + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: IExternalServiceResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + } + + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + } + + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + } + + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + } + + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + } + +} + +// ============================================================================ +// IResourceWithWaitSupport +// ============================================================================ + +export interface IResourceWithWaitSupport { + toJSON(): MarshalledHandle; + waitFor(dependency: IResource): IResourceWithWaitSupportPromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; + waitForStart(dependency: IResource): IResourceWithWaitSupportPromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IResourceWithWaitSupportPromise; +} + +export interface IResourceWithWaitSupportPromise extends PromiseLike { + waitFor(dependency: IResource): IResourceWithWaitSupportPromise; + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; + waitForStart(dependency: IResource): IResourceWithWaitSupportPromise; + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IResourceWithWaitSupportPromise; +} + +// ============================================================================ +// ResourceWithWaitSupport +// ============================================================================ + +export class ResourceWithWaitSupport extends ResourceBuilderBase { + constructor(handle: IResourceWithWaitSupportHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _waitForInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._waitForInternal(dependency)); + } + + /** @internal */ + private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForStartInternal(dependency: IResource): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._waitForStartInternal(dependency)); + } + + /** @internal */ + private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + } + + /** @internal */ + private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + if (exitCode !== undefined) rpcArgs.exitCode = exitCode; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceCompletion', + rpcArgs + ); + return new ResourceWithWaitSupport(result, this._client); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + const exitCode = options?.exitCode; + return new ResourceWithWaitSupportPromise(this._waitForCompletionInternal(dependency, exitCode)); + } + +} + +/** + * Thenable wrapper for ResourceWithWaitSupport that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ResourceWithWaitSupportPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceWithWaitSupport) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for another resource to be ready */ + waitFor(dependency: IResource): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitFor(dependency))); + } + + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + } + + /** Waits for another resource to start */ + waitForStart(dependency: IResource): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStart(dependency))); + } + + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + } + + /** Waits for resource completion */ + waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + } + +} + +// ============================================================================ +// Connection Helper +// ============================================================================ + +/** + * Creates and connects to the Aspire AppHost. + * Reads connection info from environment variables set by `aspire run`. + */ +export async function connect(): Promise { + const socketPath = process.env.REMOTE_APP_HOST_SOCKET_PATH; + if (!socketPath) { + throw new Error( + 'REMOTE_APP_HOST_SOCKET_PATH environment variable not set. ' + + 'Run this application using `aspire run`.' + ); + } + + const client = new AspireClientRpc(socketPath); + await client.connect(); + + // Exit the process if the server connection is lost + client.onDisconnect(() => { + console.error('Connection to AppHost lost. Exiting...'); + process.exit(1); + }); + + return client; +} + +/** + * Creates a new distributed application builder. + * This is the entry point for building Aspire applications. + * + * @param options - Optional configuration options for the builder + * @returns A DistributedApplicationBuilder instance + * + * @example + * const builder = await createBuilder(); + * builder.addRedis("cache"); + * builder.addContainer("api", "mcr.microsoft.com/dotnet/samples:aspnetapp"); + * const app = await builder.build(); + * await app.run(); + */ +export async function createBuilder(options?: CreateBuilderOptions): Promise { + const client = await connect(); + + // Default args, projectDirectory, and appHostFilePath if not provided + // ASPIRE_APPHOST_FILEPATH is set by the CLI for consistent socket hash computation + const effectiveOptions: CreateBuilderOptions = { + ...options, + args: options?.args ?? process.argv.slice(2), + projectDirectory: options?.projectDirectory ?? process.env.ASPIRE_PROJECT_DIRECTORY ?? process.cwd(), + appHostFilePath: options?.appHostFilePath ?? process.env.ASPIRE_APPHOST_FILEPATH + }; + + const handle = await client.invokeCapability( + 'Aspire.Hosting/createBuilderWithOptions', + { options: effectiveOptions } + ); + return new DistributedApplicationBuilder(handle, client); +} + +// Re-export commonly used types +export { Handle, AppHostUsageError, CancellationToken, CapabilityError, registerCallback } from './transport.js'; +export { refExpr, ReferenceExpression } from './base.js'; +export type { ICancellationToken, IReferenceExpression } from './base.js'; + +// ============================================================================ +// Global Error Handling +// ============================================================================ + +/** + * Set up global error handlers to ensure the process exits properly on errors. + * Node.js doesn't exit on unhandled rejections by default, so we need to handle them. + */ +process.on('unhandledRejection', (reason: unknown) => { + const error = reason instanceof Error ? reason : new Error(String(reason)); + + if (reason instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else if (reason instanceof CapabilityError) { + console.error(`\n❌ Capability Error: ${error.message}`); + console.error(` Code: ${(reason as CapabilityError).code}`); + if ((reason as CapabilityError).capability) { + console.error(` Capability: ${(reason as CapabilityError).capability}`); + } + } else { + console.error(`\n❌ Unhandled Error: ${error.message}`); + if (error.stack) { + console.error(error.stack); + } + } + + process.exit(1); +}); + +process.on('uncaughtException', (error: Error) => { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + if (!(error instanceof AppHostUsageError) && error.stack) { + console.error(error.stack); + } + process.exit(1); +}); + +// ============================================================================ +// Handle Wrapper Registrations +// ============================================================================ + +// 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/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/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/Aspire.Hosting.ConnectionStringResource', (handle, client) => new ConnectionStringResource(handle as ConnectionStringResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource', (handle, client) => new ContainerRegistryResource(handle as ContainerRegistryResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource', (handle, client) => new ContainerResource(handle as ContainerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource', (handle, client) => new CSharpAppResource(handle as CSharpAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource', (handle, client) => new DotnetToolResource(handle as DotnetToolResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource', (handle, client) => new ExecutableResource(handle as ExecutableResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ExternalServiceResource', (handle, client) => new ExternalServiceResource(handle as ExternalServiceResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource', (handle, client) => new ParameterResource(handle as ParameterResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource', (handle, client) => new ProjectResource(handle as ProjectResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerDatabaseResource', (handle, client) => new SqlServerDatabaseResource(handle as SqlServerDatabaseResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerServerResource', (handle, client) => new SqlServerServerResource(handle as SqlServerServerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource', (handle, client) => new ComputeResource(handle as IComputeResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource', (handle, client) => new ContainerFilesDestinationResource(handle as IContainerFilesDestinationResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new Resource(handle as IResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs', (handle, client) => new ResourceWithArgs(handle as IResourceWithArgsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionString(handle as IResourceWithConnectionStringHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); + diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts new file mode 100644 index 00000000000..bbfc7cb1a51 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts @@ -0,0 +1,586 @@ +// base.ts - Core Aspire types: base classes, ReferenceExpression +import type { ICancellationToken } from './transport.js'; +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; + +// Re-export transport types for convenience +export { Handle, AspireClient, CapabilityError, CancellationToken, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +export type { ICancellationToken, MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; +export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './transport.js'; + +// ============================================================================ +// Reference Expression +// ============================================================================ + +/** + * Represents a reference expression that can be passed to capabilities. + * + * Reference expressions are serialized in the protocol as: + * ```json + * { + * "$expr": { + * "format": "redis://{0}:{1}", + * "valueProviders": [ + * { "$handle": "Aspire.Hosting.ApplicationModel/EndpointReference:1" }, + * { "$handle": "Aspire.Hosting.ApplicationModel/EndpointReference:2" } + * ] + * } + * } + * ``` + * + * @example + * ```typescript + * const redis = await builder.addRedis("cache"); + * const endpoint = await redis.getEndpoint("tcp"); + * + * // Create a reference expression + * const expr = refExpr`redis://${endpoint}:6379`; + * + * // Use it in an environment variable + * await api.withEnvironment("REDIS_URL", expr); + * ``` + */ +export interface IReferenceExpression { + readonly isConditional: boolean; + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle; + getValue(cancellationToken?: AbortSignal | ICancellationToken): Promise; + toString(): string; +} + +export class ReferenceExpression implements IReferenceExpression { + // Expression mode fields + private readonly _format?: string; + private readonly _valueProviders?: unknown[]; + + // Conditional mode fields + private readonly _condition?: unknown; + private readonly _whenTrue?: IReferenceExpression; + private readonly _whenFalse?: IReferenceExpression; + private readonly _matchValue?: string; + + // Handle mode fields (when wrapping a server-returned handle) + private readonly _handle?: Handle; + private readonly _client?: AspireClient; + + constructor(format: string, valueProviders: unknown[]); + constructor(handle: Handle, client: AspireClient); + constructor(condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, + whenTrueOrWhenFalse?: IReferenceExpression, + whenFalse?: IReferenceExpression + ) { + if (typeof handleOrFormatOrCondition === 'string') { + this._format = handleOrFormatOrCondition; + this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (handleOrFormatOrCondition instanceof Handle) { + this._handle = handleOrFormatOrCondition; + this._client = clientOrValueProvidersOrMatchValue as AspireClient; + } else { + this._condition = handleOrFormatOrCondition; + this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + this._whenTrue = whenTrueOrWhenFalse; + this._whenFalse = whenFalse; + } + } + + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return this._condition !== undefined; + } + + /** + * Creates a reference expression from a tagged template literal. + * + * @param strings - The template literal string parts + * @param values - The interpolated values (handles to value providers) + * @returns A ReferenceExpression instance + */ + static create(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { + // Build the format string with {0}, {1}, etc. placeholders + let format = ''; + for (let i = 0; i < strings.length; i++) { + format += strings[i]; + if (i < values.length) { + format += `{${i}}`; + } + } + + // Extract handles from values + const valueProviders = values.map(extractHandleForExpr); + + return new ReferenceExpression(format, valueProviders); + } + + /** + * Creates a conditional reference expression from its constituent parts. + * + * @param condition - A value provider whose result is compared to matchValue + * @param whenTrue - The expression to use when the condition matches + * @param whenFalse - The expression to use when the condition does not match + * @param matchValue - The value to compare the condition against (defaults to "True") + * @returns A ReferenceExpression instance in conditional mode + */ + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: IReferenceExpression, + whenFalse: IReferenceExpression + ): IReferenceExpression { + return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + } + + /** + * Serializes the reference expression for JSON-RPC transport. + * In expression mode, uses the $expr format with format + valueProviders. + * In conditional mode, uses the $expr format with condition + whenTrue + whenFalse. + * In handle mode, delegates to the handle's serialization. + */ + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { + if (this._handle) { + return this._handle.toJSON(); + } + + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(this._condition), + whenTrue: this._whenTrue!.toJSON(), + whenFalse: this._whenFalse!.toJSON(), + matchValue: this._matchValue! + } + }; + } + + return { + $expr: { + format: this._format!, + valueProviders: this._valueProviders && this._valueProviders.length > 0 ? this._valueProviders : undefined + } + }; + } + + /** + * 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 | ICancellationToken): 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. + */ + toString(): string { + if (this._handle) { + return `ReferenceExpression(handle)`; + } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } + return `ReferenceExpression(${this._format})`; + } +} + +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. + * @internal + */ +function extractHandleForExpr(value: unknown): unknown { + if (value === null || value === undefined) { + throw new Error('Cannot use null or undefined in reference expression'); + } + + // String literals - include directly in the expression + if (typeof value === 'string') { + return value; + } + + // Number literals - convert to string + if (typeof value === 'number') { + return String(value); + } + + // Handle objects - get their JSON representation + if (value instanceof Handle) { + return value.toJSON(); + } + + // 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 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 || '$expr' in json)) { + return json; + } + } + + throw new Error( + `Cannot use value of type ${typeof value} in reference expression. ` + + `Expected a Handle, string, or number.` + ); +} + +/** + * Tagged template function for creating reference expressions. + * + * Use this to create dynamic expressions that reference endpoints, parameters, and other + * value providers. The expression is evaluated at runtime by Aspire. + * + * @example + * ```typescript + * const redis = await builder.addRedis("cache"); + * const endpoint = await redis.getEndpoint("tcp"); + * + * // Create a reference expression using the tagged template + * const expr = refExpr`redis://${endpoint}:6379`; + * + * // Use it in an environment variable + * await api.withEnvironment("REDIS_URL", expr); + * ``` + */ +export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { + return ReferenceExpression.create(strings, ...values); +} + +// ============================================================================ +// ResourceBuilderBase +// ============================================================================ + +/** + * Base class for resource builders (e.g., RedisBuilder, ContainerBuilder). + * Provides handle management and JSON serialization. + */ +export class ResourceBuilderBase { + constructor(protected _handle: THandle, protected _client: AspireClient) {} + + toJSON(): MarshalledHandle { return this._handle.toJSON(); } +} + +// ============================================================================ +// AspireList - Mutable List Wrapper +// ============================================================================ + +/** + * Wrapper for a mutable .NET List. + * Provides array-like methods that invoke capabilities on the underlying collection. + * + * @example + * ```typescript + * const items = await resource.getItems(); // Returns AspireList + * const count = await items.count(); + * const first = await items.get(0); + * await items.add(newItem); + * ``` + */ +export class AspireList { + private _resolvedHandle?: Handle; + private _resolvePromise?: Promise; + + constructor( + private readonly _handleOrContext: Handle, + private readonly _client: AspireClient, + private readonly _typeId: string, + private readonly _getterCapabilityId?: string + ) { + // If no getter capability, the handle is already the list handle + if (!_getterCapabilityId) { + this._resolvedHandle = _handleOrContext; + } + } + + /** + * Ensures we have the actual list handle by calling the getter if needed. + */ + private async _ensureHandle(): Promise { + if (this._resolvedHandle) { + return this._resolvedHandle; + } + if (this._resolvePromise) { + return this._resolvePromise; + } + // Call the getter capability to get the actual list handle + this._resolvePromise = (async () => { + const result = await this._client.invokeCapability(this._getterCapabilityId!, { + context: this._handleOrContext + }); + this._resolvedHandle = result as Handle; + return this._resolvedHandle; + })(); + return this._resolvePromise; + } + + /** + * Gets the number of elements in the list. + */ + async count(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/List.length', { + list: handle + }) as number; + } + + /** + * Gets the element at the specified index. + */ + async get(index: number): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/List.get', { + list: handle, + index + }) as T; + } + + /** + * Adds an element to the end of the list. + */ + async add(item: T): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/List.add', { + list: handle, + item + }); + } + + /** + * Removes the element at the specified index. + */ + async removeAt(index: number): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/List.removeAt', { + list: handle, + index + }); + } + + /** + * Clears all elements from the list. + */ + async clear(): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/List.clear', { + list: handle + }); + } + + /** + * Converts the list to an array (creates a copy). + */ + async toArray(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/List.toArray', { + list: handle + }) as T[]; + } + + 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._resolvedHandle.toJSON(); + } +} + +// ============================================================================ +// AspireDict - Mutable Dictionary Wrapper +// ============================================================================ + +/** + * Wrapper for a mutable .NET Dictionary. + * Provides object-like methods that invoke capabilities on the underlying collection. + * + * @example + * ```typescript + * const config = await resource.getConfig(); // Returns AspireDict + * const value = await config.get("key"); + * await config.set("key", "value"); + * const hasKey = await config.containsKey("key"); + * ``` + */ +export class AspireDict { + private _resolvedHandle?: Handle; + private _resolvePromise?: Promise; + + constructor( + private readonly _handleOrContext: Handle, + private readonly _client: AspireClient, + private readonly _typeId: string, + private readonly _getterCapabilityId?: string + ) { + // If no getter capability, the handle is already the dictionary handle + if (!_getterCapabilityId) { + this._resolvedHandle = _handleOrContext; + } + } + + /** + * Ensures we have the actual dictionary handle by calling the getter if needed. + */ + private async _ensureHandle(): Promise { + if (this._resolvedHandle) { + return this._resolvedHandle; + } + if (this._resolvePromise) { + return this._resolvePromise; + } + // Call the getter capability to get the actual dictionary handle + this._resolvePromise = (async () => { + const result = await this._client.invokeCapability(this._getterCapabilityId!, { + context: this._handleOrContext + }); + this._resolvedHandle = result as Handle; + return this._resolvedHandle; + })(); + return this._resolvePromise; + } + + /** + * Gets the number of key-value pairs in the dictionary. + */ + async count(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.count', { + dict: handle + }) as number; + } + + /** + * Gets the value associated with the specified key. + * @throws If the key is not found. + */ + async get(key: K): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.get', { + dict: handle, + key + }) as V; + } + + /** + * Sets the value for the specified key. + */ + async set(key: K, value: V): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/Dict.set', { + dict: handle, + key, + value + }); + } + + /** + * Determines whether the dictionary contains the specified key. + */ + async containsKey(key: K): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.has', { + dict: handle, + key + }) as boolean; + } + + /** + * Removes the value with the specified key. + * @returns True if the element was removed; false if the key was not found. + */ + async remove(key: K): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.remove', { + dict: handle, + key + }) as boolean; + } + + /** + * Clears all key-value pairs from the dictionary. + */ + async clear(): Promise { + const handle = await this._ensureHandle(); + await this._client.invokeCapability('Aspire.Hosting/Dict.clear', { + dict: handle + }); + } + + /** + * Gets all keys in the dictionary. + */ + async keys(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.keys', { + dict: handle + }) as K[]; + } + + /** + * Gets all values in the dictionary. + */ + async values(): Promise { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.values', { + dict: handle + }) as V[]; + } + + /** + * Converts the dictionary to a plain object (creates a copy). + * Only works when K is string. + */ + async toObject(): Promise> { + const handle = await this._ensureHandle(); + return await this._client.invokeCapability('Aspire.Hosting/Dict.toObject', { + dict: handle + }) as Record; + } + + 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/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts new file mode 100644 index 00000000000..3098979921f --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts @@ -0,0 +1,1019 @@ +// transport.ts - ATS transport layer: RPC, Handle, errors, callbacks +import * as net from 'net'; +import * as rpc from 'vscode-jsonrpc/node.js'; + +// ============================================================================ +// Base Types +// ============================================================================ + +/** + * Type for callback functions that can be registered and invoked from .NET. + * Internal: receives args and client for handle wrapping. + */ +export type CallbackFunction = (args: unknown, client: AspireClient) => unknown | Promise; + +/** + * Represents a handle to a .NET object in the ATS system. + * Handles are typed references that can be passed between capabilities. + */ +export interface MarshalledHandle { + /** The handle ID (instance number) */ + $handle: string; + /** The ATS type ID */ + $type: string; +} + +/** + * Error details for ATS errors. + */ +export interface AtsErrorDetails { + /** The parameter that caused the error */ + parameter?: string; + /** The expected type or value */ + expected?: string; + /** The actual type or value */ + actual?: string; +} + +/** + * Structured error from ATS capability invocation. + */ +export interface AtsError { + /** Machine-readable error code */ + code: string; + /** Human-readable error message */ + message: string; + /** The capability that failed (if applicable) */ + capability?: string; + /** Additional error details */ + details?: AtsErrorDetails; +} + +/** + * ATS error codes returned by the server. + */ +export const AtsErrorCodes = { + /** Unknown capability ID */ + CapabilityNotFound: 'CAPABILITY_NOT_FOUND', + /** Handle ID doesn't exist or was disposed */ + HandleNotFound: 'HANDLE_NOT_FOUND', + /** Handle type doesn't satisfy capability's type constraint */ + TypeMismatch: 'TYPE_MISMATCH', + /** Missing required argument or wrong type */ + InvalidArgument: 'INVALID_ARGUMENT', + /** Argument value outside valid range */ + ArgumentOutOfRange: 'ARGUMENT_OUT_OF_RANGE', + /** Error occurred during callback invocation */ + CallbackError: 'CALLBACK_ERROR', + /** Unexpected error in capability execution */ + InternalError: 'INTERNAL_ERROR', +} as const; + +/** + * Type guard to check if a value is an ATS error response. + */ +export function isAtsError(value: unknown): value is { $error: AtsError } { + return ( + value !== null && + typeof value === 'object' && + '$error' in value && + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null + ); +} + +/** + * Type guard to check if a value is a marshalled handle. + */ +export function isMarshalledHandle(value: unknown): value is MarshalledHandle { + return ( + value !== null && + typeof value === 'object' && + '$handle' in value && + '$type' in value + ); +} + +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +function isCancellationTokenLike(value: unknown): value is ICancellationToken { + return ( + value !== null && + typeof value === 'object' && + 'register' in value && + typeof (value as { register?: unknown }).register === 'function' && + 'toJSON' in value && + typeof (value as { toJSON?: unknown }).toJSON === 'function' + ); +} + +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 +// ============================================================================ + +/** + * A typed handle to a .NET object in the ATS system. + * Handles are opaque references that can be passed to capabilities. + * + * @typeParam T - The ATS type ID (e.g., "Aspire.Hosting/IDistributedApplicationBuilder") + */ +export class Handle { + private readonly _handleId: string; + private readonly _typeId: T; + + constructor(marshalled: MarshalledHandle) { + this._handleId = marshalled.$handle; + this._typeId = marshalled.$type as T; + } + + /** The handle ID (instance number) */ + get $handle(): string { + return this._handleId; + } + + /** The ATS type ID */ + get $type(): T { + return this._typeId; + } + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { + return { + $handle: this._handleId, + $type: this._typeId + }; + } + + /** String representation for debugging */ + toString(): string { + return `Handle<${this._typeId}>(${this._handleId})`; + } +} + +// ============================================================================ +// 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 interface ICancellationToken { + toJSON(): string | undefined; + register(client?: AspireClient): string | undefined; +} + +export class CancellationToken implements ICancellationToken { + 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): ICancellationToken { + if (isCancellationTokenLike(value)) { + 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 +// ============================================================================ + +/** + * Factory function for creating typed wrapper instances from handles. + */ +export type HandleWrapperFactory = (handle: Handle, client: AspireClient) => unknown; + +/** + * Registry of handle wrapper factories by type ID. + * Generated code registers wrapper classes here so callback handles can be properly typed. + */ +const handleWrapperRegistry = new Map(); + +/** + * Register a wrapper factory for a type ID. + * Called by generated code to register wrapper classes. + */ +export function registerHandleWrapper(typeId: string, factory: HandleWrapperFactory): void { + handleWrapperRegistry.set(typeId, factory); +} + +/** + * Checks if a value is a marshalled handle and wraps it appropriately. + * Uses the wrapper registry to create typed wrapper instances when available. + * + * @param value - The value to potentially wrap + * @param client - Optional client for creating typed wrapper instances + */ +export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { + 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; + } + + 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; +} + +// ============================================================================ +// Capability Error +// ============================================================================ + +/** + * Error thrown when an ATS capability invocation fails. + */ +export class CapabilityError extends Error { + constructor( + /** The structured error from the server */ + public readonly error: AtsError + ) { + super(error.message); + this.name = 'CapabilityError'; + } + + /** Machine-readable error code */ + get code(): string { + return this.error.code; + } + + /** The capability that failed (if applicable) */ + get capability(): string | undefined { + return this.error.capability; + } +} + +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + } +} + +function isPromiseLike(value: unknown): value is PromiseLike { + return ( + value !== null && + (typeof value === 'object' || typeof value === 'function') && + 'then' in value && + typeof (value as { then?: unknown }).then === 'function' + ); +} + +function validateCapabilityArgs( + capabilityId: string, + args?: Record +): void { + if (!args) { + return; + } + + const validateValue = (value: unknown, path: string, ancestors: Set): void => { + if (value === null || value === undefined) { + return; + } + + if (isPromiseLike(value)) { + throw new AppHostUsageError( + `Argument '${path}' passed to capability '${capabilityId}' is a Promise-like value. ` + + `This usually means an async builder call was not awaited. ` + + `Did you forget 'await' on a call like builder.addPostgres(...) or resource.addDatabase(...)?` + ); + } + + if (typeof value !== 'object') { + return; + } + + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); + } + + ancestors.add(value); + try { + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + validateValue(value[i], `${path}[${i}]`, ancestors); + } + return; + } + + 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, new Set()); + } +} + +// ============================================================================ +// Callback Registry +// ============================================================================ + +const callbackRegistry = new Map(); +let callbackIdCounter = 0; + +/** + * Register a callback function that can be invoked from the .NET side. + * Returns a callback ID that should be passed to methods accepting callbacks. + * + * .NET passes arguments as an object with positional keys: `{ p0: value0, p1: value1, ... }` + * This function automatically extracts positional parameters and wraps handles. + * + * @example + * // Single parameter callback + * const id = registerCallback((ctx) => console.log(ctx)); + * // .NET sends: { p0: { $handle: "...", $type: "..." } } + * // Callback receives: Handle instance + * + * @example + * // Multi-parameter callback + * const id = registerCallback((a, b) => console.log(a, b)); + * // .NET sends: { p0: "hello", p1: 42 } + * // Callback receives: "hello", 42 + */ +export function registerCallback( + callback: (...args: any[]) => TResult | Promise +): string { + const callbackId = `callback_${++callbackIdCounter}_${Date.now()}`; + + // Wrap the callback to handle .NET's positional argument format + const wrapper: CallbackFunction = async (args: unknown, client: AspireClient) => { + // .NET sends args as object { p0: value0, p1: value1, ... } + if (args && typeof args === 'object' && !Array.isArray(args)) { + const argObj = args as Record; + const argArray: unknown[] = []; + + // Extract positional parameters (p0, p1, p2, ...) + for (let i = 0; ; i++) { + const key = `p${i}`; + if (key in argObj) { + argArray.push(wrapIfHandle(argObj[key], client)); + } else { + break; + } + } + + if (argArray.length > 0) { + // Spread positional arguments to callback + const result = await callback(...argArray); + // DTO writeback protocol: when a void callback returns undefined, we + // return the original args object so the .NET host can detect property + // mutations made by the callback and apply them back to the original + // C# DTO objects. DTO args are plain JS objects (not Handle wrappers), + // so any property changes the callback made are reflected in args. + // + // Non-void callbacks (result !== undefined) return their actual result. + // The .NET side only activates writeback for void delegates whose + // parameters include [AspireDto] types — all other cases discard the + // returned args object, so the extra wire payload is harmless. + // + // IMPORTANT: callbacks that intentionally return undefined will also + // trigger this path. For non-void delegate types, the C# proxy uses + // a result-unmarshalling path (not writeback), so returning args will + // cause an unmarshal error. Void callbacks should never return a + // meaningful value; non-void callbacks should always return one. + return result !== undefined ? result : args; + } + + // No positional params found — nothing to write back + return await callback(); + } + + // Null/undefined - call with no args + if (args === null || args === undefined) { + return await callback(); + } + + // Primitive value - pass as single arg (shouldn't happen with current protocol) + return await callback(wrapIfHandle(args, client)); + }; + + callbackRegistry.set(callbackId, wrapper); + return callbackId; +} + +/** + * Unregister a callback by its ID. + */ +export function unregisterCallback(callbackId: string): boolean { + return callbackRegistry.delete(callbackId); +} + +/** + * Get the number of registered callbacks. + */ +export function getCallbackCount(): number { + return callbackRegistry.size; +} + +// ============================================================================ +// Cancellation Token Registry +// ============================================================================ + +/** + * Registry for cancellation tokens. + * Maps cancellation IDs to cleanup functions. + */ +const cancellationRegistry = new Map void>(); +let cancellationIdCounter = 0; +const connectedClients = new Set(); + +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.' + ); +} + +/** + * 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 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 | ICancellationToken): 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(); + * const id = registerCancellation(controller.signal); + * // Pass id to capability invocation + * // Later: controller.abort() will cancel the operation + */ +export function registerCancellation(signalOrToken?: AbortSignal | ICancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, + maybeSignalOrToken?: AbortSignal | ICancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; + + if (!signalOrToken) { + return undefined; + } + + if (isCancellationTokenLike(signalOrToken)) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + + if (signal.aborted) { + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); + } + + const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; + + // Set up the abort listener + const onAbort = () => { + // Send cancel request to host + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { + // Ignore errors - the operation may have already completed + }); + } + // Clean up the listener + cancellationRegistry.delete(cancellationId); + }; + + // Listen for abort + signal.addEventListener('abort', onAbort, { once: true }); + + // Store cleanup function + cancellationRegistry.set(cancellationId, () => { + signal.removeEventListener('abort', onAbort); + }); + + 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 (isCancellationTokenLike(value)) { + 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. + * + * @param cancellationId - The cancellation ID to unregister + */ +export function unregisterCancellation(cancellationId: string | undefined): void { + if (!cancellationId) { + return; + } + + const cleanup = cancellationRegistry.get(cancellationId); + if (cleanup) { + cleanup(); + cancellationRegistry.delete(cancellationId); + } +} + +// ============================================================================ +// AspireClient (JSON-RPC Connection) +// ============================================================================ + +/** + * Client for connecting to the Aspire AppHost via socket/named pipe. + */ +export class AspireClient { + private connection: rpc.MessageConnection | null = null; + private socket: net.Socket | null = null; + private disconnectCallbacks: (() => void)[] = []; + private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; + + constructor(private socketPath: string) { } + + /** + * Register a callback to be called when the connection is lost + */ + onDisconnect(callback: () => void): void { + this.disconnectCallbacks.push(callback); + } + + private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + + for (const callback of this.disconnectCallbacks) { + try { + callback(); + } catch { + // Ignore callback errors + } + } + } + + connect(timeoutMs: number = 5000): Promise { + if (this.connected) { + return Promise.resolve(); + } + + 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._connectPromise = new Promise((resolve, reject) => { + const socket = net.createConnection(pipePath); + this.socket = socket; + + 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; + } + + clearTimeout(timeout); + cleanupPendingListeners(); + + try { + 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.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); + + // Handle callback invocations from the .NET side + this.connection.onRequest('invokeCallback', async (callbackId: string, args: unknown) => { + const callback = callbackRegistry.get(callbackId); + if (!callback) { + throw new Error(`Callback not found: ${callbackId}`); + } + try { + // The registered wrapper handles arg unpacking and handle wrapping + // Pass this client so handles can be wrapped with typed wrapper classes + return await Promise.resolve(callback(args, this)); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + throw new Error(`Callback execution failed: ${message}`); + } + }); + + 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.'); + } + + connectedClients.add(this); + this._connectPromise = null; + settled = true; + + resolve(); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); + } + }; + + 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 { + if (!this.connection) return Promise.reject(new Error('Not connected to AppHost')); + return this.connection.sendRequest('ping'); + } + + /** + * Cancel a CancellationToken by its ID. + * Called when an AbortSignal is aborted. + * + * @param tokenId - The token ID to cancel + * @returns True if the token was found and cancelled, false otherwise + */ + cancelToken(tokenId: string): Promise { + if (!this.connection) return Promise.reject(new Error('Not connected to AppHost')); + return this.connection.sendRequest('cancelToken', tokenId); + } + + /** + * Invoke an ATS capability by ID. + * + * Capabilities are operations exposed by [AspireExport] attributes. + * Results are automatically wrapped in Handle objects when applicable. + * + * @param capabilityId - The capability ID (e.g., "Aspire.Hosting/createBuilder") + * @param args - Arguments to pass to the capability + * @returns The capability result, wrapped as Handle if it's a handle type + * @throws CapabilityError if the capability fails + */ + async invokeCapability( + capabilityId: string, + args?: Record + ): Promise { + if (!this.connection) { + throw new Error('Not connected to AppHost'); + } + + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; + + try { + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); + + // 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; + } finally { + this._pendingCalls--; + if (this._pendingCalls === 0) { + this.socket?.unref(); + } + } + } finally { + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); + } + } + } + + disconnect(): void { + 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 { + return this.connection !== null && this.socket !== null; + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..2815369b08c --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:55686;http://localhost:57768", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:51980", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:28684" + } + } + }, + "packages": { + "Aspire.Hosting.SqlServer": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..30f9b9f1e7e --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Valkey": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..f584976ed4b --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Yarp": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..83102f6682b --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json @@ -0,0 +1,21 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29750;http://localhost:28931", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10975", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13319" + } + } + }, + "packages": { + "Aspire.Hosting": "", + "Aspire.Hosting.Testing": "", + "Aspire.Hosting.Yarp": "", + "Aspire.Hosting.Redis": "" + } +} \ No newline at end of file diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs index 8d2b152a7e7..ff402b7bc78 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs @@ -122,6 +122,21 @@ public sealed class AtsTypeScriptCodeGenerator : ICodeGenerator // Mapping of enum type IDs to TypeScript enum names private readonly Dictionary _enumTypeNames = new(StringComparer.Ordinal); + private static string GetInterfaceName(string className) => $"I{className}"; + + private static string GetPromiseInterfaceName(string className) => $"I{className}Promise"; + + private static string GetReferenceExpressionInterfaceName() => "IReferenceExpression"; + + private static string GetCancellationTokenInterfaceName() => "ICancellationToken"; + + private static string GetHandleReferenceInterfaceName() => "IHandleReference"; + + private string GetConcreteClassName(string typeId) => _wrapperClassNames.GetValueOrDefault(typeId) + ?? DeriveClassName(typeId); + + private string GetPublicPromiseInterfaceName(string typeId) => GetPromiseInterfaceName(GetConcreteClassName(typeId)); + /// /// Checks if an AtsTypeRef represents a handle type. /// @@ -142,13 +157,13 @@ private string MapTypeRefToTypeScript(AtsTypeRef? typeRef) // Check for wrapper class first (handles custom types like resource builders) if (_wrapperClassNames.TryGetValue(typeRef.TypeId, out var wrapperClassName)) { - return wrapperClassName; + return GetInterfaceName(wrapperClassName); } // ReferenceExpression is a value type defined in base.ts, not a handle-based wrapper if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) { - return "ReferenceExpression"; + return GetReferenceExpressionInterfaceName(); } return typeRef.Category switch @@ -183,7 +198,7 @@ AtsConstants.DateTime or AtsConstants.DateTimeOffset or AtsConstants.DateOnly or AtsConstants.TimeOnly => "string", AtsConstants.TimeSpan => "number", AtsConstants.Guid or AtsConstants.Uri => "string", - AtsConstants.CancellationToken => "CancellationToken", + AtsConstants.CancellationToken => GetCancellationTokenInterfaceName(), _ => typeId }; @@ -244,19 +259,19 @@ private static string GetDtoInterfaceName(string typeId) /// /// Maps a user-supplied input type to TypeScript. - /// For interface handle types, generated APIs accept wrapper instances. + /// For interface handle types, generated APIs accept any handle-bearing wrapper instance. /// For cancellation tokens, generated APIs accept either an AbortSignal or a transport-safe CancellationToken. /// private string MapInputTypeToTypeScript(AtsTypeRef? typeRef) { if (IsInterfaceHandleType(typeRef)) { - return "ResourceBuilderBase"; + return GetHandleReferenceInterfaceName(); } if (IsCancellationTokenType(typeRef)) { - return "AbortSignal | CancellationToken"; + return $"AbortSignal | {GetCancellationTokenInterfaceName()}"; } return MapTypeRefToTypeScript(typeRef); @@ -395,6 +410,12 @@ private string GenerateAspireSdk(AtsContext context) registerHandleWrapper } from './transport.js'; + import type { + ICancellationToken, + IHandleReference, + IReferenceExpression + } from './base.js'; + import { ResourceBuilderBase, ReferenceExpression, @@ -919,8 +940,234 @@ private static string GetTypeDescription(string typeId) return $"Handle to {typeName}"; } + private string BuildPublicParameterList(List requiredParams, bool hasOptionals, string optionsInterfaceName) + { + var publicParamDefs = new List(); + foreach (var param in requiredParams) + { + var tsType = MapParameterToTypeScript(param); + publicParamDefs.Add($"{param.Name}: {tsType}"); + } + if (hasOptionals) + { + publicParamDefs.Add($"options?: {optionsInterfaceName}"); + } + + return string.Join(", ", publicParamDefs); + } + + private void GenerateInterfaceProperty(string propertyName, AtsCapabilityInfo? getter, AtsCapabilityInfo? setter) + { + if (getter?.ReturnType is { } returnType) + { + if (IsDictionaryType(returnType)) + { + var keyType = returnType.KeyType != null ? MapTypeRefToTypeScript(returnType.KeyType) : "string"; + var valueType = returnType.ValueType != null ? MapTypeRefToTypeScript(returnType.ValueType) : "unknown"; + WriteLine($" readonly {propertyName}: AspireDict<{keyType}, {valueType}>;"); + return; + } + + if (IsListType(returnType)) + { + var elementType = returnType.ElementType != null ? MapTypeRefToTypeScript(returnType.ElementType) : "unknown"; + WriteLine($" readonly {propertyName}: AspireList<{elementType}>;"); + return; + } + } + + WriteLine($" {propertyName}: {{"); + + if (getter != null) + { + var returnTypeName = MapTypeRefToTypeScript(getter.ReturnType); + WriteLine($" get: () => Promise<{returnTypeName}>;"); + } + + if (setter != null) + { + var valueParam = setter.Parameters.FirstOrDefault(p => p.Name == "value"); + if (valueParam != null) + { + var valueType = MapInputTypeToTypeScript(valueParam.Type); + WriteLine($" set: (value: {valueType}) => Promise;"); + } + } + + WriteLine(" };"); + } + + private string GetBuilderPromiseInterfaceForMethod(BuilderModel builder, AtsCapabilityInfo capability) + { + if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && + !string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && + !string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) + { + return GetPublicPromiseInterfaceName(capability.ReturnType.TypeId); + } + + return GetPromiseInterfaceName(builder.BuilderClassName); + } + + private void GenerateBuilderInterface(BuilderModel builder) + { + var interfaceName = GetInterfaceName(builder.BuilderClassName); + + WriteLine("// ============================================================================"); + WriteLine($"// {interfaceName}"); + WriteLine("// ============================================================================"); + WriteLine(); + WriteLine($"export interface {interfaceName} {{"); + WriteLine(" toJSON(): MarshalledHandle;"); + + var getters = builder.Capabilities.Where(c => c.CapabilityKind == AtsCapabilityKind.PropertyGetter).ToList(); + var setters = builder.Capabilities.Where(c => c.CapabilityKind == AtsCapabilityKind.PropertySetter).ToList(); + if (getters.Count > 0 || setters.Count > 0) + { + var properties = GroupPropertiesByName(getters, setters); + foreach (var prop in properties) + { + GenerateInterfaceProperty(prop.PropertyName, prop.Getter, prop.Setter); + } + } + + foreach (var capability in builder.Capabilities.Where(c => + c.CapabilityKind != AtsCapabilityKind.PropertyGetter && + c.CapabilityKind != AtsCapabilityKind.PropertySetter)) + { + var (requiredParams, optionalParams) = SeparateParameters(capability.Parameters); + var hasOptionals = optionalParams.Count > 0; + var optionsInterfaceName = ResolveOptionsInterfaceName(capability); + var publicParamsString = BuildPublicParameterList(requiredParams, hasOptionals, optionsInterfaceName); + var hasNonBuilderReturn = !capability.ReturnsBuilder && capability.ReturnType != null; + + if (hasNonBuilderReturn) + { + var returnType = MapTypeRefToTypeScript(capability.ReturnType); + WriteLine($" {capability.MethodName}({publicParamsString}): Promise<{returnType}>;"); + } + else + { + WriteLine($" {capability.MethodName}({publicParamsString}): {GetBuilderPromiseInterfaceForMethod(builder, capability)};"); + } + } + + WriteLine("}"); + WriteLine(); + } + + private void GenerateBuilderPromiseInterface(BuilderModel builder) + { + var interfaceName = GetInterfaceName(builder.BuilderClassName); + var promiseInterfaceName = GetPromiseInterfaceName(builder.BuilderClassName); + + WriteLine($"export interface {promiseInterfaceName} extends PromiseLike<{interfaceName}> {{"); + + foreach (var capability in builder.Capabilities.Where(c => + c.CapabilityKind != AtsCapabilityKind.PropertyGetter && + c.CapabilityKind != AtsCapabilityKind.PropertySetter)) + { + var (requiredParams, optionalParams) = SeparateParameters(capability.Parameters); + var hasOptionals = optionalParams.Count > 0; + var optionsInterfaceName = ResolveOptionsInterfaceName(capability); + var paramsString = BuildPublicParameterList(requiredParams, hasOptionals, optionsInterfaceName); + var hasNonBuilderReturn = !capability.ReturnsBuilder && capability.ReturnType != null; + + if (hasNonBuilderReturn) + { + var returnType = MapTypeRefToTypeScript(capability.ReturnType); + WriteLine($" {capability.MethodName}({paramsString}): Promise<{returnType}>;"); + } + else + { + WriteLine($" {capability.MethodName}({paramsString}): {GetBuilderPromiseInterfaceForMethod(builder, capability)};"); + } + } + + WriteLine("}"); + WriteLine(); + } + + private void GenerateTypeClassInterfaceMethod(string className, AtsCapabilityInfo capability) + { + var methodName = !string.IsNullOrEmpty(capability.OwningTypeName) && capability.MethodName.Contains('.') + ? capability.MethodName[(capability.MethodName.LastIndexOf('.') + 1)..] + : GetTypeScriptMethodName(capability.MethodName); + var targetParamName = capability.TargetParameterName ?? "context"; + var userParams = capability.Parameters.Where(p => p.Name != targetParamName).ToList(); + var (requiredParams, optionalParams) = SeparateParameters(userParams); + var hasOptionals = optionalParams.Count > 0; + var optionsInterfaceName = ResolveOptionsInterfaceName(capability); + var paramsString = BuildPublicParameterList(requiredParams, hasOptionals, optionsInterfaceName); + var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; + + if (capability.ReturnType != null && _typesWithPromiseWrappers.Contains(capability.ReturnType.TypeId)) + { + WriteLine($" {methodName}({paramsString}): {GetPublicPromiseInterfaceName(capability.ReturnType.TypeId)};"); + } + else if (isVoid) + { + WriteLine($" {methodName}({paramsString}): {GetPromiseInterfaceName(className)};"); + } + else + { + var returnType = MapTypeRefToTypeScript(capability.ReturnType); + WriteLine($" {methodName}({paramsString}): Promise<{returnType}>;"); + } + } + + private void GenerateTypeClassInterface(BuilderModel model) + { + var className = DeriveClassName(model.TypeId); + var interfaceName = GetInterfaceName(className); + var hasMethods = HasChainableMethods(model); + + WriteLine("// ============================================================================"); + WriteLine($"// {interfaceName}"); + WriteLine("// ============================================================================"); + WriteLine(); + WriteLine($"export interface {interfaceName} {{"); + WriteLine(" toJSON(): MarshalledHandle;"); + + var getters = model.Capabilities.Where(c => c.CapabilityKind == AtsCapabilityKind.PropertyGetter).ToList(); + var setters = model.Capabilities.Where(c => c.CapabilityKind == AtsCapabilityKind.PropertySetter).ToList(); + var contextMethods = model.Capabilities.Where(c => c.CapabilityKind == AtsCapabilityKind.InstanceMethod).ToList(); + var otherMethods = model.Capabilities.Where(c => c.CapabilityKind == AtsCapabilityKind.Method).ToList(); + + var properties = GroupPropertiesByName(getters, setters); + foreach (var prop in properties) + { + GenerateInterfaceProperty(prop.PropertyName, prop.Getter, prop.Setter); + } + + foreach (var method in contextMethods.Concat(otherMethods)) + { + GenerateTypeClassInterfaceMethod(className, method); + } + + WriteLine("}"); + WriteLine(); + + if (!hasMethods) + { + return; + } + + var promiseInterfaceName = GetPromiseInterfaceName(className); + WriteLine($"export interface {promiseInterfaceName} extends PromiseLike<{interfaceName}> {{"); + foreach (var method in contextMethods.Concat(otherMethods)) + { + GenerateTypeClassInterfaceMethod(className, method); + } + WriteLine("}"); + WriteLine(); + } + private void GenerateBuilderClass(BuilderModel builder) { + GenerateBuilderInterface(builder); + GenerateBuilderPromiseInterface(builder); + WriteLine("// ============================================================================"); WriteLine($"// {builder.BuilderClassName}"); WriteLine("// ============================================================================"); @@ -1606,6 +1853,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise /// Generates a property-like object that returns a wrapper class. /// - private void GenerateWrapperPropertyObject(string propertyName, AtsCapabilityInfo getter, string wrapperClassName) + private void GenerateWrapperPropertyObject(string propertyName, AtsCapabilityInfo getter, AtsCapabilityInfo? setter, string wrapperClassName) { var handleType = GetHandleTypeName(getter.ReturnType!.TypeId); @@ -1928,6 +2178,22 @@ private void GenerateWrapperPropertyObject(string propertyName, AtsCapabilityInf WriteLine(" );"); WriteLine($" return new {wrapperClassName}(handle, this._client);"); WriteLine(" },"); + + if (setter != null) + { + var valueParam = setter.Parameters.FirstOrDefault(p => p.Name == "value"); + if (valueParam != null) + { + var valueType = MapInputTypeToTypeScript(valueParam.Type); + WriteLine($" set: async (value: {valueType}): Promise => {{"); + WriteLine($" await this._client.invokeCapability("); + WriteLine($" '{setter.CapabilityId}',"); + WriteLine($" {{ context: this._handle, {GetRpcArgumentEntry("value", valueParam.Type)} }}"); + WriteLine(" );"); + WriteLine(" }"); + } + } + WriteLine(" };"); WriteLine(); } diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts index 95f3429b80d..e380bd12749 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts @@ -1,9 +1,10 @@ -// base.ts - Core Aspire types: base classes, ReferenceExpression +// base.ts - Core Aspire types: base classes, ReferenceExpression +import type { ICancellationToken } from './transport.js'; import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience export { Handle, AspireClient, CapabilityError, CancellationToken, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; -export type { MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; +export type { ICancellationToken, MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './transport.js'; // ============================================================================ @@ -38,15 +39,22 @@ export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './t * await api.withEnvironment("REDIS_URL", expr); * ``` */ -export class ReferenceExpression { +export interface IReferenceExpression { + readonly isConditional: boolean; + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle; + getValue(cancellationToken?: AbortSignal | ICancellationToken): Promise; + toString(): string; +} + +export class ReferenceExpression implements IReferenceExpression { // Expression mode fields private readonly _format?: string; private readonly _valueProviders?: unknown[]; // Conditional mode fields private readonly _condition?: unknown; - private readonly _whenTrue?: ReferenceExpression; - private readonly _whenFalse?: ReferenceExpression; + private readonly _whenTrue?: IReferenceExpression; + private readonly _whenFalse?: IReferenceExpression; private readonly _matchValue?: string; // Handle mode fields (when wrapping a server-returned handle) @@ -55,12 +63,12 @@ export class ReferenceExpression { constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor(condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression); constructor( handleOrFormatOrCondition: Handle | string | unknown, clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, - whenTrueOrWhenFalse?: ReferenceExpression, - whenFalse?: ReferenceExpression + whenTrueOrWhenFalse?: IReferenceExpression, + whenFalse?: IReferenceExpression ) { if (typeof handleOrFormatOrCondition === 'string') { this._format = handleOrFormatOrCondition; @@ -90,7 +98,7 @@ export class ReferenceExpression { * @param values - The interpolated values (handles to value providers) * @returns A ReferenceExpression instance */ - static create(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { + static create(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { // Build the format string with {0}, {1}, etc. placeholders let format = ''; for (let i = 0; i < strings.length; i++) { @@ -118,9 +126,9 @@ export class ReferenceExpression { static createConditional( condition: unknown, matchValue: string, - whenTrue: ReferenceExpression, - whenFalse: ReferenceExpression - ): ReferenceExpression { + whenTrue: IReferenceExpression, + whenFalse: IReferenceExpression + ): IReferenceExpression { return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); } @@ -161,7 +169,7 @@ export class ReferenceExpression { * @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 { + async getValue(cancellationToken?: AbortSignal | ICancellationToken): Promise { if (!this._handle || !this._client) { throw new Error('getValue is only available on server-returned ReferenceExpression instances'); } @@ -258,7 +266,7 @@ function extractHandleForExpr(value: unknown): unknown { * await api.withEnvironment("REDIS_URL", expr); * ``` */ -export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { +export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { return ReferenceExpression.create(strings, ...values); } @@ -266,11 +274,15 @@ export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): Re // ResourceBuilderBase // ============================================================================ +export interface IHandleReference { + toJSON(): MarshalledHandle; +} + /** * Base class for resource builders (e.g., RedisBuilder, ContainerBuilder). * Provides handle management and JSON serialization. */ -export class ResourceBuilderBase { +export class ResourceBuilderBase implements IHandleReference { constructor(protected _handle: THandle, protected _client: AspireClient) {} toJSON(): MarshalledHandle { return this._handle.toJSON(); } diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts index 904e57142f9..80eca54a17a 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts @@ -104,6 +104,17 @@ function isAbortSignal(value: unknown): value is AbortSignal { ); } +function isCancellationTokenLike(value: unknown): value is ICancellationToken { + return ( + value !== null && + typeof value === 'object' && + 'register' in value && + typeof (value as { register?: unknown }).register === 'function' && + 'toJSON' in value && + typeof (value as { toJSON?: unknown }).toJSON === 'function' + ); +} + function isPlainObject(value: unknown): value is Record { if (value === null || typeof value !== 'object') { return false; @@ -205,7 +216,12 @@ export class Handle { * const connectionString = await connectionStringExpression.getValue(cancellationToken); * ``` */ -export class CancellationToken { +export interface ICancellationToken { + toJSON(): string | undefined; + register(client?: AspireClient): string | undefined; +} + +export class CancellationToken implements ICancellationToken { private readonly _signal?: AbortSignal; private readonly _remoteTokenId?: string; @@ -230,8 +246,8 @@ export class CancellationToken { * 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) { + static fromValue(value: unknown): ICancellationToken { + if (isCancellationTokenLike(value)) { return value; } @@ -569,7 +585,7 @@ function resolveCancellationClient(client?: AspireClient): 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 */ -export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | ICancellationToken): string | undefined; /** * Registers cancellation support using the single connected AspireClient. * @@ -586,21 +602,21 @@ export function registerCancellation(client: AspireClient, signalOrToken?: Abort * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation(signalOrToken?: AbortSignal | ICancellationToken): string | undefined; export function registerCancellation( - clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, - maybeSignalOrToken?: AbortSignal | CancellationToken + clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, + maybeSignalOrToken?: AbortSignal | ICancellationToken ): string | undefined { const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; const signalOrToken = client ? maybeSignalOrToken - : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; if (!signalOrToken) { return undefined; } - if (signalOrToken instanceof CancellationToken) { + if (isCancellationTokenLike(signalOrToken)) { return signalOrToken.register(client); } @@ -648,7 +664,7 @@ async function marshalTransportValue( return value; } - if (value instanceof CancellationToken) { + if (isCancellationTokenLike(value)) { const cancellationId = value.register(client); if (cancellationId !== undefined) { cancellationIds.push(cancellationId); diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs index 9b0a0060aea..dba9e709135 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs @@ -582,23 +582,17 @@ public void Pattern4_InterfaceParameterType_HasCorrectTypeRef() [Fact] public void Pattern4_InterfaceParameterType_GeneratesUnionType() { - // Pattern 4/5: Verify that parameters with interface handle types generate union types - // in the generated TypeScript. + // Interface-constrained resource parameters should accept a structural + // handle-bearing type instead of the nominal ResourceBuilderBase type. var atsContext = CreateContextFromTestAssembly(); // Generate the TypeScript output var files = _generator.GenerateDistributedApplication(atsContext); var aspireTs = files["aspire.ts"]; - // The withDependency method should have its dependency parameter as a union type: - // dependency: IResourceWithConnectionStringHandle | ResourceBuilderBase - // Note: The exact generated name depends on the type mapping, but it should contain - // both the handle type and ResourceBuilderBase. - Assert.Contains("ResourceBuilderBase", aspireTs); - - // Also verify the union type pattern appears somewhere - // (the exact format depends on the type name mapping) - Assert.Contains("|", aspireTs); // Union types use pipe + Assert.Contains("export type { ICancellationToken, IHandleReference, IReferenceExpression } from './base.js';", aspireTs); + Assert.Contains("withDependency(dependency: IHandleReference)", aspireTs); + Assert.DoesNotContain("withDependency(dependency: ResourceBuilderBase)", aspireTs); } [Fact] @@ -1139,12 +1133,12 @@ public void Scanner_CancellationToken_MapsToCorrectTypeId() public void Generate_MethodWithCancellationToken_GeneratesCancellationTokenParameter() { // Generated input parameters should accept AbortSignal for user-authored cancellation, - // while callbacks and returned values continue to use the SDK CancellationToken wrapper. + // while callbacks and returned values use the structural SDK cancellation token interface. var code = GenerateTwoPassCode(); - Assert.Contains("cancellationToken?: AbortSignal | CancellationToken;", code); - Assert.Contains("set: async (value: AbortSignal | CancellationToken): Promise => {", code); - Assert.Contains("withCancellableOperation(operation: (arg: CancellationToken) => Promise)", code); + Assert.Contains("cancellationToken?: AbortSignal | ICancellationToken;", code); + Assert.Contains("set: async (value: AbortSignal | ICancellationToken): Promise => {", code); + Assert.Contains("withCancellableOperation(operation: (arg: ICancellationToken) => Promise)", code); } [Fact] diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts index 31fe0cf0350..b7597580326 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts @@ -16,6 +16,12 @@ import { registerHandleWrapper } from './transport.js'; +import type { + ICancellationToken, + IHandleReference, + IReferenceExpression +} from './base.js'; + import { ResourceBuilderBase, ReferenceExpression, @@ -125,11 +131,11 @@ export interface AddTestRedisOptions { } export interface GetStatusAsyncOptions { - cancellationToken?: AbortSignal | CancellationToken; + cancellationToken?: AbortSignal | ICancellationToken; } export interface WaitForReadyAsyncOptions { - cancellationToken?: AbortSignal | CancellationToken; + cancellationToken?: AbortSignal | ICancellationToken; } export interface WithDataVolumeOptions { @@ -148,7 +154,7 @@ export interface WithMergeLoggingPathOptions { } export interface WithOptionalCallbackOptions { - callback?: (arg: TestCallbackContext) => Promise; + callback?: (arg: ITestCallbackContext) => Promise; } export interface WithOptionalStringOptions { @@ -160,6 +166,26 @@ export interface WithPersistenceOptions { mode?: TestPersistenceMode; } +// ============================================================================ +// ITestCallbackContext +// ============================================================================ + +export interface ITestCallbackContext { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + value: { + get: () => Promise; + set: (value: number) => Promise; + }; + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | ICancellationToken) => Promise; + }; +} + // ============================================================================ // TestCallbackContext // ============================================================================ @@ -207,14 +233,14 @@ export class TestCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.cancellationToken', { context: this._handle } ); return CancellationToken.fromValue(result); }, - set: async (value: AbortSignal | CancellationToken): Promise => { + set: async (value: AbortSignal | ICancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -224,6 +250,16 @@ export class TestCallbackContext { } +// ============================================================================ +// ITestCollectionContext +// ============================================================================ + +export interface ITestCollectionContext { + toJSON(): MarshalledHandle; + readonly items: AspireList; + readonly metadata: AspireDict; +} + // ============================================================================ // TestCollectionContext // ============================================================================ @@ -267,6 +303,26 @@ export class TestCollectionContext { } +// ============================================================================ +// ITestEnvironmentContext +// ============================================================================ + +export interface ITestEnvironmentContext { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + description: { + get: () => Promise; + set: (value: string) => Promise; + }; + priority: { + get: () => Promise; + set: (value: number) => Promise; + }; +} + // ============================================================================ // TestEnvironmentContext // ============================================================================ @@ -330,6 +386,31 @@ export class TestEnvironmentContext { } +// ============================================================================ +// ITestResourceContext +// ============================================================================ + +export interface ITestResourceContext { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + value: { + get: () => Promise; + set: (value: number) => Promise; + }; + getValueAsync(): Promise; + setValueAsync(value: string): ITestResourceContextPromise; + validateAsync(): Promise; +} + +export interface ITestResourceContextPromise extends PromiseLike { + getValueAsync(): Promise; + setValueAsync(value: string): ITestResourceContextPromise; + validateAsync(): Promise; +} + // ============================================================================ // TestResourceContext // ============================================================================ @@ -440,6 +521,21 @@ export class TestResourceContextPromise implements PromiseLike { + addTestRedis(name: string, options?: AddTestRedisOptions): ITestRedisResourcePromise; + addTestVault(name: string): ITestVaultResourcePromise; +} + // ============================================================================ // DistributedApplicationBuilder // ============================================================================ @@ -512,6 +608,49 @@ export class DistributedApplicationBuilderPromise implements PromiseLike Promise): ITestDatabaseResourcePromise; + withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; + withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; + testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; + withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ITestDatabaseResourcePromise; +} + +export interface ITestDatabaseResourcePromise extends PromiseLike { + withOptionalString(options?: WithOptionalStringOptions): ITestDatabaseResourcePromise; + withConfig(config: TestConfigDto): ITestDatabaseResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestDatabaseResourcePromise; + withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; + withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; + testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; + withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ITestDatabaseResourcePromise; +} + // ============================================================================ // TestDatabaseResource // ============================================================================ @@ -556,7 +695,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -571,7 +710,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -621,7 +760,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -673,7 +812,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -688,12 +827,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -703,12 +842,12 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -718,7 +857,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -767,7 +906,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withCancellableOperationInternal(operation)); } @@ -944,7 +1083,7 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -979,17 +1118,17 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { + testWaitFor(dependency: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { + withDependency(dependency: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -1004,7 +1143,7 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } @@ -1055,6 +1194,71 @@ export class TestDatabaseResourcePromise implements PromiseLike>; + getMetadata(): Promise>; + withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withCreatedAt(createdAt: string): ITestRedisResourcePromise; + withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; + withCorrelationId(correlationId: string): ITestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; + withStatus(status: TestResourceStatus): ITestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; + testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + getEndpoints(): Promise; + withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; + withRedisSpecific(option: string): ITestRedisResourcePromise; + withDependency(dependency: IHandleReference): ITestRedisResourcePromise; + withEndpoints(endpoints: string[]): ITestRedisResourcePromise; + withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + getStatusAsync(options?: GetStatusAsyncOptions): Promise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; +} + +export interface ITestRedisResourcePromise extends PromiseLike { + addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): ITestDatabaseResourcePromise; + withPersistence(options?: WithPersistenceOptions): ITestRedisResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ITestRedisResourcePromise; + withConfig(config: TestConfigDto): ITestRedisResourcePromise; + getTags(): Promise>; + getMetadata(): Promise>; + withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withCreatedAt(createdAt: string): ITestRedisResourcePromise; + withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; + withCorrelationId(correlationId: string): ITestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; + withStatus(status: TestResourceStatus): ITestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; + testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + getEndpoints(): Promise; + withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; + withRedisSpecific(option: string): ITestRedisResourcePromise; + withDependency(dependency: IHandleReference): ITestRedisResourcePromise; + withEndpoints(endpoints: string[]): ITestRedisResourcePromise; + withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + getStatusAsync(options?: GetStatusAsyncOptions): Promise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; +} + // ============================================================================ // TestRedisResource // ============================================================================ @@ -1151,7 +1355,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withConnectionStringInternal(connectionString: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', @@ -1161,12 +1365,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -1181,7 +1385,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -1231,7 +1435,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -1283,7 +1487,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -1298,12 +1502,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -1313,7 +1517,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -1367,7 +1571,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -1427,7 +1631,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withCancellableOperationInternal(operation)); } @@ -1443,7 +1647,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withMultiParamHandleCallbackInternal(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (arg1Data: unknown, arg2Data: unknown) => { const arg1Handle = wrapIfHandle(arg1Data) as TestCallbackContextHandle; const arg1 = new TestCallbackContext(arg1Handle, this._client); @@ -1460,7 +1664,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withMultiParamHandleCallbackInternal(callback)); } @@ -1659,12 +1863,12 @@ export class TestRedisResourcePromise implements PromiseLike } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise { + withConnectionString(connectionString: IReferenceExpression): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionString(connectionString))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -1699,12 +1903,12 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): TestRedisResourcePromise { + testWaitFor(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } @@ -1724,7 +1928,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): TestRedisResourcePromise { + withDependency(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -1744,7 +1948,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } @@ -1754,7 +1958,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Tests multi-param callback destructuring */ - withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withMultiParamHandleCallback(callback))); } @@ -1805,6 +2009,49 @@ export class TestRedisResourcePromise implements PromiseLike } +// ============================================================================ +// ITestVaultResource +// ============================================================================ + +export interface ITestVaultResource { + toJSON(): MarshalledHandle; + withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; + withConfig(config: TestConfigDto): ITestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; + withCreatedAt(createdAt: string): ITestVaultResourcePromise; + withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; + withCorrelationId(correlationId: string): ITestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; + withStatus(status: TestResourceStatus): ITestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; + testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; + withDependency(dependency: IHandleReference): ITestVaultResourcePromise; + withEndpoints(endpoints: string[]): ITestVaultResourcePromise; + withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; + withVaultDirect(option: string): ITestVaultResourcePromise; +} + +export interface ITestVaultResourcePromise extends PromiseLike { + withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; + withConfig(config: TestConfigDto): ITestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; + withCreatedAt(createdAt: string): ITestVaultResourcePromise; + withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; + withCorrelationId(correlationId: string): ITestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; + withStatus(status: TestResourceStatus): ITestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; + testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; + withDependency(dependency: IHandleReference): ITestVaultResourcePromise; + withEndpoints(endpoints: string[]): ITestVaultResourcePromise; + withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; + withVaultDirect(option: string): ITestVaultResourcePromise; +} + // ============================================================================ // TestVaultResource // ============================================================================ @@ -1849,7 +2096,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -1864,7 +2111,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -1914,7 +2161,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -1966,7 +2213,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -1981,12 +2228,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -1996,12 +2243,12 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -2011,7 +2258,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -2060,7 +2307,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withCancellableOperationInternal(operation)); } @@ -2235,7 +2482,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -2270,17 +2517,17 @@ export class TestVaultResourcePromise implements PromiseLike } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): TestVaultResourcePromise { + testWaitFor(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): TestVaultResourcePromise { + withDependency(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -2295,7 +2542,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } @@ -2346,6 +2593,43 @@ export class TestVaultResourcePromise implements PromiseLike } +// ============================================================================ +// IResource +// ============================================================================ + +export interface IResource { + toJSON(): MarshalledHandle; + withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; + withConfig(config: TestConfigDto): IResourcePromise; + withCreatedAt(createdAt: string): IResourcePromise; + withModifiedAt(modifiedAt: string): IResourcePromise; + withCorrelationId(correlationId: string): IResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; + withStatus(status: TestResourceStatus): IResourcePromise; + withNestedConfig(config: TestNestedDto): IResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; + testWaitFor(dependency: IHandleReference): IResourcePromise; + withDependency(dependency: IHandleReference): IResourcePromise; + withEndpoints(endpoints: string[]): IResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; +} + +export interface IResourcePromise extends PromiseLike { + withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; + withConfig(config: TestConfigDto): IResourcePromise; + withCreatedAt(createdAt: string): IResourcePromise; + withModifiedAt(modifiedAt: string): IResourcePromise; + withCorrelationId(correlationId: string): IResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; + withStatus(status: TestResourceStatus): IResourcePromise; + withNestedConfig(config: TestNestedDto): IResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; + testWaitFor(dependency: IHandleReference): IResourcePromise; + withDependency(dependency: IHandleReference): IResourcePromise; + withEndpoints(endpoints: string[]): IResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; +} + // ============================================================================ // Resource // ============================================================================ @@ -2435,7 +2719,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -2487,7 +2771,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -2502,12 +2786,12 @@ export class Resource extends ResourceBuilderBase { } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { return new ResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -2517,12 +2801,12 @@ export class Resource extends ResourceBuilderBase { } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ResourcePromise { + testWaitFor(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: ResourceBuilderBase): Promise { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -2532,7 +2816,7 @@ export class Resource extends ResourceBuilderBase { } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ResourcePromise { + withDependency(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._withDependencyInternal(dependency)); } @@ -2552,7 +2836,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -2566,7 +2850,7 @@ export class Resource extends ResourceBuilderBase { } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { return new ResourcePromise(this._withCancellableOperationInternal(operation)); } @@ -2756,17 +3040,17 @@ export class ResourcePromise implements PromiseLike { } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ResourcePromise { + testWaitFor(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ResourcePromise { + withDependency(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -2776,7 +3060,7 @@ export class ResourcePromise implements PromiseLike { } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } @@ -2822,6 +3106,21 @@ export class ResourcePromise implements PromiseLike { } +// ============================================================================ +// IResourceWithConnectionString +// ============================================================================ + +export interface IResourceWithConnectionString { + toJSON(): MarshalledHandle; + withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; +} + +export interface IResourceWithConnectionStringPromise extends PromiseLike { + withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; +} + // ============================================================================ // ResourceWithConnectionString // ============================================================================ @@ -2832,7 +3131,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + private async _withConnectionStringInternal(connectionString: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', @@ -2842,7 +3141,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase obj.withConnectionString(connectionString))); } @@ -2890,6 +3189,21 @@ export class ResourceWithConnectionStringPromise implements PromiseLike Promise): IResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; +} + +export interface IResourceWithEnvironmentPromise extends PromiseLike { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; +} + // ============================================================================ // ResourceWithEnvironment // ============================================================================ @@ -2900,7 +3214,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -2915,7 +3229,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -2952,7 +3266,7 @@ export class ResourceWithEnvironmentPromise implements PromiseLike Promise): ResourceWithEnvironmentPromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -3028,6 +3342,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise Promise; + configure?: (obj: IContainerResource) => Promise; } export interface PublishResourceUpdateOptions { @@ -529,19 +535,19 @@ export interface PublishResourceUpdateOptions { } export interface RunOptions { - cancellationToken?: AbortSignal | CancellationToken; + cancellationToken?: AbortSignal | ICancellationToken; } export interface SaveStateJsonOptions { - cancellationToken?: AbortSignal | CancellationToken; + cancellationToken?: AbortSignal | ICancellationToken; } export interface UpdateTaskMarkdownOptions { - cancellationToken?: AbortSignal | CancellationToken; + cancellationToken?: AbortSignal | ICancellationToken; } export interface UpdateTaskOptions { - cancellationToken?: AbortSignal | CancellationToken; + cancellationToken?: AbortSignal | ICancellationToken; } export interface WaitForCompletionOptions { @@ -549,7 +555,7 @@ export interface WaitForCompletionOptions { } export interface WaitForReadyAsyncOptions { - cancellationToken?: AbortSignal | CancellationToken; + cancellationToken?: AbortSignal | ICancellationToken; } export interface WaitForResourceStateOptions { @@ -624,7 +630,7 @@ export interface WithHttpProbeOptions { } export interface WithHttpsDeveloperCertificateOptions { - password?: ParameterResource; + password?: IParameterResource; } export interface WithHttpsEndpointOptions { @@ -648,18 +654,8 @@ export interface WithMcpServerOptions { endpointName?: string; } -export interface WithMergeLoggingOptions { - enableConsole?: boolean; - maxFiles?: number; -} - -export interface WithMergeLoggingPathOptions { - enableConsole?: boolean; - maxFiles?: number; -} - export interface WithOptionalCallbackOptions { - callback?: (arg: TestCallbackContext) => Promise; + callback?: (arg: ITestCallbackContext) => Promise; } export interface WithOptionalStringOptions { @@ -701,6 +697,20 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// IAfterResourcesCreatedEvent +// ============================================================================ + +export interface IAfterResourcesCreatedEvent { + toJSON(): MarshalledHandle; + services: { + get: () => Promise; + }; + model: { + get: () => Promise; + }; +} + // ============================================================================ // AfterResourcesCreatedEvent // ============================================================================ @@ -738,6 +748,20 @@ export class AfterResourcesCreatedEvent { } +// ============================================================================ +// IBeforeResourceStartedEvent +// ============================================================================ + +export interface IBeforeResourceStartedEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + // ============================================================================ // BeforeResourceStartedEvent // ============================================================================ @@ -775,6 +799,20 @@ export class BeforeResourceStartedEvent { } +// ============================================================================ +// IBeforeStartEvent +// ============================================================================ + +export interface IBeforeStartEvent { + toJSON(): MarshalledHandle; + services: { + get: () => Promise; + }; + model: { + get: () => Promise; + }; +} + // ============================================================================ // BeforeStartEvent // ============================================================================ @@ -812,6 +850,29 @@ export class BeforeStartEvent { } +// ============================================================================ +// ICommandLineArgsCallbackContext +// ============================================================================ + +export interface ICommandLineArgsCallbackContext { + toJSON(): MarshalledHandle; + readonly args: AspireList; + cancellationToken: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + set: (value: IDistributedApplicationExecutionContext) => Promise; + }; + logger: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; + resource: { + get: () => Promise; + }; +} + // ============================================================================ // CommandLineArgsCallbackContext // ============================================================================ @@ -841,7 +902,7 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } @@ -859,6 +920,12 @@ export class CommandLineArgsCallbackContext { ); return new DistributedApplicationExecutionContext(handle, this._client); }, + set: async (value: IDistributedApplicationExecutionContext): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setExecutionContext', + { context: this._handle, value } + ); + } }; /** Gets the Logger property */ @@ -870,6 +937,12 @@ export class CommandLineArgsCallbackContext { ); return new Logger(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setLogger', + { context: this._handle, value } + ); + } }; /** Gets the Resource property */ @@ -885,6 +958,20 @@ export class CommandLineArgsCallbackContext { } +// ============================================================================ +// IConnectionStringAvailableEvent +// ============================================================================ + +export interface IConnectionStringAvailableEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + // ============================================================================ // ConnectionStringAvailableEvent // ============================================================================ @@ -922,6 +1009,19 @@ export class ConnectionStringAvailableEvent { } +// ============================================================================ +// IDistributedApplication +// ============================================================================ + +export interface IDistributedApplication { + toJSON(): MarshalledHandle; + run(options?: RunOptions): IDistributedApplicationPromise; +} + +export interface IDistributedApplicationPromise extends PromiseLike { + run(options?: RunOptions): IDistributedApplicationPromise; +} + // ============================================================================ // DistributedApplication // ============================================================================ @@ -937,7 +1037,7 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { + async _runInternal(cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( @@ -974,6 +1074,30 @@ export class DistributedApplicationPromise implements PromiseLike Promise; + set: (value: string) => Promise; + }; + operation: { + get: () => Promise; + }; + serviceProvider: { + get: () => Promise; + }; + isPublishMode: { + get: () => Promise; + }; + isRunMode: { + get: () => Promise; + }; +} + // ============================================================================ // DistributedApplicationExecutionContext // ============================================================================ @@ -1046,6 +1170,21 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// IDistributedApplicationModel +// ============================================================================ + +export interface IDistributedApplicationModel { + toJSON(): MarshalledHandle; + getResources(): Promise; + findResourceByName(name: string): IResourcePromise; +} + +export interface IDistributedApplicationModelPromise extends PromiseLike { + getResources(): Promise; + findResourceByName(name: string): IResourcePromise; +} + // ============================================================================ // DistributedApplicationModel // ============================================================================ @@ -1060,9 +1199,9 @@ export class DistributedApplicationModel { toJSON(): MarshalledHandle { return this._handle.toJSON(); } /** Gets resources from the distributed application model */ - async getResources(): Promise { + async getResources(): Promise { const rpcArgs: Record = { model: this._handle }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getResources', rpcArgs ); @@ -1099,7 +1238,7 @@ export class DistributedApplicationModelPromise implements PromiseLike { + getResources(): Promise { return this._promise.then(obj => obj.getResources()); } @@ -1110,6 +1249,61 @@ export class DistributedApplicationModelPromise implements PromiseLike Promise; + }; + endpointName: { + get: () => Promise; + }; + errorMessage: { + get: () => Promise; + set: (value: string) => Promise; + }; + isAllocated: { + get: () => Promise; + }; + exists: { + get: () => Promise; + }; + isHttp: { + get: () => Promise; + }; + isHttps: { + get: () => Promise; + }; + tlsEnabled: { + get: () => Promise; + }; + port: { + get: () => Promise; + }; + targetPort: { + get: () => Promise; + }; + host: { + get: () => Promise; + }; + scheme: { + get: () => Promise; + }; + url: { + get: () => Promise; + }; + getValueAsync(options?: GetValueAsyncOptions): Promise; + getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; +} + +export interface IEndpointReferencePromise extends PromiseLike { + getValueAsync(options?: GetValueAsyncOptions): Promise; + getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -1210,16 +1404,6 @@ export class EndpointReference { }, }; - /** Gets the ExcludeReferenceEndpoint property */ - excludeReferenceEndpoint = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint', - { context: this._handle } - ); - }, - }; - /** Gets the Port property */ port = { get: async (): Promise => { @@ -1282,9 +1466,9 @@ export class EndpointReference { } /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ - async getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise { + async getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { const rpcArgs: Record = { context: this._handle, enabledValue, disabledValue }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EndpointReference.getTlsValue', rpcArgs ); @@ -1311,12 +1495,29 @@ export class EndpointReferencePromise implements PromiseLike } /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ - getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise { + getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); } } +// ============================================================================ +// IEndpointReferenceExpression +// ============================================================================ + +export interface IEndpointReferenceExpression { + toJSON(): MarshalledHandle; + endpoint: { + get: () => Promise; + }; + property: { + get: () => Promise; + }; + valueExpression: { + get: () => Promise; + }; +} + // ============================================================================ // EndpointReferenceExpression // ============================================================================ @@ -1363,6 +1564,28 @@ export class EndpointReferenceExpression { } +// ============================================================================ +// IEnvironmentCallbackContext +// ============================================================================ + +export interface IEnvironmentCallbackContext { + toJSON(): MarshalledHandle; + readonly environmentVariables: AspireDict; + cancellationToken: { + get: () => Promise; + }; + logger: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; + resource: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; +} + // ============================================================================ // EnvironmentCallbackContext // ============================================================================ @@ -1377,10 +1600,10 @@ export class EnvironmentCallbackContext { toJSON(): MarshalledHandle { return this._handle.toJSON(); } /** Gets the EnvironmentVariables property */ - private _environmentVariables?: AspireDict; - get environmentVariables(): AspireDict { + private _environmentVariables?: AspireDict; + get environmentVariables(): AspireDict { if (!this._environmentVariables) { - this._environmentVariables = new AspireDict( + this._environmentVariables = new AspireDict( this._handle, this._client, 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.environmentVariables', @@ -1392,7 +1615,7 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } @@ -1410,6 +1633,12 @@ export class EnvironmentCallbackContext { ); return new Logger(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.setLogger', + { context: this._handle, value } + ); + } }; /** Gets the Resource property */ @@ -1436,6 +1665,26 @@ export class EnvironmentCallbackContext { } +// ============================================================================ +// IExecuteCommandContext +// ============================================================================ + +export interface IExecuteCommandContext { + toJSON(): MarshalledHandle; + serviceProvider: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; + resourceName: { + get: () => Promise; + set: (value: string) => Promise; + }; + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | ICancellationToken) => Promise; + }; +} + // ============================================================================ // ExecuteCommandContext // ============================================================================ @@ -1458,6 +1707,12 @@ export class ExecuteCommandContext { ); return new ServiceProvider(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setServiceProvider', + { context: this._handle, value } + ); + } }; /** Gets the ResourceName property */ @@ -1478,14 +1733,14 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + 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 | CancellationToken): Promise => { + set: async (value: AbortSignal | ICancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -1495,6 +1750,29 @@ export class ExecuteCommandContext { } +// ============================================================================ +// IInitializeResourceEvent +// ============================================================================ + +export interface IInitializeResourceEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + eventing: { + get: () => Promise; + }; + logger: { + get: () => Promise; + }; + notifications: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + // ============================================================================ // InitializeResourceEvent // ============================================================================ @@ -1565,6 +1843,31 @@ export class InitializeResourceEvent { } +// ============================================================================ +// IPipelineConfigurationContext +// ============================================================================ + +export interface IPipelineConfigurationContext { + toJSON(): MarshalledHandle; + services: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; + steps: { + get: () => Promise; + set: (value: IPipelineStep[]) => Promise; + }; + model: { + get: () => Promise; + set: (value: IDistributedApplicationModel) => Promise; + }; + getStepsByTag(tag: string): Promise; +} + +export interface IPipelineConfigurationContextPromise extends PromiseLike { + getStepsByTag(tag: string): Promise; +} + // ============================================================================ // PipelineConfigurationContext // ============================================================================ @@ -1587,17 +1890,23 @@ export class PipelineConfigurationContext { ); return new ServiceProvider(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setServices', + { context: this._handle, value } + ); + } }; /** Gets the Steps property */ steps = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + return await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', { context: this._handle } ); }, - set: async (value: PipelineStep[]): Promise => { + set: async (value: IPipelineStep[]): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', { context: this._handle, value } @@ -1614,12 +1923,18 @@ export class PipelineConfigurationContext { ); return new DistributedApplicationModel(handle, this._client); }, + set: async (value: IDistributedApplicationModel): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setModel', + { context: this._handle, value } + ); + } }; /** Gets pipeline steps with the specified tag */ - async getStepsByTag(tag: string): Promise { + async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/getStepsByTag', rpcArgs ); @@ -1641,12 +1956,39 @@ export class PipelineConfigurationContextPromise implements PromiseLike { + getStepsByTag(tag: string): Promise { return this._promise.then(obj => obj.getStepsByTag(tag)); } } +// ============================================================================ +// IPipelineContext +// ============================================================================ + +export interface IPipelineContext { + toJSON(): MarshalledHandle; + model: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; + logger: { + get: () => Promise; + }; + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | ICancellationToken) => Promise; + }; + summary: { + get: () => Promise; + }; +} + // ============================================================================ // PipelineContext // ============================================================================ @@ -1706,14 +2048,14 @@ export class PipelineContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + 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 => { + set: async (value: AbortSignal | ICancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -1734,6 +2076,36 @@ export class PipelineContext { } +// ============================================================================ +// IPipelineStep +// ============================================================================ + +export interface IPipelineStep { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + description: { + get: () => Promise; + set: (value: string) => Promise; + }; + readonly dependsOnSteps: AspireList; + readonly requiredBySteps: AspireList; + readonly tags: AspireList; + resource: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; + dependsOn(stepName: string): IPipelineStepPromise; + requiredBy(stepName: string): IPipelineStepPromise; +} + +export interface IPipelineStepPromise extends PromiseLike { + dependsOn(stepName: string): IPipelineStepPromise; + requiredBy(stepName: string): IPipelineStepPromise; +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1830,6 +2202,12 @@ export class PipelineStep { ); return new Resource(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.setResource', + { context: this._handle, value } + ); + } }; /** Adds a dependency on another step by name */ @@ -1889,6 +2267,40 @@ export class PipelineStepPromise implements PromiseLike { } +// ============================================================================ +// IPipelineStepContext +// ============================================================================ + +export interface IPipelineStepContext { + toJSON(): MarshalledHandle; + pipelineContext: { + get: () => Promise; + set: (value: IPipelineContext) => Promise; + }; + reportingStep: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; + model: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; + logger: { + get: () => Promise; + }; + cancellationToken: { + get: () => Promise; + }; + summary: { + get: () => Promise; + }; +} + // ============================================================================ // PipelineStepContext // ============================================================================ @@ -1911,6 +2323,12 @@ export class PipelineStepContext { ); return new PipelineContext(handle, this._client); }, + set: async (value: IPipelineContext): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.setPipelineContext', + { context: this._handle, value } + ); + } }; /** Gets the ReportingStep property */ @@ -1922,6 +2340,12 @@ export class PipelineStepContext { ); return new ReportingStep(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.setReportingStep', + { context: this._handle, value } + ); + } }; /** Gets the Model property */ @@ -1970,7 +2394,7 @@ export class PipelineStepContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } @@ -1992,6 +2416,22 @@ export class PipelineStepContext { } +// ============================================================================ +// IPipelineStepFactoryContext +// ============================================================================ + +export interface IPipelineStepFactoryContext { + toJSON(): MarshalledHandle; + pipelineContext: { + get: () => Promise; + set: (value: IPipelineContext) => Promise; + }; + resource: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; +} + // ============================================================================ // PipelineStepFactoryContext // ============================================================================ @@ -2014,6 +2454,12 @@ export class PipelineStepFactoryContext { ); return new PipelineContext(handle, this._client); }, + set: async (value: IPipelineContext): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setPipelineContext', + { context: this._handle, value } + ); + } }; /** Gets the Resource property */ @@ -2025,10 +2471,31 @@ export class PipelineStepFactoryContext { ); return new Resource(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setResource', + { context: this._handle, value } + ); + } }; } +// ============================================================================ +// IPipelineSummary +// ============================================================================ + +export interface IPipelineSummary { + toJSON(): MarshalledHandle; + add(key: string, value: string): IPipelineSummaryPromise; + addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; +} + +export interface IPipelineSummaryPromise extends PromiseLike { + add(key: string, value: string): IPipelineSummaryPromise; + addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; +} + // ============================================================================ // PipelineSummary // ============================================================================ @@ -2099,6 +2566,26 @@ export class PipelineSummaryPromise implements PromiseLike { } +// ============================================================================ +// IProjectResourceOptions +// ============================================================================ + +export interface IProjectResourceOptions { + toJSON(): MarshalledHandle; + launchProfileName: { + get: () => Promise; + set: (value: string) => Promise; + }; + excludeLaunchProfile: { + get: () => Promise; + set: (value: boolean) => Promise; + }; + excludeKestrelEndpoints: { + get: () => Promise; + set: (value: boolean) => Promise; + }; +} + // ============================================================================ // ProjectResourceOptions // ============================================================================ @@ -2162,6 +2649,28 @@ export class ProjectResourceOptions { } +// ============================================================================ +// IReferenceExpressionBuilder +// ============================================================================ + +export interface IReferenceExpressionBuilder { + toJSON(): MarshalledHandle; + isEmpty: { + get: () => Promise; + }; + appendLiteral(value: string): IReferenceExpressionBuilderPromise; + appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; + build(): Promise; +} + +export interface IReferenceExpressionBuilderPromise extends PromiseLike { + appendLiteral(value: string): IReferenceExpressionBuilderPromise; + appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; + build(): Promise; +} + // ============================================================================ // ReferenceExpressionBuilder // ============================================================================ @@ -2235,9 +2744,9 @@ export class ReferenceExpressionBuilder { } /** Builds the reference expression */ - async build(): Promise { + async build(): Promise { const rpcArgs: Record = { context: this._handle }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/build', rpcArgs ); @@ -2274,12 +2783,26 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike { + build(): Promise { return this._promise.then(obj => obj.build()); } } +// ============================================================================ +// IResourceEndpointsAllocatedEvent +// ============================================================================ + +export interface IResourceEndpointsAllocatedEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + // ============================================================================ // ResourceEndpointsAllocatedEvent // ============================================================================ @@ -2318,10 +2841,25 @@ export class ResourceEndpointsAllocatedEvent { } // ============================================================================ -// ResourceLoggerService +// IResourceLoggerService // ============================================================================ -/** +export interface IResourceLoggerService { + toJSON(): MarshalledHandle; + completeLog(resource: IHandleReference): IResourceLoggerServicePromise; + completeLogByName(resourceName: string): IResourceLoggerServicePromise; +} + +export interface IResourceLoggerServicePromise extends PromiseLike { + completeLog(resource: IHandleReference): IResourceLoggerServicePromise; + completeLogByName(resourceName: string): IResourceLoggerServicePromise; +} + +// ============================================================================ +// ResourceLoggerService +// ============================================================================ + +/** * Type class for ResourceLoggerService. */ export class ResourceLoggerService { @@ -2332,7 +2870,7 @@ export class ResourceLoggerService { /** Completes the log stream for a resource */ /** @internal */ - async _completeLogInternal(resource: ResourceBuilderBase): Promise { + async _completeLogInternal(resource: IHandleReference): Promise { const rpcArgs: Record = { loggerService: this._handle, resource }; await this._client.invokeCapability( 'Aspire.Hosting/completeLog', @@ -2341,7 +2879,7 @@ export class ResourceLoggerService { return this; } - completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + completeLog(resource: IHandleReference): ResourceLoggerServicePromise { return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); } @@ -2376,7 +2914,7 @@ export class ResourceLoggerServicePromise implements PromiseLike obj.completeLog(resource))); } @@ -2387,6 +2925,29 @@ export class ResourceLoggerServicePromise implements PromiseLike; + waitForResourceHealthy(resourceName: string): Promise; + waitForDependencies(resource: IHandleReference): IResourceNotificationServicePromise; + tryGetResourceState(resourceName: string): Promise; + publishResourceUpdate(resource: IHandleReference, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; +} + +export interface IResourceNotificationServicePromise extends PromiseLike { + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): IResourceNotificationServicePromise; + waitForResourceStates(resourceName: string, targetStates: string[]): Promise; + waitForResourceHealthy(resourceName: string): Promise; + waitForDependencies(resource: IHandleReference): IResourceNotificationServicePromise; + tryGetResourceState(resourceName: string): Promise; + publishResourceUpdate(resource: IHandleReference, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; +} + // ============================================================================ // ResourceNotificationService // ============================================================================ @@ -2437,7 +2998,7 @@ export class ResourceNotificationService { /** Waits for all dependencies of a resource to be ready */ /** @internal */ - async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + async _waitForDependenciesInternal(resource: IHandleReference): Promise { const rpcArgs: Record = { notificationService: this._handle, resource }; await this._client.invokeCapability( 'Aspire.Hosting/waitForDependencies', @@ -2446,7 +3007,7 @@ export class ResourceNotificationService { return this; } - waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + waitForDependencies(resource: IHandleReference): ResourceNotificationServicePromise { return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); } @@ -2461,7 +3022,7 @@ export class ResourceNotificationService { /** Publishes an update for a resource's state */ /** @internal */ - async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + async _publishResourceUpdateInternal(resource: IHandleReference, state?: string, stateStyle?: string): Promise { const rpcArgs: Record = { notificationService: this._handle, resource }; if (state !== undefined) rpcArgs.state = state; if (stateStyle !== undefined) rpcArgs.stateStyle = stateStyle; @@ -2472,7 +3033,7 @@ export class ResourceNotificationService { return this; } - publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + publishResourceUpdate(resource: IHandleReference, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { const state = options?.state; const stateStyle = options?.stateStyle; return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); @@ -2509,7 +3070,7 @@ export class ResourceNotificationServicePromise implements PromiseLike obj.waitForDependencies(resource))); } @@ -2519,12 +3080,26 @@ export class ResourceNotificationServicePromise implements PromiseLike obj.publishResourceUpdate(resource, options))); } } +// ============================================================================ +// IResourceReadyEvent +// ============================================================================ + +export interface IResourceReadyEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + // ============================================================================ // ResourceReadyEvent // ============================================================================ @@ -2562,6 +3137,20 @@ export class ResourceReadyEvent { } +// ============================================================================ +// IResourceStoppedEvent +// ============================================================================ + +export interface IResourceStoppedEvent { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + services: { + get: () => Promise; + }; +} + // ============================================================================ // ResourceStoppedEvent // ============================================================================ @@ -2599,6 +3188,28 @@ export class ResourceStoppedEvent { } +// ============================================================================ +// IResourceUrlsCallbackContext +// ============================================================================ + +export interface IResourceUrlsCallbackContext { + toJSON(): MarshalledHandle; + resource: { + get: () => Promise; + }; + readonly urls: AspireList; + cancellationToken: { + get: () => Promise; + }; + logger: { + get: () => Promise; + set: (value: IHandleReference) => Promise; + }; + executionContext: { + get: () => Promise; + }; +} + // ============================================================================ // ResourceUrlsCallbackContext // ============================================================================ @@ -2639,7 +3250,7 @@ export class ResourceUrlsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', { context: this._handle } @@ -2657,6 +3268,12 @@ export class ResourceUrlsCallbackContext { ); return new Logger(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.setLogger', + { context: this._handle, value } + ); + } }; /** Gets the ExecutionContext property */ @@ -2672,6 +3289,26 @@ export class ResourceUrlsCallbackContext { } +// ============================================================================ +// ITestCallbackContext +// ============================================================================ + +export interface ITestCallbackContext { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + value: { + get: () => Promise; + set: (value: number) => Promise; + }; + cancellationToken: { + get: () => Promise; + set: (value: AbortSignal | ICancellationToken) => Promise; + }; +} + // ============================================================================ // TestCallbackContext // ============================================================================ @@ -2719,14 +3356,14 @@ export class TestCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.cancellationToken', { context: this._handle } ); return CancellationToken.fromValue(result); }, - set: async (value: AbortSignal | CancellationToken): Promise => { + set: async (value: AbortSignal | ICancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -2736,6 +3373,16 @@ export class TestCallbackContext { } +// ============================================================================ +// ITestCollectionContext +// ============================================================================ + +export interface ITestCollectionContext { + toJSON(): MarshalledHandle; + readonly items: AspireList; + readonly metadata: AspireDict; +} + // ============================================================================ // TestCollectionContext // ============================================================================ @@ -2779,6 +3426,26 @@ export class TestCollectionContext { } +// ============================================================================ +// ITestEnvironmentContext +// ============================================================================ + +export interface ITestEnvironmentContext { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + description: { + get: () => Promise; + set: (value: string) => Promise; + }; + priority: { + get: () => Promise; + set: (value: number) => Promise; + }; +} + // ============================================================================ // TestEnvironmentContext // ============================================================================ @@ -2842,6 +3509,31 @@ export class TestEnvironmentContext { } +// ============================================================================ +// ITestResourceContext +// ============================================================================ + +export interface ITestResourceContext { + toJSON(): MarshalledHandle; + name: { + get: () => Promise; + set: (value: string) => Promise; + }; + value: { + get: () => Promise; + set: (value: number) => Promise; + }; + getValueAsync(): Promise; + setValueAsync(value: string): ITestResourceContextPromise; + validateAsync(): Promise; +} + +export interface ITestResourceContextPromise extends PromiseLike { + getValueAsync(): Promise; + setValueAsync(value: string): ITestResourceContextPromise; + validateAsync(): Promise; +} + // ============================================================================ // TestResourceContext // ============================================================================ @@ -2952,6 +3644,18 @@ export class TestResourceContextPromise implements PromiseLike Promise; + set: (value: IHandleReference) => Promise; + }; +} + // ============================================================================ // UpdateCommandStateContext // ============================================================================ @@ -2974,10 +3678,37 @@ export class UpdateCommandStateContext { ); return new ServiceProvider(handle, this._client); }, + set: async (value: IHandleReference): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.setServiceProvider', + { context: this._handle, value } + ); + } }; } +// ============================================================================ +// IConfiguration +// ============================================================================ + +export interface IConfiguration { + toJSON(): MarshalledHandle; + getConfigValue(key: string): Promise; + getConnectionString(name: string): Promise; + getSection(key: string): Promise; + getChildren(): Promise; + exists(key: string): Promise; +} + +export interface IConfigurationPromise extends PromiseLike { + getConfigValue(key: string): Promise; + getConnectionString(name: string): Promise; + getSection(key: string): Promise; + getChildren(): Promise; + exists(key: string): Promise; +} + // ============================================================================ // Configuration // ============================================================================ @@ -3078,6 +3809,82 @@ export class ConfigurationPromise implements PromiseLike { } +// ============================================================================ +// IDistributedApplicationBuilder +// ============================================================================ + +export interface IDistributedApplicationBuilder { + toJSON(): MarshalledHandle; + appHostDirectory: { + get: () => Promise; + }; + environment: { + get: () => Promise; + }; + eventing: { + get: () => Promise; + }; + executionContext: { + get: () => Promise; + }; + userSecretsManager: { + get: () => Promise; + }; + build(): IDistributedApplicationPromise; + addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; + addContainer(name: string, image: string): IContainerResourcePromise; + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; + addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; + addExternalService(name: string, url: string): IExternalServiceResourcePromise; + addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; + addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; + addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; + addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; + addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; + addCSharpApp(name: string, path: string): IProjectResourcePromise; + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; + getConfiguration(): IConfigurationPromise; + subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; + subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; + addTestRedis(name: string, options?: AddTestRedisOptions): ITestRedisResourcePromise; + addTestVault(name: string): ITestVaultResourcePromise; +} + +export interface IDistributedApplicationBuilderPromise extends PromiseLike { + build(): IDistributedApplicationPromise; + addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; + addContainer(name: string, image: string): IContainerResourcePromise; + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; + addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; + addExternalService(name: string, url: string): IExternalServiceResourcePromise; + addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; + addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; + addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; + addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; + addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; + addCSharpApp(name: string, path: string): IProjectResourcePromise; + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; + getConfiguration(): IConfigurationPromise; + subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; + subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; + addTestRedis(name: string, options?: AddTestRedisOptions): ITestRedisResourcePromise; + addTestVault(name: string): ITestVaultResourcePromise; +} + // ============================================================================ // DistributedApplicationBuilder // ============================================================================ @@ -3162,7 +3969,7 @@ export class DistributedApplicationBuilder { /** Adds a connection string with a reference expression */ /** @internal */ - async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; const result = await this._client.invokeCapability( 'Aspire.Hosting/addConnectionStringExpression', @@ -3171,13 +3978,13 @@ export class DistributedApplicationBuilder { return new ConnectionStringResource(result, this._client); } - addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): 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 { + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): Promise { const connectionStringBuilderId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; const obj = new ReferenceExpressionBuilder(objHandle, this._client); @@ -3191,13 +3998,13 @@ export class DistributedApplicationBuilder { return new ConnectionStringResource(result, this._client); } - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); } /** Adds a container registry resource */ /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + async _addContainerRegistryInternal(name: string, endpoint: IParameterResource, repository?: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, endpoint }; if (repository !== undefined) rpcArgs.repository = repository; const result = await this._client.invokeCapability( @@ -3207,7 +4014,7 @@ export class DistributedApplicationBuilder { return new ContainerRegistryResource(result, this._client); } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { const repository = options?.repository; return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); } @@ -3325,7 +4132,7 @@ export class DistributedApplicationBuilder { /** Adds an external service with a parameter URL */ /** @internal */ - async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + async _addExternalServiceParameterInternal(name: string, urlParameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, urlParameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/addExternalServiceParameter', @@ -3334,7 +4141,7 @@ export class DistributedApplicationBuilder { return new ExternalServiceResource(result, this._client); } - addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + addExternalServiceParameter(name: string, urlParameter: IParameterResource): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); } @@ -3425,7 +4232,7 @@ export class DistributedApplicationBuilder { /** Adds a project resource with configuration options */ /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; const obj = new ProjectResourceOptions(objHandle, this._client); @@ -3439,7 +4246,7 @@ export class DistributedApplicationBuilder { return new ProjectResource(result, this._client); } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); } @@ -3460,7 +4267,7 @@ export class DistributedApplicationBuilder { /** Adds a C# application resource with configuration options */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; const obj = new ProjectResourceOptions(objHandle, this._client); @@ -3474,7 +4281,7 @@ export class DistributedApplicationBuilder { return new CSharpAppResource(result, this._client); } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); } @@ -3494,7 +4301,7 @@ export class DistributedApplicationBuilder { } /** Subscribes to the BeforeStart event */ - async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + async subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; const arg = new BeforeStartEvent(argHandle, this._client); @@ -3508,7 +4315,7 @@ export class DistributedApplicationBuilder { } /** Subscribes to the AfterResourcesCreated event */ - async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + async subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; const arg = new AfterResourcesCreatedEvent(argHandle, this._client); @@ -3574,17 +4381,17 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addConnectionStringExpression(name, connectionStringExpression))); } /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); } /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); } @@ -3624,7 +4431,7 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addExternalServiceParameter(name, urlParameter))); } @@ -3654,7 +4461,7 @@ export class DistributedApplicationBuilderPromise implements PromiseLike Promise): ProjectResourcePromise { + addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); } @@ -3664,7 +4471,7 @@ export class DistributedApplicationBuilderPromise implements PromiseLike Promise): CSharpAppResourcePromise { + addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); } @@ -3674,12 +4481,12 @@ export class DistributedApplicationBuilderPromise implements PromiseLike Promise): Promise { + subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise { return this._promise.then(obj => obj.subscribeBeforeStart(callback)); } /** Subscribes to the AfterResourcesCreated event */ - subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise { return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); } @@ -3695,6 +4502,19 @@ export class DistributedApplicationBuilderPromise implements PromiseLike { + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): IDistributedApplicationEventingPromise; +} + // ============================================================================ // DistributedApplicationEventing // ============================================================================ @@ -3745,6 +4565,25 @@ export class DistributedApplicationEventingPromise implements PromiseLike; + isProduction(): Promise; + isStaging(): Promise; + isEnvironment(environmentName: string): Promise; +} + +export interface IHostEnvironmentPromise extends PromiseLike { + isDevelopment(): Promise; + isProduction(): Promise; + isStaging(): Promise; + isEnvironment(environmentName: string): Promise; +} + // ============================================================================ // HostEnvironment // ============================================================================ @@ -3831,6 +4670,27 @@ export class HostEnvironmentPromise implements PromiseLike { } +// ============================================================================ +// ILogger +// ============================================================================ + +export interface ILogger { + toJSON(): MarshalledHandle; + logInformation(message: string): ILoggerPromise; + logWarning(message: string): ILoggerPromise; + logError(message: string): ILoggerPromise; + logDebug(message: string): ILoggerPromise; + log(level: string, message: string): ILoggerPromise; +} + +export interface ILoggerPromise extends PromiseLike { + logInformation(message: string): ILoggerPromise; + logWarning(message: string): ILoggerPromise; + logError(message: string): ILoggerPromise; + logDebug(message: string): ILoggerPromise; + log(level: string, message: string): ILoggerPromise; +} + // ============================================================================ // Logger // ============================================================================ @@ -3961,6 +4821,19 @@ export class LoggerPromise implements PromiseLike { } +// ============================================================================ +// ILoggerFactory +// ============================================================================ + +export interface ILoggerFactory { + toJSON(): MarshalledHandle; + createLogger(categoryName: string): ILoggerPromise; +} + +export interface ILoggerFactoryPromise extends PromiseLike { + createLogger(categoryName: string): ILoggerPromise; +} + // ============================================================================ // LoggerFactory // ============================================================================ @@ -4011,6 +4884,29 @@ export class LoggerFactoryPromise implements PromiseLike { } +// ============================================================================ +// IReportingStep +// ============================================================================ + +export interface IReportingStep { + toJSON(): MarshalledHandle; + createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; + logStep(level: string, message: string): IReportingStepPromise; + logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; + completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; +} + +export interface IReportingStepPromise extends PromiseLike { + createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; + logStep(level: string, message: string): IReportingStepPromise; + logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; + completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; +} + // ============================================================================ // ReportingStep // ============================================================================ @@ -4026,7 +4922,7 @@ export class ReportingStep { /** Creates a reporting task with plain-text status text */ /** @internal */ - async _createTaskInternal(statusText: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _createTaskInternal(statusText: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingStep: this._handle, statusText }; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); const result = await this._client.invokeCapability( @@ -4043,7 +4939,7 @@ export class ReportingStep { /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _createMarkdownTaskInternal(markdownString: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _createMarkdownTaskInternal(markdownString: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingStep: this._handle, markdownString }; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); const result = await this._client.invokeCapability( @@ -4090,7 +4986,7 @@ export class ReportingStep { /** Completes the reporting step with plain-text completion text */ /** @internal */ - async _completeStepInternal(completionText: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _completeStepInternal(completionText: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingStep: this._handle, completionText }; if (completionState !== undefined) rpcArgs.completionState = completionState; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); @@ -4109,7 +5005,7 @@ export class ReportingStep { /** Completes the reporting step with Markdown-formatted completion text */ /** @internal */ - async _completeStepMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _completeStepMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingStep: this._handle, markdownString }; if (completionState !== undefined) rpcArgs.completionState = completionState; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); @@ -4173,6 +5069,25 @@ export class ReportingStepPromise implements PromiseLike { } +// ============================================================================ +// IReportingTask +// ============================================================================ + +export interface IReportingTask { + toJSON(): MarshalledHandle; + updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; + completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; +} + +export interface IReportingTaskPromise extends PromiseLike { + updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; + completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; +} + // ============================================================================ // ReportingTask // ============================================================================ @@ -4188,7 +5103,7 @@ export class ReportingTask { /** Updates the reporting task with plain-text status text */ /** @internal */ - async _updateTaskInternal(statusText: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _updateTaskInternal(statusText: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingTask: this._handle, statusText }; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( @@ -4205,7 +5120,7 @@ export class ReportingTask { /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _updateTaskMarkdownInternal(markdownString: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _updateTaskMarkdownInternal(markdownString: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingTask: this._handle, markdownString }; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( @@ -4222,7 +5137,7 @@ export class ReportingTask { /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _completeTaskInternal(completionMessage?: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _completeTaskInternal(completionMessage?: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingTask: this._handle }; if (completionMessage !== undefined) rpcArgs.completionMessage = completionMessage; if (completionState !== undefined) rpcArgs.completionState = completionState; @@ -4243,7 +5158,7 @@ export class ReportingTask { /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _completeTaskMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _completeTaskMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { reportingTask: this._handle, markdownString }; if (completionState !== undefined) rpcArgs.completionState = completionState; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); @@ -4297,6 +5212,29 @@ export class ReportingTaskPromise implements PromiseLike { } +// ============================================================================ +// IServiceProvider +// ============================================================================ + +export interface IServiceProvider { + toJSON(): MarshalledHandle; + getEventing(): IDistributedApplicationEventingPromise; + getLoggerFactory(): ILoggerFactoryPromise; + getResourceLoggerService(): IResourceLoggerServicePromise; + getDistributedApplicationModel(): IDistributedApplicationModelPromise; + getResourceNotificationService(): IResourceNotificationServicePromise; + getUserSecretsManager(): IUserSecretsManagerPromise; +} + +export interface IServiceProviderPromise extends PromiseLike { + getEventing(): IDistributedApplicationEventingPromise; + getLoggerFactory(): ILoggerFactoryPromise; + getResourceLoggerService(): IResourceLoggerServicePromise; + getDistributedApplicationModel(): IDistributedApplicationModelPromise; + getResourceNotificationService(): IResourceNotificationServicePromise; + getUserSecretsManager(): IUserSecretsManagerPromise; +} + // ============================================================================ // ServiceProvider // ============================================================================ @@ -4447,6 +5385,29 @@ export class ServiceProviderPromise implements PromiseLike { } +// ============================================================================ +// IUserSecretsManager +// ============================================================================ + +export interface IUserSecretsManager { + toJSON(): MarshalledHandle; + isAvailable: { + get: () => Promise; + }; + filePath: { + get: () => Promise; + }; + trySetSecret(name: string, value: string): Promise; + saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; + getOrSetSecret(resourceBuilder: IHandleReference, name: string, value: string): IUserSecretsManagerPromise; +} + +export interface IUserSecretsManagerPromise extends PromiseLike { + trySetSecret(name: string, value: string): Promise; + saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; + getOrSetSecret(resourceBuilder: IHandleReference, name: string, value: string): IUserSecretsManagerPromise; +} + // ============================================================================ // UserSecretsManager // ============================================================================ @@ -4491,7 +5452,7 @@ export class UserSecretsManager { /** Saves state to user secrets from a JSON string */ /** @internal */ - async _saveStateJsonInternal(json: string, cancellationToken?: AbortSignal | CancellationToken): Promise { + async _saveStateJsonInternal(json: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { const rpcArgs: Record = { userSecretsManager: this._handle, json }; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( @@ -4508,7 +5469,7 @@ export class UserSecretsManager { /** 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 { + async _getOrSetSecretInternal(resourceBuilder: IHandleReference, name: string, value: string): Promise { const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; await this._client.invokeCapability( 'Aspire.Hosting/getOrSetSecret', @@ -4517,7 +5478,7 @@ export class UserSecretsManager { return this; } - getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + getOrSetSecret(resourceBuilder: IHandleReference, name: string, value: string): UserSecretsManagerPromise { return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } @@ -4547,12 +5508,119 @@ export class UserSecretsManagerPromise implements PromiseLike obj.getOrSetSecret(resourceBuilder, name, value))); } } +// ============================================================================ +// IConnectionStringResource +// ============================================================================ + +export interface IConnectionStringResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IConnectionStringResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; + withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; + getConnectionProperty(key: string): Promise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; + excludeFromManifest(): IConnectionStringResourcePromise; + waitFor(dependency: IHandleReference): IConnectionStringResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + waitForStart(dependency: IHandleReference): IConnectionStringResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + withExplicitStart(): IConnectionStringResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; + withHealthCheck(key: string): IConnectionStringResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; + withParentRelationship(parent: IHandleReference): IConnectionStringResourcePromise; + withChildRelationship(child: IHandleReference): IConnectionStringResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; + excludeFromMcp(): IConnectionStringResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IConnectionStringResourcePromise; + withConfig(config: TestConfigDto): IConnectionStringResourcePromise; + withConnectionString(connectionString: IReferenceExpression): IConnectionStringResourcePromise; + withCreatedAt(createdAt: string): IConnectionStringResourcePromise; + withModifiedAt(modifiedAt: string): IConnectionStringResourcePromise; + withCorrelationId(correlationId: string): IConnectionStringResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IConnectionStringResourcePromise; + withStatus(status: TestResourceStatus): IConnectionStringResourcePromise; + withNestedConfig(config: TestNestedDto): IConnectionStringResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IConnectionStringResourcePromise; + testWaitFor(dependency: IHandleReference): IConnectionStringResourcePromise; + withConnectionStringDirect(connectionString: string): IConnectionStringResourcePromise; + withDependency(dependency: IHandleReference): IConnectionStringResourcePromise; + withEndpoints(endpoints: string[]): IConnectionStringResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IConnectionStringResourcePromise; +} + +export interface IConnectionStringResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IConnectionStringResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; + withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; + getConnectionProperty(key: string): Promise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; + excludeFromManifest(): IConnectionStringResourcePromise; + waitFor(dependency: IHandleReference): IConnectionStringResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + waitForStart(dependency: IHandleReference): IConnectionStringResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; + withExplicitStart(): IConnectionStringResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; + withHealthCheck(key: string): IConnectionStringResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; + withParentRelationship(parent: IHandleReference): IConnectionStringResourcePromise; + withChildRelationship(child: IHandleReference): IConnectionStringResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; + excludeFromMcp(): IConnectionStringResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IConnectionStringResourcePromise; + withConfig(config: TestConfigDto): IConnectionStringResourcePromise; + withConnectionString(connectionString: IReferenceExpression): IConnectionStringResourcePromise; + withCreatedAt(createdAt: string): IConnectionStringResourcePromise; + withModifiedAt(modifiedAt: string): IConnectionStringResourcePromise; + withCorrelationId(correlationId: string): IConnectionStringResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IConnectionStringResourcePromise; + withStatus(status: TestResourceStatus): IConnectionStringResourcePromise; + withNestedConfig(config: TestNestedDto): IConnectionStringResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IConnectionStringResourcePromise; + testWaitFor(dependency: IHandleReference): IConnectionStringResourcePromise; + withConnectionStringDirect(connectionString: string): IConnectionStringResourcePromise; + withDependency(dependency: IHandleReference): IConnectionStringResourcePromise; + withEndpoints(endpoints: string[]): IConnectionStringResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IConnectionStringResourcePromise; +} + // ============================================================================ // ConnectionStringResource // ============================================================================ @@ -4563,7 +5631,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -4573,7 +5641,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', @@ -4624,7 +5692,7 @@ 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 { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -4659,10 +5736,30 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -4681,7 +5778,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -4692,7 +5789,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + waitFor(dependency: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -4757,27 +5854,27 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + waitForStart(dependency: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -4787,7 +5884,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { const exitCode = options?.exitCode; return new ConnectionStringResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -4839,7 +5936,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -4855,38 +5952,38 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { const commandOptions = options?.commandOptions; return new ConnectionStringResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { + withParentRelationship(parent: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ConnectionStringResourcePromise { + withChildRelationship(child: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._withChildRelationshipInternal(child)); } @@ -4923,7 +6020,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -4942,7 +6039,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -4951,7 +6048,27 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -4966,7 +6083,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -4980,7 +6097,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -4995,12 +6112,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -5015,12 +6132,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; const arg = new ConnectionStringAvailableEvent(argHandle, this._client); @@ -5035,12 +6152,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -5055,12 +6172,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -5075,7 +6192,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); } @@ -5114,7 +6231,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withConnectionStringInternal(connectionString: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', @@ -5124,7 +6241,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -5226,7 +6343,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -5241,12 +6358,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -5256,7 +6373,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -5286,7 +6403,7 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -5320,192 +6437,74 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); +} + +/** + * Thenable wrapper for ConnectionStringResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class ConnectionStringResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ConnectionStringResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withMergeLabelInternal(label)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IHandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); + /** Adds a connection property with a reference expression */ + withConnectionProperty(name: string, value: IReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withMergeEndpointInternal(endpointName, port)); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ConnectionStringResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ConnectionStringResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ConnectionStringResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ConnectionStringResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - -} - -/** - * Thenable wrapper for ConnectionStringResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ConnectionStringResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ConnectionStringResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -5520,22 +6519,22 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + waitForStart(dependency: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -5545,7 +6544,7 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.waitForCompletion(dependency, options))); } @@ -5555,17 +6554,17 @@ export class ConnectionStringResourcePromise implements PromiseLike Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { + withParentRelationship(parent: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ConnectionStringResourcePromise { + withChildRelationship(child: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -5580,12 +6579,17 @@ export class ConnectionStringResourcePromise implements PromiseLike Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -5595,27 +6599,27 @@ export class ConnectionStringResourcePromise implements PromiseLike Promise): ConnectionStringResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -5630,7 +6634,7 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionString(connectionString))); } @@ -5665,12 +6669,12 @@ export class ConnectionStringResourcePromise implements PromiseLike Promise): ConnectionStringResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ConnectionStringResourcePromise { + testWaitFor(dependency: IHandleReference): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } @@ -5680,7 +6684,7 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withDependency(dependency))); } @@ -5690,50 +6694,95 @@ export class ConnectionStringResourcePromise implements PromiseLike Promise): ConnectionStringResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IContainerRegistryResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IContainerRegistryResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IContainerRegistryResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; + excludeFromManifest(): IContainerRegistryResourcePromise; + withExplicitStart(): IContainerRegistryResourcePromise; + withHealthCheck(key: string): IContainerRegistryResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; + withParentRelationship(parent: IHandleReference): IContainerRegistryResourcePromise; + withChildRelationship(child: IHandleReference): IContainerRegistryResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; + excludeFromMcp(): IContainerRegistryResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IContainerRegistryResourcePromise; + withConfig(config: TestConfigDto): IContainerRegistryResourcePromise; + withCreatedAt(createdAt: string): IContainerRegistryResourcePromise; + withModifiedAt(modifiedAt: string): IContainerRegistryResourcePromise; + withCorrelationId(correlationId: string): IContainerRegistryResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerRegistryResourcePromise; + withStatus(status: TestResourceStatus): IContainerRegistryResourcePromise; + withNestedConfig(config: TestNestedDto): IContainerRegistryResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerRegistryResourcePromise; + testWaitFor(dependency: IHandleReference): IContainerRegistryResourcePromise; + withDependency(dependency: IHandleReference): IContainerRegistryResourcePromise; + withEndpoints(endpoints: string[]): IContainerRegistryResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerRegistryResourcePromise; +} +export interface IContainerRegistryResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IContainerRegistryResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; + excludeFromManifest(): IContainerRegistryResourcePromise; + withExplicitStart(): IContainerRegistryResourcePromise; + withHealthCheck(key: string): IContainerRegistryResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; + withParentRelationship(parent: IHandleReference): IContainerRegistryResourcePromise; + withChildRelationship(child: IHandleReference): IContainerRegistryResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; + excludeFromMcp(): IContainerRegistryResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IContainerRegistryResourcePromise; + withConfig(config: TestConfigDto): IContainerRegistryResourcePromise; + withCreatedAt(createdAt: string): IContainerRegistryResourcePromise; + withModifiedAt(modifiedAt: string): IContainerRegistryResourcePromise; + withCorrelationId(correlationId: string): IContainerRegistryResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerRegistryResourcePromise; + withStatus(status: TestResourceStatus): IContainerRegistryResourcePromise; + withNestedConfig(config: TestNestedDto): IContainerRegistryResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerRegistryResourcePromise; + testWaitFor(dependency: IHandleReference): IContainerRegistryResourcePromise; + withDependency(dependency: IHandleReference): IContainerRegistryResourcePromise; + withEndpoints(endpoints: string[]): IContainerRegistryResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerRegistryResourcePromise; } // ============================================================================ @@ -5746,7 +6795,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -5756,7 +6805,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -5812,10 +6861,30 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -5834,7 +6903,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -5845,7 +6914,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -5931,38 +7000,38 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { const commandOptions = options?.commandOptions; return new ContainerRegistryResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + withParentRelationship(parent: IHandleReference): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + withChildRelationship(child: IHandleReference): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); } @@ -5999,7 +7068,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -6018,7 +7087,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -6027,7 +7096,27 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -6042,7 +7131,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -6056,7 +7145,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -6071,12 +7160,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -6091,12 +7180,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -6111,12 +7200,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -6131,7 +7220,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); } @@ -6215,7 +7304,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -6267,7 +7356,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -6282,12 +7371,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -6297,12 +7386,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -6312,7 +7401,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -6346,138 +7435,10 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerRegistryResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ContainerRegistryResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerRegistryResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ContainerRegistryResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - } /** @@ -6496,7 +7457,7 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); } @@ -6511,17 +7472,22 @@ export class ContainerRegistryResourcePromise implements PromiseLike Promise): ContainerRegistryResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -6546,17 +7512,17 @@ export class ContainerRegistryResourcePromise implements PromiseLike Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + withParentRelationship(parent: IHandleReference): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + withChildRelationship(child: IHandleReference): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -6571,12 +7537,17 @@ export class ContainerRegistryResourcePromise implements PromiseLike Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -6586,22 +7557,22 @@ export class ContainerRegistryResourcePromise implements PromiseLike Promise): ContainerRegistryResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -6646,17 +7617,17 @@ export class ContainerRegistryResourcePromise implements PromiseLike Promise): ContainerRegistryResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ContainerRegistryResourcePromise { + testWaitFor(dependency: IHandleReference): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ContainerRegistryResourcePromise { + withDependency(dependency: IHandleReference): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -6666,50 +7637,207 @@ export class ContainerRegistryResourcePromise implements PromiseLike Promise): ContainerRegistryResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IContainerResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IContainerResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IContainerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; + withEntrypoint(entrypoint: string): IContainerResourcePromise; + withImageTag(tag: string): IContainerResourcePromise; + withImageRegistry(registry: string): IContainerResourcePromise; + withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; + withImageSHA256(sha256: string): IContainerResourcePromise; + withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; + withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; + publishAsContainer(): IContainerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; + withContainerName(name: string): IContainerResourcePromise; + withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; + withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; + withContainerNetworkAlias(alias: string): IContainerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; + withOtlpExporter(): IContainerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; + publishAsConnectionString(): IContainerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IContainerResourcePromise; + withArgs(args: string[]): IContainerResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IContainerResourcePromise; + withReferenceUri(name: string, uri: string): IContainerResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; + withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; + withExternalHttpEndpoints(): IContainerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IContainerResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; + excludeFromManifest(): IContainerResourcePromise; + waitFor(dependency: IHandleReference): IContainerResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; + waitForStart(dependency: IHandleReference): IContainerResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; + withExplicitStart(): IContainerResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IContainerResourcePromise; + withHealthCheck(key: string): IContainerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; + withoutHttpsCertificate(): IContainerResourcePromise; + withParentRelationship(parent: IHandleReference): IContainerResourcePromise; + withChildRelationship(child: IHandleReference): IContainerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; + excludeFromMcp(): IContainerResourcePromise; + withRemoteImageName(remoteImageName: string): IContainerResourcePromise; + withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IContainerResourcePromise; + withConfig(config: TestConfigDto): IContainerResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IContainerResourcePromise; + withCreatedAt(createdAt: string): IContainerResourcePromise; + withModifiedAt(modifiedAt: string): IContainerResourcePromise; + withCorrelationId(correlationId: string): IContainerResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerResourcePromise; + withStatus(status: TestResourceStatus): IContainerResourcePromise; + withNestedConfig(config: TestNestedDto): IContainerResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerResourcePromise; + testWaitFor(dependency: IHandleReference): IContainerResourcePromise; + withDependency(dependency: IHandleReference): IContainerResourcePromise; + withEndpoints(endpoints: string[]): IContainerResourcePromise; + withEnvironmentVariables(variables: Record): IContainerResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerResourcePromise; +} +export interface IContainerResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IContainerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; + withEntrypoint(entrypoint: string): IContainerResourcePromise; + withImageTag(tag: string): IContainerResourcePromise; + withImageRegistry(registry: string): IContainerResourcePromise; + withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; + withImageSHA256(sha256: string): IContainerResourcePromise; + withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; + withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; + publishAsContainer(): IContainerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; + withContainerName(name: string): IContainerResourcePromise; + withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; + withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; + withContainerNetworkAlias(alias: string): IContainerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; + withOtlpExporter(): IContainerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; + publishAsConnectionString(): IContainerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IContainerResourcePromise; + withArgs(args: string[]): IContainerResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IContainerResourcePromise; + withReferenceUri(name: string, uri: string): IContainerResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; + withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; + withExternalHttpEndpoints(): IContainerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IContainerResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; + excludeFromManifest(): IContainerResourcePromise; + waitFor(dependency: IHandleReference): IContainerResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; + waitForStart(dependency: IHandleReference): IContainerResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; + withExplicitStart(): IContainerResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IContainerResourcePromise; + withHealthCheck(key: string): IContainerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; + withoutHttpsCertificate(): IContainerResourcePromise; + withParentRelationship(parent: IHandleReference): IContainerResourcePromise; + withChildRelationship(child: IHandleReference): IContainerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; + excludeFromMcp(): IContainerResourcePromise; + withRemoteImageName(remoteImageName: string): IContainerResourcePromise; + withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IContainerResourcePromise; + withConfig(config: TestConfigDto): IContainerResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IContainerResourcePromise; + withCreatedAt(createdAt: string): IContainerResourcePromise; + withModifiedAt(modifiedAt: string): IContainerResourcePromise; + withCorrelationId(correlationId: string): IContainerResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerResourcePromise; + withStatus(status: TestResourceStatus): IContainerResourcePromise; + withNestedConfig(config: TestNestedDto): IContainerResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerResourcePromise; + testWaitFor(dependency: IHandleReference): IContainerResourcePromise; + withDependency(dependency: IHandleReference): IContainerResourcePromise; + withEndpoints(endpoints: string[]): IContainerResourcePromise; + withEnvironmentVariables(variables: Record): IContainerResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerResourcePromise; } // ============================================================================ @@ -6722,7 +7850,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -6732,7 +7860,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new ContainerResource(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + withBuildArg(name: string, value: IParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new ContainerResource(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + withBuildSecret(name: string, value: IParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); } @@ -7085,41 +8213,11 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => 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( @@ -7130,12 +8228,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -7145,12 +8243,27 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -7160,12 +8273,12 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -7175,7 +8288,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -7210,17 +8323,37 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - 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( + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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 ); @@ -7228,7 +8361,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -7261,12 +8394,12 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -7276,7 +8409,7 @@ export class ContainerResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -7401,7 +8534,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -7416,10 +8549,30 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -7438,7 +8591,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -7449,7 +8602,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -7489,7 +8642,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } @@ -7509,22 +8662,22 @@ export class ContainerResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ContainerResourcePromise { + waitFor(dependency: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -7534,27 +8687,27 @@ export class ContainerResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ContainerResourcePromise { + waitForStart(dependency: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -7564,7 +8717,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ContainerResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise { const exitCode = options?.exitCode; return new ContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -7637,7 +8790,7 @@ export class ContainerResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -7653,7 +8806,7 @@ export class ContainerResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ContainerResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { const commandOptions = options?.commandOptions; return new ContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -7689,11 +8842,11 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 ContainerResource(result, this._client); @@ -7721,32 +8874,32 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { + withParentRelationship(parent: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerResourcePromise { + withChildRelationship(child: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._withChildRelationshipInternal(child)); } @@ -7842,7 +8995,7 @@ export class ContainerResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -7861,7 +9014,7 @@ export class ContainerResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -7870,7 +9023,27 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -7885,7 +9058,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -7918,7 +9091,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -7933,12 +9106,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -7953,12 +9126,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -7973,12 +9146,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -7993,12 +9166,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -8013,7 +9186,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); } @@ -8052,7 +9225,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -8067,7 +9240,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -8117,7 +9290,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -8169,7 +9342,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -8184,12 +9357,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -8199,12 +9372,12 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -8214,7 +9387,7 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -8263,138 +9436,10 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ContainerResourcePromise { - return new ContainerResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ContainerResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ContainerResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerResourcePromise { - return new ContainerResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - } /** @@ -8413,7 +9458,7 @@ export class ContainerResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + withContainerRegistry(registry: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } @@ -8478,12 +9523,12 @@ export class ContainerResourcePromise implements PromiseLike } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + withBuildArg(name: string, value: IParameterResource): 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 { + withBuildSecret(name: string, value: IParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } @@ -8527,33 +9572,28 @@ export class ContainerResourcePromise implements PromiseLike 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: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 { + withEnvironmentParameter(name: string, parameter: IParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ContainerResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } @@ -8563,12 +9603,17 @@ export class ContainerResourcePromise implements PromiseLike } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -8578,12 +9623,12 @@ export class ContainerResourcePromise implements PromiseLike } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): ContainerResourcePromise { + withReferenceExternalService(externalService: IExternalServiceResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): ContainerResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -8608,7 +9653,7 @@ export class ContainerResourcePromise implements PromiseLike } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -8618,17 +9663,22 @@ export class ContainerResourcePromise implements PromiseLike } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -8638,7 +9688,7 @@ export class ContainerResourcePromise implements PromiseLike } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } @@ -8648,22 +9698,22 @@ export class ContainerResourcePromise implements PromiseLike } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ContainerResourcePromise { + waitFor(dependency: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ContainerResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ContainerResourcePromise { + waitForStart(dependency: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ContainerResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -8673,7 +9723,7 @@ export class ContainerResourcePromise implements PromiseLike } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ContainerResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } @@ -8688,7 +9738,7 @@ export class ContainerResourcePromise implements PromiseLike } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -8713,12 +9763,12 @@ export class ContainerResourcePromise implements PromiseLike } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { + withParentRelationship(parent: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerResourcePromise { + withChildRelationship(child: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -8748,12 +9798,17 @@ export class ContainerResourcePromise implements PromiseLike } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -8768,27 +9823,27 @@ export class ContainerResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -8803,7 +9858,7 @@ export class ContainerResourcePromise implements PromiseLike } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ContainerResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -8838,17 +9893,17 @@ export class ContainerResourcePromise implements PromiseLike } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ContainerResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ContainerResourcePromise { + testWaitFor(dependency: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ContainerResourcePromise { + withDependency(dependency: IHandleReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -8863,50 +9918,179 @@ export class ContainerResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// ICSharpAppResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface ICSharpAppResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): ICSharpAppResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; + withOtlpExporter(): ICSharpAppResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; + withReplicas(replicas: number): ICSharpAppResourcePromise; + disableForwardedHeaders(): ICSharpAppResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ICSharpAppResourcePromise; + withArgs(args: string[]): ICSharpAppResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ICSharpAppResourcePromise; + withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; + withExternalHttpEndpoints(): ICSharpAppResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ICSharpAppResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; + publishWithContainerFiles(source: IHandleReference, destinationPath: string): ICSharpAppResourcePromise; + excludeFromManifest(): ICSharpAppResourcePromise; + waitFor(dependency: IHandleReference): ICSharpAppResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + waitForStart(dependency: IHandleReference): ICSharpAppResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + withExplicitStart(): ICSharpAppResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; + withHealthCheck(key: string): ICSharpAppResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; + withoutHttpsCertificate(): ICSharpAppResourcePromise; + withParentRelationship(parent: IHandleReference): ICSharpAppResourcePromise; + withChildRelationship(child: IHandleReference): ICSharpAppResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; + excludeFromMcp(): ICSharpAppResourcePromise; + withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; + withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ICSharpAppResourcePromise; + withConfig(config: TestConfigDto): ICSharpAppResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ICSharpAppResourcePromise; + withCreatedAt(createdAt: string): ICSharpAppResourcePromise; + withModifiedAt(modifiedAt: string): ICSharpAppResourcePromise; + withCorrelationId(correlationId: string): ICSharpAppResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ICSharpAppResourcePromise; + withStatus(status: TestResourceStatus): ICSharpAppResourcePromise; + withNestedConfig(config: TestNestedDto): ICSharpAppResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ICSharpAppResourcePromise; + testWaitFor(dependency: IHandleReference): ICSharpAppResourcePromise; + withDependency(dependency: IHandleReference): ICSharpAppResourcePromise; + withEndpoints(endpoints: string[]): ICSharpAppResourcePromise; + withEnvironmentVariables(variables: Record): ICSharpAppResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ICSharpAppResourcePromise; +} +export interface ICSharpAppResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): ICSharpAppResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; + withOtlpExporter(): ICSharpAppResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; + withReplicas(replicas: number): ICSharpAppResourcePromise; + disableForwardedHeaders(): ICSharpAppResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ICSharpAppResourcePromise; + withArgs(args: string[]): ICSharpAppResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ICSharpAppResourcePromise; + withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; + withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; + withExternalHttpEndpoints(): ICSharpAppResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ICSharpAppResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; + publishWithContainerFiles(source: IHandleReference, destinationPath: string): ICSharpAppResourcePromise; + excludeFromManifest(): ICSharpAppResourcePromise; + waitFor(dependency: IHandleReference): ICSharpAppResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + waitForStart(dependency: IHandleReference): ICSharpAppResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; + withExplicitStart(): ICSharpAppResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; + withHealthCheck(key: string): ICSharpAppResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; + withoutHttpsCertificate(): ICSharpAppResourcePromise; + withParentRelationship(parent: IHandleReference): ICSharpAppResourcePromise; + withChildRelationship(child: IHandleReference): ICSharpAppResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; + excludeFromMcp(): ICSharpAppResourcePromise; + withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; + withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ICSharpAppResourcePromise; + withConfig(config: TestConfigDto): ICSharpAppResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ICSharpAppResourcePromise; + withCreatedAt(createdAt: string): ICSharpAppResourcePromise; + withModifiedAt(modifiedAt: string): ICSharpAppResourcePromise; + withCorrelationId(correlationId: string): ICSharpAppResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ICSharpAppResourcePromise; + withStatus(status: TestResourceStatus): ICSharpAppResourcePromise; + withNestedConfig(config: TestNestedDto): ICSharpAppResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ICSharpAppResourcePromise; + testWaitFor(dependency: IHandleReference): ICSharpAppResourcePromise; + withDependency(dependency: IHandleReference): ICSharpAppResourcePromise; + withEndpoints(endpoints: string[]): ICSharpAppResourcePromise; + withEnvironmentVariables(variables: Record): ICSharpAppResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ICSharpAppResourcePromise; } // ============================================================================ @@ -8919,7 +10103,7 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -8929,7 +10113,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _publishAsDockerFileInternal(configure?: (obj: IContainerResource) => Promise): Promise { const configureId = configure ? registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; const obj = new ContainerResource(objHandle, this._client); @@ -9071,41 +10255,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: IEnvironmentCallbackContext) => 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( @@ -9116,12 +10270,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -9131,12 +10285,27 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -9146,12 +10315,12 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -9161,7 +10330,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -9196,12 +10365,32 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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; @@ -9214,7 +10403,7 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -9247,12 +10436,12 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -9262,7 +10451,7 @@ export class CSharpAppResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -9387,7 +10576,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -9402,10 +10591,30 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -9424,7 +10633,7 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -9435,7 +10644,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -9475,22 +10684,22 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { + private async _publishWithContainerFilesInternal(source: IHandleReference, 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 CSharpAppResource(result, this._client); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): CSharpAppResourcePromise { + publishWithContainerFiles(source: IHandleReference, destinationPath: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); } @@ -9510,22 +10719,22 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + waitFor(dependency: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -9535,27 +10744,27 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + waitForStart(dependency: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -9565,7 +10774,7 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise { const exitCode = options?.exitCode; return new CSharpAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -9638,7 +10847,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -9654,7 +10863,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { const commandOptions = options?.commandOptions; return new CSharpAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -9690,11 +10899,11 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 CSharpAppResource(result, this._client); @@ -9722,32 +10931,32 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { + withParentRelationship(parent: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): CSharpAppResourcePromise { + withChildRelationship(child: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withChildRelationshipInternal(child)); } @@ -9843,7 +11052,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -9862,7 +11071,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -9871,7 +11080,27 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -9886,7 +11115,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -9900,7 +11129,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -9915,12 +11144,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -9935,12 +11164,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -9955,12 +11184,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -9975,12 +11204,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -9995,7 +11224,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); } @@ -10034,7 +11263,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -10049,7 +11278,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -10099,7 +11328,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -10151,7 +11380,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -10166,12 +11395,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -10181,12 +11410,12 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -10196,7 +11425,7 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -10245,163 +11474,35 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } +} + +/** + * Thenable wrapper for CSharpAppResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class CSharpAppResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds a label to the resource */ - withMergeLabel(label: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withMergeLabelInternal(label)); + then( + onfulfilled?: ((value: CSharpAppResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new CSharpAppResource(result, this._client); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IHandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): CSharpAppResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new CSharpAppResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): CSharpAppResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new CSharpAppResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - -} - -/** - * Thenable wrapper for CSharpAppResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class CSharpAppResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: CSharpAppResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Configures an MCP server endpoint on the resource */ @@ -10439,33 +11540,28 @@ 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: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 { + withEnvironmentParameter(name: string, parameter: IParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): CSharpAppResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } @@ -10475,12 +11571,17 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -10490,12 +11591,12 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): CSharpAppResourcePromise { + withReferenceExternalService(externalService: IExternalServiceResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): CSharpAppResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -10520,7 +11621,7 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -10530,17 +11631,22 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -10550,12 +11656,12 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): CSharpAppResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): CSharpAppResourcePromise { + publishWithContainerFiles(source: IHandleReference, destinationPath: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); } @@ -10565,22 +11671,22 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + waitFor(dependency: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + waitForStart(dependency: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -10590,7 +11696,7 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } @@ -10605,7 +11711,7 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -10630,12 +11736,12 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { + withParentRelationship(parent: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): CSharpAppResourcePromise { + withChildRelationship(child: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -10665,12 +11771,17 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -10680,27 +11791,27 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -10715,7 +11826,7 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): CSharpAppResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -10750,17 +11861,17 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): CSharpAppResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + testWaitFor(dependency: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): CSharpAppResourcePromise { + withDependency(dependency: IHandleReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -10775,50 +11886,191 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): CSharpAppResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IDotnetToolResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IDotnetToolResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IDotnetToolResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; + withToolPackage(packageId: string): IDotnetToolResourcePromise; + withToolVersion(version: string): IDotnetToolResourcePromise; + withToolPrerelease(): IDotnetToolResourcePromise; + withToolSource(source: string): IDotnetToolResourcePromise; + withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; + withToolIgnoreFailedSources(): IDotnetToolResourcePromise; + publishAsDockerFile(): IDotnetToolResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; + withExecutableCommand(command: string): IDotnetToolResourcePromise; + withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; + withOtlpExporter(): IDotnetToolResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IDotnetToolResourcePromise; + withArgs(args: string[]): IDotnetToolResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IDotnetToolResourcePromise; + withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; + withExternalHttpEndpoints(): IDotnetToolResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IDotnetToolResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; + excludeFromManifest(): IDotnetToolResourcePromise; + waitFor(dependency: IHandleReference): IDotnetToolResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + waitForStart(dependency: IHandleReference): IDotnetToolResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + withExplicitStart(): IDotnetToolResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; + withHealthCheck(key: string): IDotnetToolResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; + withoutHttpsCertificate(): IDotnetToolResourcePromise; + withParentRelationship(parent: IHandleReference): IDotnetToolResourcePromise; + withChildRelationship(child: IHandleReference): IDotnetToolResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; + excludeFromMcp(): IDotnetToolResourcePromise; + withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; + withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IDotnetToolResourcePromise; + withConfig(config: TestConfigDto): IDotnetToolResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IDotnetToolResourcePromise; + withCreatedAt(createdAt: string): IDotnetToolResourcePromise; + withModifiedAt(modifiedAt: string): IDotnetToolResourcePromise; + withCorrelationId(correlationId: string): IDotnetToolResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IDotnetToolResourcePromise; + withStatus(status: TestResourceStatus): IDotnetToolResourcePromise; + withNestedConfig(config: TestNestedDto): IDotnetToolResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IDotnetToolResourcePromise; + testWaitFor(dependency: IHandleReference): IDotnetToolResourcePromise; + withDependency(dependency: IHandleReference): IDotnetToolResourcePromise; + withEndpoints(endpoints: string[]): IDotnetToolResourcePromise; + withEnvironmentVariables(variables: Record): IDotnetToolResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IDotnetToolResourcePromise; +} +export interface IDotnetToolResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IDotnetToolResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; + withToolPackage(packageId: string): IDotnetToolResourcePromise; + withToolVersion(version: string): IDotnetToolResourcePromise; + withToolPrerelease(): IDotnetToolResourcePromise; + withToolSource(source: string): IDotnetToolResourcePromise; + withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; + withToolIgnoreFailedSources(): IDotnetToolResourcePromise; + publishAsDockerFile(): IDotnetToolResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; + withExecutableCommand(command: string): IDotnetToolResourcePromise; + withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; + withOtlpExporter(): IDotnetToolResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IDotnetToolResourcePromise; + withArgs(args: string[]): IDotnetToolResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IDotnetToolResourcePromise; + withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; + withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; + withExternalHttpEndpoints(): IDotnetToolResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IDotnetToolResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; + excludeFromManifest(): IDotnetToolResourcePromise; + waitFor(dependency: IHandleReference): IDotnetToolResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + waitForStart(dependency: IHandleReference): IDotnetToolResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; + withExplicitStart(): IDotnetToolResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; + withHealthCheck(key: string): IDotnetToolResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; + withoutHttpsCertificate(): IDotnetToolResourcePromise; + withParentRelationship(parent: IHandleReference): IDotnetToolResourcePromise; + withChildRelationship(child: IHandleReference): IDotnetToolResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; + excludeFromMcp(): IDotnetToolResourcePromise; + withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; + withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IDotnetToolResourcePromise; + withConfig(config: TestConfigDto): IDotnetToolResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IDotnetToolResourcePromise; + withCreatedAt(createdAt: string): IDotnetToolResourcePromise; + withModifiedAt(modifiedAt: string): IDotnetToolResourcePromise; + withCorrelationId(correlationId: string): IDotnetToolResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IDotnetToolResourcePromise; + withStatus(status: TestResourceStatus): IDotnetToolResourcePromise; + withNestedConfig(config: TestNestedDto): IDotnetToolResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IDotnetToolResourcePromise; + testWaitFor(dependency: IHandleReference): IDotnetToolResourcePromise; + withDependency(dependency: IHandleReference): IDotnetToolResourcePromise; + withEndpoints(endpoints: string[]): IDotnetToolResourcePromise; + withEnvironmentVariables(variables: Record): IDotnetToolResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IDotnetToolResourcePromise; } // ============================================================================ @@ -10831,7 +12083,7 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -10841,7 +12093,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: IContainerResource) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; const obj = new ContainerResource(objHandle, this._client); @@ -10985,7 +12237,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); } @@ -11086,41 +12338,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: IEnvironmentCallbackContext) => 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( @@ -11131,12 +12353,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -11146,12 +12368,27 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -11161,12 +12398,12 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -11176,7 +12413,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -11211,12 +12448,32 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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; @@ -11229,7 +12486,7 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -11262,12 +12519,12 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -11277,7 +12534,7 @@ export class DotnetToolResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -11402,7 +12659,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -11417,10 +12674,30 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -11439,7 +12716,7 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -11450,7 +12727,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -11490,7 +12767,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } @@ -11510,22 +12787,22 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + waitFor(dependency: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -11535,27 +12812,27 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + waitForStart(dependency: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -11565,7 +12842,7 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): DotnetToolResourcePromise { const exitCode = options?.exitCode; return new DotnetToolResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -11638,7 +12915,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -11654,7 +12931,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { const commandOptions = options?.commandOptions; return new DotnetToolResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -11690,11 +12967,11 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 DotnetToolResource(result, this._client); @@ -11722,32 +12999,32 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { + withParentRelationship(parent: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): DotnetToolResourcePromise { + withChildRelationship(child: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withChildRelationshipInternal(child)); } @@ -11843,7 +13120,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -11862,7 +13139,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -11871,7 +13148,27 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -11886,7 +13183,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -11900,7 +13197,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -11915,12 +13212,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -11935,12 +13232,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -11955,12 +13252,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -11975,12 +13272,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -11995,7 +13292,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); } @@ -12034,7 +13331,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -12049,7 +13346,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -12099,7 +13396,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -12151,7 +13448,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -12166,12 +13463,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -12181,12 +13478,12 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -12196,7 +13493,7 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -12245,193 +13542,65 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withMergeLabelInternal(label)); - } +} - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } +/** + * Thenable wrapper for DotnetToolResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class DotnetToolResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); + then( + onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new DotnetToolResource(result, this._client); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: IHandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withMergeEndpointInternal(endpointName, port)); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new DotnetToolResource(result, this._client); + /** Sets the tool package ID */ + withToolPackage(packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPackage(packageId))); } - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + /** Sets the tool version */ + withToolVersion(version: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolVersion(version))); } - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new DotnetToolResource(result, this._client); + /** Allows prerelease tool versions */ + withToolPrerelease(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPrerelease())); } - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): DotnetToolResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new DotnetToolResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + /** Adds a NuGet source for the tool */ + withToolSource(source: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolSource(source))); } - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new DotnetToolResource(result, this._client); + /** Ignores existing NuGet feeds */ + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreExistingFeeds())); } - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): DotnetToolResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new DotnetToolResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - -} - -/** - * Thenable wrapper for DotnetToolResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class DotnetToolResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Sets the tool package ID */ - withToolPackage(packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPackage(packageId))); - } - - /** Sets the tool version */ - withToolVersion(version: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolVersion(version))); - } - - /** Allows prerelease tool versions */ - withToolPrerelease(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPrerelease())); - } - - /** Adds a NuGet source for the tool */ - withToolSource(source: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolSource(source))); - } - - /** Ignores existing NuGet feeds */ - withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreExistingFeeds())); - } - - /** Ignores failed NuGet sources */ - withToolIgnoreFailedSources(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreFailedSources())); + /** Ignores failed NuGet sources */ + withToolIgnoreFailedSources(): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreFailedSources())); } /** Publishes the executable as a Docker container */ @@ -12440,7 +13609,7 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); } @@ -12474,33 +13643,28 @@ 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: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 { + withEnvironmentParameter(name: string, parameter: IParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): DotnetToolResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } @@ -12510,12 +13674,17 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -12525,12 +13694,12 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): DotnetToolResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -12555,7 +13724,7 @@ export class DotnetToolResourcePromise implements PromiseLike { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -12565,17 +13734,22 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -12585,7 +13759,7 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } @@ -12595,22 +13769,22 @@ export class DotnetToolResourcePromise implements PromiseLike obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + waitForStart(dependency: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -12620,7 +13794,7 @@ export class DotnetToolResourcePromise implements PromiseLike obj.waitForCompletion(dependency, options))); } @@ -12635,7 +13809,7 @@ export class DotnetToolResourcePromise implements PromiseLike Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -12660,12 +13834,12 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): DotnetToolResourcePromise { + withChildRelationship(child: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -12695,12 +13869,17 @@ export class DotnetToolResourcePromise implements PromiseLike Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -12710,27 +13889,27 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -12745,7 +13924,7 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -12780,17 +13959,17 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + testWaitFor(dependency: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): DotnetToolResourcePromise { + withDependency(dependency: IHandleReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -12805,50 +13984,179 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IExecutableResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IExecutableResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IExecutableResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; + publishAsDockerFile(): IExecutableResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; + withExecutableCommand(command: string): IExecutableResourcePromise; + withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; + withOtlpExporter(): IExecutableResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IExecutableResourcePromise; + withArgs(args: string[]): IExecutableResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IExecutableResourcePromise; + withReferenceUri(name: string, uri: string): IExecutableResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; + withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; + withExternalHttpEndpoints(): IExecutableResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IExecutableResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; + excludeFromManifest(): IExecutableResourcePromise; + waitFor(dependency: IHandleReference): IExecutableResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; + waitForStart(dependency: IHandleReference): IExecutableResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; + withExplicitStart(): IExecutableResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IExecutableResourcePromise; + withHealthCheck(key: string): IExecutableResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; + withoutHttpsCertificate(): IExecutableResourcePromise; + withParentRelationship(parent: IHandleReference): IExecutableResourcePromise; + withChildRelationship(child: IHandleReference): IExecutableResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; + excludeFromMcp(): IExecutableResourcePromise; + withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; + withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IExecutableResourcePromise; + withConfig(config: TestConfigDto): IExecutableResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IExecutableResourcePromise; + withCreatedAt(createdAt: string): IExecutableResourcePromise; + withModifiedAt(modifiedAt: string): IExecutableResourcePromise; + withCorrelationId(correlationId: string): IExecutableResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IExecutableResourcePromise; + withStatus(status: TestResourceStatus): IExecutableResourcePromise; + withNestedConfig(config: TestNestedDto): IExecutableResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IExecutableResourcePromise; + testWaitFor(dependency: IHandleReference): IExecutableResourcePromise; + withDependency(dependency: IHandleReference): IExecutableResourcePromise; + withEndpoints(endpoints: string[]): IExecutableResourcePromise; + withEnvironmentVariables(variables: Record): IExecutableResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExecutableResourcePromise; +} +export interface IExecutableResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IExecutableResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; + publishAsDockerFile(): IExecutableResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; + withExecutableCommand(command: string): IExecutableResourcePromise; + withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; + withOtlpExporter(): IExecutableResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IExecutableResourcePromise; + withArgs(args: string[]): IExecutableResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IExecutableResourcePromise; + withReferenceUri(name: string, uri: string): IExecutableResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; + withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; + withExternalHttpEndpoints(): IExecutableResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IExecutableResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; + excludeFromManifest(): IExecutableResourcePromise; + waitFor(dependency: IHandleReference): IExecutableResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; + waitForStart(dependency: IHandleReference): IExecutableResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; + withExplicitStart(): IExecutableResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IExecutableResourcePromise; + withHealthCheck(key: string): IExecutableResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; + withoutHttpsCertificate(): IExecutableResourcePromise; + withParentRelationship(parent: IHandleReference): IExecutableResourcePromise; + withChildRelationship(child: IHandleReference): IExecutableResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; + excludeFromMcp(): IExecutableResourcePromise; + withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; + withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IExecutableResourcePromise; + withConfig(config: TestConfigDto): IExecutableResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IExecutableResourcePromise; + withCreatedAt(createdAt: string): IExecutableResourcePromise; + withModifiedAt(modifiedAt: string): IExecutableResourcePromise; + withCorrelationId(correlationId: string): IExecutableResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IExecutableResourcePromise; + withStatus(status: TestResourceStatus): IExecutableResourcePromise; + withNestedConfig(config: TestNestedDto): IExecutableResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IExecutableResourcePromise; + testWaitFor(dependency: IHandleReference): IExecutableResourcePromise; + withDependency(dependency: IHandleReference): IExecutableResourcePromise; + withEndpoints(endpoints: string[]): IExecutableResourcePromise; + withEnvironmentVariables(variables: Record): IExecutableResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExecutableResourcePromise; } // ============================================================================ @@ -12861,7 +14169,7 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -12871,7 +14179,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: IContainerResource) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; const obj = new ContainerResource(objHandle, this._client); @@ -12925,7 +14233,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); } @@ -13026,41 +14334,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: IEnvironmentCallbackContext) => 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( @@ -13071,12 +14349,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -13086,12 +14364,27 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -13101,12 +14394,12 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -13116,7 +14409,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -13151,12 +14444,32 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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; @@ -13169,7 +14482,7 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -13202,12 +14515,12 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -13217,7 +14530,7 @@ export class ExecutableResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -13342,7 +14655,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -13357,10 +14670,30 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -13379,7 +14712,7 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -13390,7 +14723,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -13430,7 +14763,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } @@ -13450,22 +14783,22 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ExecutableResourcePromise { + waitFor(dependency: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -13475,27 +14808,27 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ExecutableResourcePromise { + waitForStart(dependency: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -13505,7 +14838,7 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ExecutableResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ExecutableResourcePromise { const exitCode = options?.exitCode; return new ExecutableResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -13578,7 +14911,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -13594,7 +14927,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ExecutableResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { const commandOptions = options?.commandOptions; return new ExecutableResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -13630,11 +14963,11 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 ExecutableResource(result, this._client); @@ -13662,32 +14995,32 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { + withParentRelationship(parent: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ExecutableResourcePromise { + withChildRelationship(child: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withChildRelationshipInternal(child)); } @@ -13783,7 +15116,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -13802,7 +15135,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -13811,7 +15144,27 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -13826,7 +15179,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -13840,7 +15193,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -13855,12 +15208,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -13875,12 +15228,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -13895,12 +15248,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -13915,12 +15268,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -13935,7 +15288,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); } @@ -13974,7 +15327,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -13989,7 +15342,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -14039,7 +15392,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -14091,7 +15444,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -14106,12 +15459,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -14121,12 +15474,12 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -14136,7 +15489,7 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -14185,138 +15538,10 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExecutableResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ExecutableResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExecutableResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ExecutableResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - } /** @@ -14335,7 +15560,7 @@ export class ExecutableResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); } @@ -14350,7 +15575,7 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); } @@ -14384,33 +15609,28 @@ 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: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 { + withEnvironmentParameter(name: string, parameter: IParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ExecutableResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } @@ -14420,12 +15640,17 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -14435,12 +15660,12 @@ export class ExecutableResourcePromise implements PromiseLike obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): ExecutableResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -14465,7 +15690,7 @@ export class ExecutableResourcePromise implements PromiseLike { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -14475,17 +15700,22 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -14495,7 +15725,7 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } @@ -14505,22 +15735,22 @@ export class ExecutableResourcePromise implements PromiseLike obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ExecutableResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ExecutableResourcePromise { + waitForStart(dependency: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ExecutableResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -14530,7 +15760,7 @@ export class ExecutableResourcePromise implements PromiseLike obj.waitForCompletion(dependency, options))); } @@ -14545,7 +15775,7 @@ export class ExecutableResourcePromise implements PromiseLike Promise, options?: WithCommandOptions): ExecutableResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -14570,12 +15800,12 @@ export class ExecutableResourcePromise implements PromiseLike obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ExecutableResourcePromise { + withChildRelationship(child: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -14605,12 +15835,17 @@ export class ExecutableResourcePromise implements PromiseLike Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -14620,27 +15855,27 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -14655,7 +15890,7 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -14690,17 +15925,17 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ExecutableResourcePromise { + testWaitFor(dependency: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ExecutableResourcePromise { + withDependency(dependency: IHandleReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -14715,50 +15950,97 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IExternalServiceResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IExternalServiceResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IExternalServiceResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; + excludeFromManifest(): IExternalServiceResourcePromise; + withExplicitStart(): IExternalServiceResourcePromise; + withHealthCheck(key: string): IExternalServiceResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; + withParentRelationship(parent: IHandleReference): IExternalServiceResourcePromise; + withChildRelationship(child: IHandleReference): IExternalServiceResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; + excludeFromMcp(): IExternalServiceResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IExternalServiceResourcePromise; + withConfig(config: TestConfigDto): IExternalServiceResourcePromise; + withCreatedAt(createdAt: string): IExternalServiceResourcePromise; + withModifiedAt(modifiedAt: string): IExternalServiceResourcePromise; + withCorrelationId(correlationId: string): IExternalServiceResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IExternalServiceResourcePromise; + withStatus(status: TestResourceStatus): IExternalServiceResourcePromise; + withNestedConfig(config: TestNestedDto): IExternalServiceResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IExternalServiceResourcePromise; + testWaitFor(dependency: IHandleReference): IExternalServiceResourcePromise; + withDependency(dependency: IHandleReference): IExternalServiceResourcePromise; + withEndpoints(endpoints: string[]): IExternalServiceResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExternalServiceResourcePromise; +} +export interface IExternalServiceResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IExternalServiceResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; + excludeFromManifest(): IExternalServiceResourcePromise; + withExplicitStart(): IExternalServiceResourcePromise; + withHealthCheck(key: string): IExternalServiceResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; + withParentRelationship(parent: IHandleReference): IExternalServiceResourcePromise; + withChildRelationship(child: IHandleReference): IExternalServiceResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; + excludeFromMcp(): IExternalServiceResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IExternalServiceResourcePromise; + withConfig(config: TestConfigDto): IExternalServiceResourcePromise; + withCreatedAt(createdAt: string): IExternalServiceResourcePromise; + withModifiedAt(modifiedAt: string): IExternalServiceResourcePromise; + withCorrelationId(correlationId: string): IExternalServiceResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IExternalServiceResourcePromise; + withStatus(status: TestResourceStatus): IExternalServiceResourcePromise; + withNestedConfig(config: TestNestedDto): IExternalServiceResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IExternalServiceResourcePromise; + testWaitFor(dependency: IHandleReference): IExternalServiceResourcePromise; + withDependency(dependency: IHandleReference): IExternalServiceResourcePromise; + withEndpoints(endpoints: string[]): IExternalServiceResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExternalServiceResourcePromise; } // ============================================================================ @@ -14771,7 +16053,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -14781,7 +16063,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -14856,10 +16138,30 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -14878,7 +16180,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -14889,7 +16191,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -14975,38 +16277,38 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { const commandOptions = options?.commandOptions; return new ExternalServiceResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { + withParentRelationship(parent: IHandleReference): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ExternalServiceResourcePromise { + withChildRelationship(child: IHandleReference): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._withChildRelationshipInternal(child)); } @@ -15043,7 +16345,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -15062,7 +16364,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -15071,7 +16373,27 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -15086,7 +16408,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -15100,7 +16422,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -15115,12 +16437,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -15135,12 +16457,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -15155,12 +16477,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -15175,7 +16497,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); } @@ -15259,7 +16581,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -15311,7 +16633,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -15326,12 +16648,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -15341,12 +16663,12 @@ export class ExternalServiceResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -15356,7 +16678,7 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -15390,138 +16712,10 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExternalServiceResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ExternalServiceResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExternalServiceResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ExternalServiceResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - } /** @@ -15540,7 +16734,7 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); } @@ -15560,17 +16754,22 @@ export class ExternalServiceResourcePromise implements PromiseLike Promise): ExternalServiceResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -15595,17 +16794,17 @@ export class ExternalServiceResourcePromise implements PromiseLike Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { + withParentRelationship(parent: IHandleReference): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ExternalServiceResourcePromise { + withChildRelationship(child: IHandleReference): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -15620,12 +16819,17 @@ export class ExternalServiceResourcePromise implements PromiseLike Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -15635,22 +16839,22 @@ export class ExternalServiceResourcePromise implements PromiseLike Promise): ExternalServiceResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -15695,17 +16899,17 @@ export class ExternalServiceResourcePromise implements PromiseLike Promise): ExternalServiceResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ExternalServiceResourcePromise { + testWaitFor(dependency: IHandleReference): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ExternalServiceResourcePromise { + withDependency(dependency: IHandleReference): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -15715,50 +16919,97 @@ export class ExternalServiceResourcePromise implements PromiseLike Promise): ExternalServiceResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IParameterResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IParameterResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IParameterResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; + withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; + excludeFromManifest(): IParameterResourcePromise; + withExplicitStart(): IParameterResourcePromise; + withHealthCheck(key: string): IParameterResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; + withParentRelationship(parent: IHandleReference): IParameterResourcePromise; + withChildRelationship(child: IHandleReference): IParameterResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; + excludeFromMcp(): IParameterResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IParameterResourcePromise; + withConfig(config: TestConfigDto): IParameterResourcePromise; + withCreatedAt(createdAt: string): IParameterResourcePromise; + withModifiedAt(modifiedAt: string): IParameterResourcePromise; + withCorrelationId(correlationId: string): IParameterResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IParameterResourcePromise; + withStatus(status: TestResourceStatus): IParameterResourcePromise; + withNestedConfig(config: TestNestedDto): IParameterResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IParameterResourcePromise; + testWaitFor(dependency: IHandleReference): IParameterResourcePromise; + withDependency(dependency: IHandleReference): IParameterResourcePromise; + withEndpoints(endpoints: string[]): IParameterResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IParameterResourcePromise; +} +export interface IParameterResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IParameterResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; + withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; + excludeFromManifest(): IParameterResourcePromise; + withExplicitStart(): IParameterResourcePromise; + withHealthCheck(key: string): IParameterResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; + withParentRelationship(parent: IHandleReference): IParameterResourcePromise; + withChildRelationship(child: IHandleReference): IParameterResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; + excludeFromMcp(): IParameterResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IParameterResourcePromise; + withConfig(config: TestConfigDto): IParameterResourcePromise; + withCreatedAt(createdAt: string): IParameterResourcePromise; + withModifiedAt(modifiedAt: string): IParameterResourcePromise; + withCorrelationId(correlationId: string): IParameterResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IParameterResourcePromise; + withStatus(status: TestResourceStatus): IParameterResourcePromise; + withNestedConfig(config: TestNestedDto): IParameterResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IParameterResourcePromise; + testWaitFor(dependency: IHandleReference): IParameterResourcePromise; + withDependency(dependency: IHandleReference): IParameterResourcePromise; + withEndpoints(endpoints: string[]): IParameterResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IParameterResourcePromise; } // ============================================================================ @@ -15771,7 +17022,7 @@ export class ParameterResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -15781,7 +17032,7 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -15854,10 +17105,30 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -15876,7 +17147,7 @@ export class ParameterResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -15887,7 +17158,7 @@ export class ParameterResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -15973,38 +17244,38 @@ export class ParameterResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ParameterResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { const commandOptions = options?.commandOptions; return new ParameterResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { + withParentRelationship(parent: IHandleReference): ParameterResourcePromise { return new ParameterResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ParameterResourcePromise { + withChildRelationship(child: IHandleReference): ParameterResourcePromise { return new ParameterResourcePromise(this._withChildRelationshipInternal(child)); } @@ -16041,7 +17312,7 @@ export class ParameterResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -16060,7 +17331,7 @@ export class ParameterResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -16069,7 +17340,27 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -16084,7 +17375,7 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -16098,7 +17389,7 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -16113,12 +17404,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -16133,12 +17424,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -16153,12 +17444,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -16173,7 +17464,7 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); } @@ -16257,7 +17548,7 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -16309,7 +17600,7 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -16324,12 +17615,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -16339,12 +17630,12 @@ export class ParameterResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -16354,7 +17645,7 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -16388,138 +17679,10 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ParameterResourcePromise { - return new ParameterResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ParameterResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ParameterResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ParameterResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ParameterResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ParameterResourcePromise { - return new ParameterResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - } /** @@ -16538,7 +17701,7 @@ export class ParameterResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ParameterResourcePromise { + withContainerRegistry(registry: IHandleReference): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } @@ -16558,17 +17721,22 @@ export class ParameterResourcePromise implements PromiseLike } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -16593,17 +17761,17 @@ export class ParameterResourcePromise implements PromiseLike } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { + withParentRelationship(parent: IHandleReference): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ParameterResourcePromise { + withChildRelationship(child: IHandleReference): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -16618,12 +17786,17 @@ export class ParameterResourcePromise implements PromiseLike } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -16633,22 +17806,22 @@ export class ParameterResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -16693,17 +17866,17 @@ export class ParameterResourcePromise implements PromiseLike } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ParameterResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ParameterResourcePromise { + testWaitFor(dependency: IHandleReference): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ParameterResourcePromise { + withDependency(dependency: IHandleReference): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -16713,50 +17886,179 @@ export class ParameterResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ParameterResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IProjectResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IProjectResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IProjectResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; + withOtlpExporter(): IProjectResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; + withReplicas(replicas: number): IProjectResourcePromise; + disableForwardedHeaders(): IProjectResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IProjectResourcePromise; + withArgs(args: string[]): IProjectResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IProjectResourcePromise; + withReferenceUri(name: string, uri: string): IProjectResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; + withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; + withExternalHttpEndpoints(): IProjectResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IProjectResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; + publishWithContainerFiles(source: IHandleReference, destinationPath: string): IProjectResourcePromise; + excludeFromManifest(): IProjectResourcePromise; + waitFor(dependency: IHandleReference): IProjectResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; + waitForStart(dependency: IHandleReference): IProjectResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; + withExplicitStart(): IProjectResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IProjectResourcePromise; + withHealthCheck(key: string): IProjectResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; + withoutHttpsCertificate(): IProjectResourcePromise; + withParentRelationship(parent: IHandleReference): IProjectResourcePromise; + withChildRelationship(child: IHandleReference): IProjectResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; + excludeFromMcp(): IProjectResourcePromise; + withRemoteImageName(remoteImageName: string): IProjectResourcePromise; + withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IProjectResourcePromise; + withConfig(config: TestConfigDto): IProjectResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IProjectResourcePromise; + withCreatedAt(createdAt: string): IProjectResourcePromise; + withModifiedAt(modifiedAt: string): IProjectResourcePromise; + withCorrelationId(correlationId: string): IProjectResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IProjectResourcePromise; + withStatus(status: TestResourceStatus): IProjectResourcePromise; + withNestedConfig(config: TestNestedDto): IProjectResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IProjectResourcePromise; + testWaitFor(dependency: IHandleReference): IProjectResourcePromise; + withDependency(dependency: IHandleReference): IProjectResourcePromise; + withEndpoints(endpoints: string[]): IProjectResourcePromise; + withEnvironmentVariables(variables: Record): IProjectResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IProjectResourcePromise; +} +export interface IProjectResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IProjectResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; + withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; + withOtlpExporter(): IProjectResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; + withReplicas(replicas: number): IProjectResourcePromise; + disableForwardedHeaders(): IProjectResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IProjectResourcePromise; + withArgs(args: string[]): IProjectResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IProjectResourcePromise; + withReferenceUri(name: string, uri: string): IProjectResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; + withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; + withExternalHttpEndpoints(): IProjectResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IProjectResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; + publishWithContainerFiles(source: IHandleReference, destinationPath: string): IProjectResourcePromise; + excludeFromManifest(): IProjectResourcePromise; + waitFor(dependency: IHandleReference): IProjectResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; + waitForStart(dependency: IHandleReference): IProjectResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; + withExplicitStart(): IProjectResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IProjectResourcePromise; + withHealthCheck(key: string): IProjectResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; + withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; + withoutHttpsCertificate(): IProjectResourcePromise; + withParentRelationship(parent: IHandleReference): IProjectResourcePromise; + withChildRelationship(child: IHandleReference): IProjectResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; + excludeFromMcp(): IProjectResourcePromise; + withRemoteImageName(remoteImageName: string): IProjectResourcePromise; + withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IProjectResourcePromise; + withConfig(config: TestConfigDto): IProjectResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IProjectResourcePromise; + withCreatedAt(createdAt: string): IProjectResourcePromise; + withModifiedAt(modifiedAt: string): IProjectResourcePromise; + withCorrelationId(correlationId: string): IProjectResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IProjectResourcePromise; + withStatus(status: TestResourceStatus): IProjectResourcePromise; + withNestedConfig(config: TestNestedDto): IProjectResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IProjectResourcePromise; + testWaitFor(dependency: IHandleReference): IProjectResourcePromise; + withDependency(dependency: IHandleReference): IProjectResourcePromise; + withEndpoints(endpoints: string[]): IProjectResourcePromise; + withEnvironmentVariables(variables: Record): IProjectResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IProjectResourcePromise; } // ============================================================================ @@ -16769,7 +18071,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -16779,7 +18081,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ProjectResourcePromise { + withContainerRegistry(registry: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._withContainerRegistryInternal(registry)); } @@ -16882,7 +18184,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + private async _publishAsDockerFileInternal(configure?: (obj: IContainerResource) => Promise): Promise { const configureId = configure ? registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; const obj = new ContainerResource(objHandle, this._client); @@ -16921,41 +18223,11 @@ export class ProjectResource 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 ProjectResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(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 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)); - } - - /** @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: IEnvironmentCallbackContext) => 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( @@ -16966,12 +18238,12 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -16981,12 +18253,27 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -16996,12 +18283,12 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { + withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -17011,7 +18298,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ProjectResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } @@ -17031,7 +18318,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -17046,12 +18333,32 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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; @@ -17064,7 +18371,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): ProjectResourcePromise { const connectionName = options?.connectionName; const optional = options?.optional; const name = options?.name; @@ -17087,7 +18394,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -17097,12 +18404,12 @@ export class ProjectResource extends ResourceBuilderBase } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise { + withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { return new ProjectResourcePromise(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -17112,7 +18419,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._withReferenceEndpointInternal(endpointReference)); } @@ -17213,9 +18520,9 @@ export class ProjectResource extends ResourceBuilderBase } /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -17237,7 +18544,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -17252,10 +18559,30 @@ export class ProjectResource extends ResourceBuilderBase } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -17274,7 +18601,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -17285,7 +18612,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { const displayText = options?.displayText; return new ProjectResourcePromise(this._withUrlExpressionInternal(url, displayText)); } @@ -17310,7 +18637,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -17325,22 +18652,22 @@ export class ProjectResource extends ResourceBuilderBase } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ProjectResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { + private async _publishWithContainerFilesInternal(source: IHandleReference, 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); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): ProjectResourcePromise { + publishWithContainerFiles(source: IHandleReference, destinationPath: string): ProjectResourcePromise { return new ProjectResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); } @@ -17360,22 +18687,22 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + private async _waitForInternal(dependency: IHandleReference): 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); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ProjectResourcePromise { + waitFor(dependency: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -17385,27 +18712,27 @@ export class ProjectResource extends ResourceBuilderBase } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { return new ProjectResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + private async _waitForStartInternal(dependency: IHandleReference): 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); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ProjectResourcePromise { + waitForStart(dependency: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -17415,7 +18742,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { return new ProjectResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } @@ -17435,18 +18762,18 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ProjectResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise { const exitCode = options?.exitCode; return new ProjectResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -17488,7 +18815,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -17504,7 +18831,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { const commandOptions = options?.commandOptions; return new ProjectResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -17540,11 +18867,11 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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); @@ -17572,32 +18899,32 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withParentRelationshipInternal(parent: IHandleReference): 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { + withParentRelationship(parent: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ProjectResourcePromise { + withChildRelationship(child: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._withChildRelationshipInternal(child)); } @@ -17693,7 +19020,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -17712,7 +19039,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -17721,7 +19048,27 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -17736,7 +19083,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -17750,7 +19097,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -17765,12 +19112,12 @@ export class ProjectResource extends ResourceBuilderBase } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -17785,12 +19132,12 @@ export class ProjectResource extends ResourceBuilderBase } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -17805,12 +19152,12 @@ export class ProjectResource extends ResourceBuilderBase } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -17825,12 +19172,12 @@ export class ProjectResource extends ResourceBuilderBase } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -17845,7 +19192,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); } @@ -17884,7 +19231,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -17899,7 +19246,7 @@ export class ProjectResource extends ResourceBuilderBase } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ProjectResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -17949,7 +19296,7 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -17972,259 +19319,131 @@ export class ProjectResource extends ResourceBuilderBase /** @internal */ private async _withStatusInternal(status: TestResourceStatus): Promise { - const rpcArgs: Record = { builder: this._handle, status }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the resource status */ - withStatus(status: TestResourceStatus): ProjectResourcePromise { - return new ProjectResourcePromise(this._withStatusInternal(status)); - } - - /** @internal */ - private async _withNestedConfigInternal(config: TestNestedDto): Promise { - const rpcArgs: Record = { builder: this._handle, config }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures with nested DTO */ - withNestedConfig(config: TestNestedDto): ProjectResourcePromise { - return new ProjectResourcePromise(this._withNestedConfigInternal(config)); - } - - /** @internal */ - private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { - const validatorId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); - return await validator(arg); - }); - const rpcArgs: Record = { builder: this._handle, validator: validatorId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withValidatorInternal(validator)); - } - - /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._testWaitForInternal(dependency)); - } - - /** @internal */ - private async _withDependencyInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withDependencyInternal(dependency)); - } - - /** @internal */ - private async _withEndpointsInternal(endpoints: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, endpoints }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the endpoints */ - withEndpoints(endpoints: string[]): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEndpointsInternal(endpoints)); - } - - /** @internal */ - private async _withEnvironmentVariablesInternal(variables: Record): Promise { - const rpcArgs: Record = { builder: this._handle, variables }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets environment variables */ - withEnvironmentVariables(variables: Record): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentVariablesInternal(variables)); - } - - /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { - const operationId = registerCallback(async (argData: unknown) => { - const arg = CancellationToken.fromValue(argData); - await operation(arg); - }); - const rpcArgs: Record = { builder: this._handle, operation: operationId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withCancellableOperationInternal(operation)); - } - - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; + const rpcArgs: Record = { builder: this._handle, status }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withMergeLabelInternal(label)); + /** Sets the resource status */ + withStatus(status: TestResourceStatus): ProjectResourcePromise { + return new ProjectResourcePromise(this._withStatusInternal(status)); } /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; + private async _withNestedConfigInternal(config: TestNestedDto): Promise { + const rpcArgs: Record = { builder: this._handle, config }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); + /** Configures with nested DTO */ + withNestedConfig(config: TestNestedDto): ProjectResourcePromise { + return new ProjectResourcePromise(this._withNestedConfigInternal(config)); } /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { + const validatorId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; + const arg = new TestResourceContext(argHandle, this._client); + return await validator(arg); + }); + const rpcArgs: Record = { builder: this._handle, validator: validatorId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._withMergeEndpointInternal(endpointName, port)); + /** Adds validation callback */ + withValidator(validator: (arg: ITestResourceContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + private async _testWaitForInternal(dependency: IHandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + /** Waits for another resource (test version) */ + testWaitFor(dependency: IHandleReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + private async _withDependencyInternal(dependency: IHandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ProjectResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ProjectResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + /** Adds a dependency on another resource */ + withDependency(dependency: IHandleReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withDependencyInternal(dependency)); } /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + private async _withEndpointsInternal(endpoints: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, endpoints }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ProjectResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ProjectResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + /** Sets the endpoints */ + withEndpoints(endpoints: string[]): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEndpointsInternal(endpoints)); } /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + private async _withEnvironmentVariablesInternal(variables: Record): Promise { + const rpcArgs: Record = { builder: this._handle, variables }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); + /** Sets environment variables */ + withEnvironmentVariables(variables: Record): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + const operationId = registerCallback(async (argData: unknown) => { + const arg = CancellationToken.fromValue(argData); + await operation(arg); + }); + const rpcArgs: Record = { builder: this._handle, operation: operationId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); + /** Performs a cancellable operation */ + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withCancellableOperationInternal(operation)); } } @@ -18245,7 +19464,7 @@ export class ProjectResourcePromise implements PromiseLike { } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ProjectResourcePromise { + withContainerRegistry(registry: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } @@ -18289,33 +19508,28 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** 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))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 { + withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ProjectResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } @@ -18325,12 +19539,17 @@ export class ProjectResourcePromise implements PromiseLike { } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -18340,12 +19559,12 @@ export class ProjectResourcePromise implements PromiseLike { } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise { + withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -18370,7 +19589,7 @@ export class ProjectResourcePromise implements PromiseLike { } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -18380,17 +19599,22 @@ export class ProjectResourcePromise implements PromiseLike { } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -18400,12 +19624,12 @@ export class ProjectResourcePromise implements PromiseLike { } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ProjectResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): ProjectResourcePromise { + publishWithContainerFiles(source: IHandleReference, destinationPath: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); } @@ -18415,22 +19639,22 @@ export class ProjectResourcePromise implements PromiseLike { } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ProjectResourcePromise { + waitFor(dependency: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ProjectResourcePromise { + waitForStart(dependency: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ProjectResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -18440,7 +19664,7 @@ export class ProjectResourcePromise implements PromiseLike { } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ProjectResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } @@ -18455,7 +19679,7 @@ export class ProjectResourcePromise implements PromiseLike { } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -18480,12 +19704,12 @@ export class ProjectResourcePromise implements PromiseLike { } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { + withParentRelationship(parent: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ProjectResourcePromise { + withChildRelationship(child: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -18515,12 +19739,17 @@ export class ProjectResourcePromise implements PromiseLike { } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -18530,27 +19759,27 @@ export class ProjectResourcePromise implements PromiseLike { } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -18565,7 +19794,7 @@ export class ProjectResourcePromise implements PromiseLike { } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ProjectResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -18600,17 +19829,17 @@ export class ProjectResourcePromise implements PromiseLike { } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ProjectResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ProjectResourcePromise { + testWaitFor(dependency: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ProjectResourcePromise { + withDependency(dependency: IHandleReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -18625,50 +19854,207 @@ export class ProjectResourcePromise implements PromiseLike { } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ProjectResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// ITestDatabaseResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface ITestDatabaseResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): ITestDatabaseResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestDatabaseResourcePromise; + withEntrypoint(entrypoint: string): ITestDatabaseResourcePromise; + withImageTag(tag: string): ITestDatabaseResourcePromise; + withImageRegistry(registry: string): ITestDatabaseResourcePromise; + withImage(image: string, options?: WithImageOptions): ITestDatabaseResourcePromise; + withImageSHA256(sha256: string): ITestDatabaseResourcePromise; + withContainerRuntimeArgs(args: string[]): ITestDatabaseResourcePromise; + withLifetime(lifetime: ContainerLifetime): ITestDatabaseResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestDatabaseResourcePromise; + publishAsContainer(): ITestDatabaseResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestDatabaseResourcePromise; + withContainerName(name: string): ITestDatabaseResourcePromise; + withBuildArg(name: string, value: IParameterResource): ITestDatabaseResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ITestDatabaseResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ITestDatabaseResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestDatabaseResourcePromise; + withContainerNetworkAlias(alias: string): ITestDatabaseResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ITestDatabaseResourcePromise; + withOtlpExporter(): ITestDatabaseResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ITestDatabaseResourcePromise; + publishAsConnectionString(): ITestDatabaseResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestDatabaseResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestDatabaseResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestDatabaseResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestDatabaseResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ITestDatabaseResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestDatabaseResourcePromise; + withArgs(args: string[]): ITestDatabaseResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ITestDatabaseResourcePromise; + withReferenceUri(name: string, uri: string): ITestDatabaseResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ITestDatabaseResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ITestDatabaseResourcePromise; + withEndpoint(options?: WithEndpointOptions): ITestDatabaseResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ITestDatabaseResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestDatabaseResourcePromise; + withExternalHttpEndpoints(): ITestDatabaseResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ITestDatabaseResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ITestDatabaseResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestDatabaseResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestDatabaseResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestDatabaseResourcePromise; + excludeFromManifest(): ITestDatabaseResourcePromise; + waitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; + waitForStart(dependency: IHandleReference): ITestDatabaseResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; + withExplicitStart(): ITestDatabaseResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestDatabaseResourcePromise; + withHealthCheck(key: string): ITestDatabaseResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestDatabaseResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestDatabaseResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ITestDatabaseResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ITestDatabaseResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestDatabaseResourcePromise; + withoutHttpsCertificate(): ITestDatabaseResourcePromise; + withParentRelationship(parent: IHandleReference): ITestDatabaseResourcePromise; + withChildRelationship(child: IHandleReference): ITestDatabaseResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ITestDatabaseResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestDatabaseResourcePromise; + excludeFromMcp(): ITestDatabaseResourcePromise; + withRemoteImageName(remoteImageName: string): ITestDatabaseResourcePromise; + withRemoteImageTag(remoteImageTag: string): ITestDatabaseResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestDatabaseResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ITestDatabaseResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestDatabaseResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestDatabaseResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestDatabaseResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestDatabaseResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestDatabaseResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ITestDatabaseResourcePromise; + withConfig(config: TestConfigDto): ITestDatabaseResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestDatabaseResourcePromise; + withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; + withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; + testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; + withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; +} +export interface ITestDatabaseResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): ITestDatabaseResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestDatabaseResourcePromise; + withEntrypoint(entrypoint: string): ITestDatabaseResourcePromise; + withImageTag(tag: string): ITestDatabaseResourcePromise; + withImageRegistry(registry: string): ITestDatabaseResourcePromise; + withImage(image: string, options?: WithImageOptions): ITestDatabaseResourcePromise; + withImageSHA256(sha256: string): ITestDatabaseResourcePromise; + withContainerRuntimeArgs(args: string[]): ITestDatabaseResourcePromise; + withLifetime(lifetime: ContainerLifetime): ITestDatabaseResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestDatabaseResourcePromise; + publishAsContainer(): ITestDatabaseResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestDatabaseResourcePromise; + withContainerName(name: string): ITestDatabaseResourcePromise; + withBuildArg(name: string, value: IParameterResource): ITestDatabaseResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ITestDatabaseResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ITestDatabaseResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestDatabaseResourcePromise; + withContainerNetworkAlias(alias: string): ITestDatabaseResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ITestDatabaseResourcePromise; + withOtlpExporter(): ITestDatabaseResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ITestDatabaseResourcePromise; + publishAsConnectionString(): ITestDatabaseResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestDatabaseResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestDatabaseResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestDatabaseResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestDatabaseResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ITestDatabaseResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestDatabaseResourcePromise; + withArgs(args: string[]): ITestDatabaseResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ITestDatabaseResourcePromise; + withReferenceUri(name: string, uri: string): ITestDatabaseResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ITestDatabaseResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ITestDatabaseResourcePromise; + withEndpoint(options?: WithEndpointOptions): ITestDatabaseResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ITestDatabaseResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestDatabaseResourcePromise; + withExternalHttpEndpoints(): ITestDatabaseResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ITestDatabaseResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ITestDatabaseResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestDatabaseResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestDatabaseResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestDatabaseResourcePromise; + excludeFromManifest(): ITestDatabaseResourcePromise; + waitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; + waitForStart(dependency: IHandleReference): ITestDatabaseResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; + withExplicitStart(): ITestDatabaseResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestDatabaseResourcePromise; + withHealthCheck(key: string): ITestDatabaseResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestDatabaseResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestDatabaseResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ITestDatabaseResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ITestDatabaseResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestDatabaseResourcePromise; + withoutHttpsCertificate(): ITestDatabaseResourcePromise; + withParentRelationship(parent: IHandleReference): ITestDatabaseResourcePromise; + withChildRelationship(child: IHandleReference): ITestDatabaseResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ITestDatabaseResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestDatabaseResourcePromise; + excludeFromMcp(): ITestDatabaseResourcePromise; + withRemoteImageName(remoteImageName: string): ITestDatabaseResourcePromise; + withRemoteImageTag(remoteImageTag: string): ITestDatabaseResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestDatabaseResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ITestDatabaseResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestDatabaseResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestDatabaseResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestDatabaseResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestDatabaseResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestDatabaseResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ITestDatabaseResourcePromise; + withConfig(config: TestConfigDto): ITestDatabaseResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestDatabaseResourcePromise; + withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; + withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; + testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; + withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; } // ============================================================================ @@ -18681,7 +20067,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -18691,7 +20077,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new TestDatabaseResource(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestDatabaseResourcePromise { + withBuildArg(name: string, value: IParameterResource): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new TestDatabaseResource(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): TestDatabaseResourcePromise { + withBuildSecret(name: string, value: IParameterResource): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withBuildSecretInternal(name, value)); } @@ -19044,41 +20430,11 @@ export class TestDatabaseResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(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 TestDatabaseResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(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: IEnvironmentCallbackContext) => 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( @@ -19089,12 +20445,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -19104,12 +20460,27 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new TestDatabaseResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -19119,12 +20490,12 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -19134,7 +20505,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -19169,12 +20540,32 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new TestDatabaseResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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; @@ -19187,7 +20578,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -19220,12 +20611,12 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -19235,7 +20626,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -19360,7 +20751,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -19375,10 +20766,30 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new TestDatabaseResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -19397,7 +20808,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -19408,7 +20819,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -19448,7 +20859,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } @@ -19468,22 +20879,22 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new TestDatabaseResource(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { + waitFor(dependency: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -19493,27 +20904,27 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new TestDatabaseResource(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { + waitForStart(dependency: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -19523,7 +20934,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new TestDatabaseResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): TestDatabaseResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestDatabaseResourcePromise { const exitCode = options?.exitCode; return new TestDatabaseResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -19596,7 +21007,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -19612,7 +21023,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { const commandOptions = options?.commandOptions; return new TestDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -19648,11 +21059,11 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 TestDatabaseResource(result, this._client); @@ -19680,32 +21091,32 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new TestDatabaseResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): TestDatabaseResourcePromise { + withParentRelationship(parent: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new TestDatabaseResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): TestDatabaseResourcePromise { + withChildRelationship(child: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withChildRelationshipInternal(child)); } @@ -19801,7 +21212,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -19820,7 +21231,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -19829,7 +21240,27 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new TestDatabaseResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -19844,7 +21275,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -19877,7 +21308,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -19892,12 +21323,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -19912,12 +21343,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -19932,12 +21363,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -19952,12 +21383,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -19972,7 +21403,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._onResourceReadyInternal(callback)); } @@ -20011,7 +21442,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -20026,7 +21457,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -20076,7 +21507,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -20128,7 +21559,7 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -20143,215 +21574,87 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._testWaitForInternal(dependency)); - } - - /** @internal */ - private async _withDependencyInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withDependencyInternal(dependency)); - } - - /** @internal */ - private async _withEndpointsInternal(endpoints: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, endpoints }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Sets the endpoints */ - withEndpoints(endpoints: string[]): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEndpointsInternal(endpoints)); - } - - /** @internal */ - private async _withEnvironmentVariablesInternal(variables: Record): Promise { - const rpcArgs: Record = { builder: this._handle, variables }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Sets environment variables */ - withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentVariablesInternal(variables)); - } - - /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { - const operationId = registerCallback(async (argData: unknown) => { - const arg = CancellationToken.fromValue(argData); - await operation(arg); - }); - const rpcArgs: Record = { builder: this._handle, operation: operationId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withCancellableOperationInternal(operation)); - } - - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + private async _testWaitForInternal(dependency: IHandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + /** Waits for another resource (test version) */ + testWaitFor(dependency: IHandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + private async _withDependencyInternal(dependency: IHandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new TestDatabaseResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + /** Adds a dependency on another resource */ + withDependency(dependency: IHandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withDependencyInternal(dependency)); } /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + private async _withEndpointsInternal(endpoints: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, endpoints }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new TestDatabaseResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + /** Sets the endpoints */ + withEndpoints(endpoints: string[]): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withEndpointsInternal(endpoints)); } /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + private async _withEnvironmentVariablesInternal(variables: Record): Promise { + const rpcArgs: Record = { builder: this._handle, variables }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); + /** Sets environment variables */ + withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + const operationId = registerCallback(async (argData: unknown) => { + const arg = CancellationToken.fromValue(argData); + await operation(arg); + }); + const rpcArgs: Record = { builder: this._handle, operation: operationId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); + /** Performs a cancellable operation */ + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withCancellableOperationInternal(operation)); } } @@ -20372,7 +21675,7 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); } @@ -20437,12 +21740,12 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withBuildArg(name, value))); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): TestDatabaseResourcePromise { + withBuildSecret(name: string, value: IParameterResource): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } @@ -20486,33 +21789,28 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: ParameterResource): TestDatabaseResourcePromise { + withEnvironmentParameter(name: string, parameter: IParameterResource): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): TestDatabaseResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } @@ -20522,12 +21820,17 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): TestDatabaseResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -20537,12 +21840,12 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): TestDatabaseResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -20567,7 +21870,7 @@ export class TestDatabaseResourcePromise implements PromiseLike { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -20577,17 +21880,22 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -20597,7 +21905,7 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } @@ -20607,22 +21915,22 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { + waitForStart(dependency: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -20632,7 +21940,7 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.waitForCompletion(dependency, options))); } @@ -20647,7 +21955,7 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -20672,12 +21980,12 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): TestDatabaseResourcePromise { + withChildRelationship(child: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -20707,12 +22015,17 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -20727,27 +22040,27 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestDatabaseResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestDatabaseResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestDatabaseResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -20762,7 +22075,7 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -20797,17 +22110,17 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { + testWaitFor(dependency: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): TestDatabaseResourcePromise { + withDependency(dependency: IHandleReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -20822,50 +22135,239 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// ITestRedisResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface ITestRedisResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): ITestRedisResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestRedisResourcePromise; + withEntrypoint(entrypoint: string): ITestRedisResourcePromise; + withImageTag(tag: string): ITestRedisResourcePromise; + withImageRegistry(registry: string): ITestRedisResourcePromise; + withImage(image: string, options?: WithImageOptions): ITestRedisResourcePromise; + withImageSHA256(sha256: string): ITestRedisResourcePromise; + withContainerRuntimeArgs(args: string[]): ITestRedisResourcePromise; + withLifetime(lifetime: ContainerLifetime): ITestRedisResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestRedisResourcePromise; + publishAsContainer(): ITestRedisResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestRedisResourcePromise; + withContainerName(name: string): ITestRedisResourcePromise; + withBuildArg(name: string, value: IParameterResource): ITestRedisResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ITestRedisResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ITestRedisResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestRedisResourcePromise; + withContainerNetworkAlias(alias: string): ITestRedisResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ITestRedisResourcePromise; + withOtlpExporter(): ITestRedisResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ITestRedisResourcePromise; + publishAsConnectionString(): ITestRedisResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestRedisResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestRedisResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestRedisResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestRedisResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ITestRedisResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestRedisResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): ITestRedisResourcePromise; + withConnectionPropertyValue(name: string, value: string): ITestRedisResourcePromise; + withArgs(args: string[]): ITestRedisResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ITestRedisResourcePromise; + getConnectionProperty(key: string): Promise; + withReferenceUri(name: string, uri: string): ITestRedisResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ITestRedisResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ITestRedisResourcePromise; + withEndpoint(options?: WithEndpointOptions): ITestRedisResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ITestRedisResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestRedisResourcePromise; + withExternalHttpEndpoints(): ITestRedisResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ITestRedisResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ITestRedisResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestRedisResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestRedisResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestRedisResourcePromise; + excludeFromManifest(): ITestRedisResourcePromise; + waitFor(dependency: IHandleReference): ITestRedisResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; + waitForStart(dependency: IHandleReference): ITestRedisResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; + withExplicitStart(): ITestRedisResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestRedisResourcePromise; + withHealthCheck(key: string): ITestRedisResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestRedisResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestRedisResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ITestRedisResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ITestRedisResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestRedisResourcePromise; + withoutHttpsCertificate(): ITestRedisResourcePromise; + withParentRelationship(parent: IHandleReference): ITestRedisResourcePromise; + withChildRelationship(child: IHandleReference): ITestRedisResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ITestRedisResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestRedisResourcePromise; + excludeFromMcp(): ITestRedisResourcePromise; + withRemoteImageName(remoteImageName: string): ITestRedisResourcePromise; + withRemoteImageTag(remoteImageTag: string): ITestRedisResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestRedisResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ITestRedisResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestRedisResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestRedisResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ITestRedisResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestRedisResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestRedisResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestRedisResourcePromise; + addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): ITestDatabaseResourcePromise; + withPersistence(options?: WithPersistenceOptions): ITestRedisResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ITestRedisResourcePromise; + withConfig(config: TestConfigDto): ITestRedisResourcePromise; + getTags(): Promise>; + getMetadata(): Promise>; + withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withCreatedAt(createdAt: string): ITestRedisResourcePromise; + withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; + withCorrelationId(correlationId: string): ITestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; + withStatus(status: TestResourceStatus): ITestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; + testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + getEndpoints(): Promise; + withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; + withRedisSpecific(option: string): ITestRedisResourcePromise; + withDependency(dependency: IHandleReference): ITestRedisResourcePromise; + withEndpoints(endpoints: string[]): ITestRedisResourcePromise; + withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + getStatusAsync(options?: GetStatusAsyncOptions): Promise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; +} +export interface ITestRedisResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): ITestRedisResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestRedisResourcePromise; + withEntrypoint(entrypoint: string): ITestRedisResourcePromise; + withImageTag(tag: string): ITestRedisResourcePromise; + withImageRegistry(registry: string): ITestRedisResourcePromise; + withImage(image: string, options?: WithImageOptions): ITestRedisResourcePromise; + withImageSHA256(sha256: string): ITestRedisResourcePromise; + withContainerRuntimeArgs(args: string[]): ITestRedisResourcePromise; + withLifetime(lifetime: ContainerLifetime): ITestRedisResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestRedisResourcePromise; + publishAsContainer(): ITestRedisResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestRedisResourcePromise; + withContainerName(name: string): ITestRedisResourcePromise; + withBuildArg(name: string, value: IParameterResource): ITestRedisResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ITestRedisResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ITestRedisResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestRedisResourcePromise; + withContainerNetworkAlias(alias: string): ITestRedisResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ITestRedisResourcePromise; + withOtlpExporter(): ITestRedisResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ITestRedisResourcePromise; + publishAsConnectionString(): ITestRedisResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestRedisResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestRedisResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestRedisResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestRedisResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ITestRedisResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestRedisResourcePromise; + withConnectionProperty(name: string, value: IReferenceExpression): ITestRedisResourcePromise; + withConnectionPropertyValue(name: string, value: string): ITestRedisResourcePromise; + withArgs(args: string[]): ITestRedisResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ITestRedisResourcePromise; + getConnectionProperty(key: string): Promise; + withReferenceUri(name: string, uri: string): ITestRedisResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ITestRedisResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ITestRedisResourcePromise; + withEndpoint(options?: WithEndpointOptions): ITestRedisResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ITestRedisResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestRedisResourcePromise; + withExternalHttpEndpoints(): ITestRedisResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ITestRedisResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ITestRedisResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestRedisResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestRedisResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestRedisResourcePromise; + excludeFromManifest(): ITestRedisResourcePromise; + waitFor(dependency: IHandleReference): ITestRedisResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; + waitForStart(dependency: IHandleReference): ITestRedisResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; + withExplicitStart(): ITestRedisResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestRedisResourcePromise; + withHealthCheck(key: string): ITestRedisResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestRedisResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestRedisResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ITestRedisResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ITestRedisResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestRedisResourcePromise; + withoutHttpsCertificate(): ITestRedisResourcePromise; + withParentRelationship(parent: IHandleReference): ITestRedisResourcePromise; + withChildRelationship(child: IHandleReference): ITestRedisResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ITestRedisResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestRedisResourcePromise; + excludeFromMcp(): ITestRedisResourcePromise; + withRemoteImageName(remoteImageName: string): ITestRedisResourcePromise; + withRemoteImageTag(remoteImageTag: string): ITestRedisResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestRedisResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ITestRedisResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestRedisResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestRedisResourcePromise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ITestRedisResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestRedisResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestRedisResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestRedisResourcePromise; + addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): ITestDatabaseResourcePromise; + withPersistence(options?: WithPersistenceOptions): ITestRedisResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ITestRedisResourcePromise; + withConfig(config: TestConfigDto): ITestRedisResourcePromise; + getTags(): Promise>; + getMetadata(): Promise>; + withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withCreatedAt(createdAt: string): ITestRedisResourcePromise; + withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; + withCorrelationId(correlationId: string): ITestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; + withStatus(status: TestResourceStatus): ITestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; + testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + getEndpoints(): Promise; + withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; + withRedisSpecific(option: string): ITestRedisResourcePromise; + withDependency(dependency: IHandleReference): ITestRedisResourcePromise; + withEndpoints(endpoints: string[]): ITestRedisResourcePromise; + withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + getStatusAsync(options?: GetStatusAsyncOptions): Promise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; } // ============================================================================ @@ -20878,7 +22380,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -20888,7 +22390,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new TestRedisResource(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise { + withBuildArg(name: string, value: IParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new TestRedisResource(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): TestRedisResourcePromise { + withBuildSecret(name: string, value: IParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withBuildSecretInternal(name, value)); } @@ -21241,41 +22743,11 @@ export class TestRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(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 TestRedisResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(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: IEnvironmentCallbackContext) => 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( @@ -21286,12 +22758,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -21301,12 +22773,27 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new TestRedisResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -21316,12 +22803,12 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -21331,12 +22818,12 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', @@ -21346,7 +22833,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -21396,12 +22883,32 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new TestRedisResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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; @@ -21414,13 +22921,22 @@ export class TestRedisResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withReferenceUriInternal(name: string, uri: string): Promise { const rpcArgs: Record = { builder: this._handle, name, uri }; @@ -21437,7 +22953,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -21447,12 +22963,12 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -21462,7 +22978,7 @@ export class TestRedisResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -21587,7 +23103,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -21602,10 +23118,30 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new TestRedisResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -21624,7 +23160,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -21635,7 +23171,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -21675,7 +23211,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } @@ -21695,22 +23231,22 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new TestRedisResource(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): TestRedisResourcePromise { + waitFor(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -21720,27 +23256,27 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new TestRedisResource(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): TestRedisResourcePromise { + waitForStart(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -21750,7 +23286,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new TestRedisResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): TestRedisResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise { const exitCode = options?.exitCode; return new TestRedisResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -21823,7 +23359,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -21839,7 +23375,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): TestRedisResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise { const commandOptions = options?.commandOptions; return new TestRedisResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -21875,11 +23411,11 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 TestRedisResource(result, this._client); @@ -21907,32 +23443,32 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new TestRedisResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): TestRedisResourcePromise { + withParentRelationship(parent: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new TestRedisResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): TestRedisResourcePromise { + withChildRelationship(child: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withChildRelationshipInternal(child)); } @@ -22028,7 +23564,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -22047,7 +23583,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -22056,7 +23592,27 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new TestRedisResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -22071,7 +23627,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -22104,7 +23660,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -22119,12 +23675,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -22139,12 +23695,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; const arg = new ConnectionStringAvailableEvent(argHandle, this._client); @@ -22159,12 +23715,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -22179,12 +23735,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -22199,12 +23755,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -22219,7 +23775,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._onResourceReadyInternal(callback)); } @@ -22310,7 +23866,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withConnectionStringInternal(connectionString: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', @@ -22320,12 +23876,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -22340,7 +23896,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -22390,7 +23946,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -22442,7 +23998,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -22457,12 +24013,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -22472,7 +24028,7 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -22526,248 +24082,120 @@ export class TestRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, endpoints }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Sets the endpoints */ - withEndpoints(endpoints: string[]): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEndpointsInternal(endpoints)); - } - - /** @internal */ - private async _withEnvironmentVariablesInternal(variables: Record): Promise { - const rpcArgs: Record = { builder: this._handle, variables }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Sets environment variables */ - withEnvironmentVariables(variables: Record): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentVariablesInternal(variables)); - } - - /** Gets the status of the resource asynchronously */ - async getStatusAsync(options?: GetStatusAsyncOptions): Promise { - const cancellationToken = options?.cancellationToken; - const rpcArgs: Record = { builder: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); - return await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/getStatusAsync', - rpcArgs - ); - } - - /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { - const operationId = registerCallback(async (argData: unknown) => { - const arg = CancellationToken.fromValue(argData); - await operation(arg); - }); - const rpcArgs: Record = { builder: this._handle, operation: operationId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withCancellableOperationInternal(operation)); - } - - /** Waits for the resource to be ready */ - async waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise { - const cancellationToken = options?.cancellationToken; - const rpcArgs: Record = { builder: this._handle, timeout }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); - return await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/waitForReadyAsync', - rpcArgs - ); - } - - /** @internal */ - private async _withMultiParamHandleCallbackInternal(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): Promise { - const callbackId = registerCallback(async (arg1Data: unknown, arg2Data: unknown) => { - const arg1Handle = wrapIfHandle(arg1Data) as TestCallbackContextHandle; - const arg1 = new TestCallbackContext(arg1Handle, this._client); - const arg2Handle = wrapIfHandle(arg2Data) as TestEnvironmentContextHandle; - const arg2 = new TestEnvironmentContext(arg2Handle, this._client); - await callback(arg1, arg2); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMultiParamHandleCallback', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Tests multi-param callback destructuring */ - withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMultiParamHandleCallbackInternal(callback)); - } - - /** @internal */ - private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (name !== undefined) rpcArgs.name = name; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDataVolume', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Adds a data volume with persistence */ - withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new TestRedisResourcePromise(this._withDataVolumeInternal(name, isReadOnly)); - } - - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; + const rpcArgs: Record = { builder: this._handle, endpoints }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); + /** Sets the endpoints */ + withEndpoints(endpoints: string[]): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withEndpointsInternal(endpoints)); } /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; + private async _withEnvironmentVariablesInternal(variables: Record): Promise { + const rpcArgs: Record = { builder: this._handle, variables }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMergeEndpointInternal(endpointName, port)); + /** Sets environment variables */ + withEnvironmentVariables(variables: Record): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withEnvironmentVariablesInternal(variables)); } - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + /** Gets the status of the resource asynchronously */ + async getStatusAsync(options?: GetStatusAsyncOptions): Promise { + const cancellationToken = options?.cancellationToken; + const rpcArgs: Record = { builder: this._handle }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + return await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/getStatusAsync', rpcArgs ); - return new TestRedisResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); } /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + const operationId = registerCallback(async (argData: unknown) => { + const arg = CancellationToken.fromValue(argData); + await operation(arg); + }); + const rpcArgs: Record = { builder: this._handle, operation: operationId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new TestRedisResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + /** Performs a cancellable operation */ + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + /** Waits for the resource to be ready */ + async waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise { + const cancellationToken = options?.cancellationToken; + const rpcArgs: Record = { builder: this._handle, timeout }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + return await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/waitForReadyAsync', rpcArgs ); - return new TestRedisResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new TestRedisResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); } /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + private async _withMultiParamHandleCallbackInternal(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): Promise { + const callbackId = registerCallback(async (arg1Data: unknown, arg2Data: unknown) => { + const arg1Handle = wrapIfHandle(arg1Data) as TestCallbackContextHandle; + const arg1 = new TestCallbackContext(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(arg2Data) as TestEnvironmentContextHandle; + const arg2 = new TestEnvironmentContext(arg2Handle, this._client); + await callback(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMultiParamHandleCallback', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); + /** Tests multi-param callback destructuring */ + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withMultiParamHandleCallbackInternal(callback)); } /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDataVolume', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); + /** Adds a data volume with persistence */ + withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new TestRedisResourcePromise(this._withDataVolumeInternal(name, isReadOnly)); } } @@ -22788,7 +24216,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): TestRedisResourcePromise { + withContainerRegistry(registry: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } @@ -22853,12 +24281,12 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise { + withBuildArg(name: string, value: IParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): TestRedisResourcePromise { + withBuildSecret(name: string, value: IParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } @@ -22902,38 +24330,33 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: ParameterResource): TestRedisResourcePromise { + withEnvironmentParameter(name: string, parameter: IParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): TestRedisResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): TestRedisResourcePromise { + withConnectionProperty(name: string, value: IReferenceExpression): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -22948,27 +24371,37 @@ export class TestRedisResourcePromise implements PromiseLike } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): TestRedisResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): TestRedisResourcePromise { + withReferenceExternalService(externalService: IExternalServiceResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): TestRedisResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -22993,7 +24426,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -23003,17 +24436,22 @@ export class TestRedisResourcePromise implements PromiseLike } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -23023,7 +24461,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestRedisResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } @@ -23033,22 +24471,22 @@ export class TestRedisResourcePromise implements PromiseLike } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): TestRedisResourcePromise { + waitFor(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): TestRedisResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): TestRedisResourcePromise { + waitForStart(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): TestRedisResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -23058,7 +24496,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): TestRedisResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } @@ -23073,7 +24511,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -23098,12 +24536,12 @@ export class TestRedisResourcePromise implements PromiseLike } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): TestRedisResourcePromise { + withParentRelationship(parent: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): TestRedisResourcePromise { + withChildRelationship(child: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -23133,12 +24571,17 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestRedisResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -23153,32 +24596,32 @@ export class TestRedisResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestRedisResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestRedisResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise { + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestRedisResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestRedisResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -23213,12 +24656,12 @@ export class TestRedisResourcePromise implements PromiseLike } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise { + withConnectionString(connectionString: IReferenceExpression): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionString(connectionString))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -23253,12 +24696,12 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): TestRedisResourcePromise { + testWaitFor(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } @@ -23278,7 +24721,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): TestRedisResourcePromise { + withDependency(dependency: IHandleReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -23298,7 +24741,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } @@ -23308,7 +24751,7 @@ export class TestRedisResourcePromise implements PromiseLike } /** Tests multi-param callback destructuring */ - withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withMultiParamHandleCallback(callback))); } @@ -23317,46 +24760,205 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// ITestVaultResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface ITestVaultResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): ITestVaultResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestVaultResourcePromise; + withEntrypoint(entrypoint: string): ITestVaultResourcePromise; + withImageTag(tag: string): ITestVaultResourcePromise; + withImageRegistry(registry: string): ITestVaultResourcePromise; + withImage(image: string, options?: WithImageOptions): ITestVaultResourcePromise; + withImageSHA256(sha256: string): ITestVaultResourcePromise; + withContainerRuntimeArgs(args: string[]): ITestVaultResourcePromise; + withLifetime(lifetime: ContainerLifetime): ITestVaultResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestVaultResourcePromise; + publishAsContainer(): ITestVaultResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestVaultResourcePromise; + withContainerName(name: string): ITestVaultResourcePromise; + withBuildArg(name: string, value: IParameterResource): ITestVaultResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ITestVaultResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ITestVaultResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestVaultResourcePromise; + withContainerNetworkAlias(alias: string): ITestVaultResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ITestVaultResourcePromise; + withOtlpExporter(): ITestVaultResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ITestVaultResourcePromise; + publishAsConnectionString(): ITestVaultResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestVaultResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestVaultResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestVaultResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestVaultResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ITestVaultResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestVaultResourcePromise; + withArgs(args: string[]): ITestVaultResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ITestVaultResourcePromise; + withReferenceUri(name: string, uri: string): ITestVaultResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ITestVaultResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ITestVaultResourcePromise; + withEndpoint(options?: WithEndpointOptions): ITestVaultResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ITestVaultResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestVaultResourcePromise; + withExternalHttpEndpoints(): ITestVaultResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ITestVaultResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ITestVaultResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestVaultResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestVaultResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestVaultResourcePromise; + excludeFromManifest(): ITestVaultResourcePromise; + waitFor(dependency: IHandleReference): ITestVaultResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; + waitForStart(dependency: IHandleReference): ITestVaultResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; + withExplicitStart(): ITestVaultResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestVaultResourcePromise; + withHealthCheck(key: string): ITestVaultResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestVaultResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestVaultResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ITestVaultResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ITestVaultResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestVaultResourcePromise; + withoutHttpsCertificate(): ITestVaultResourcePromise; + withParentRelationship(parent: IHandleReference): ITestVaultResourcePromise; + withChildRelationship(child: IHandleReference): ITestVaultResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ITestVaultResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestVaultResourcePromise; + excludeFromMcp(): ITestVaultResourcePromise; + withRemoteImageName(remoteImageName: string): ITestVaultResourcePromise; + withRemoteImageTag(remoteImageTag: string): ITestVaultResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestVaultResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ITestVaultResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestVaultResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestVaultResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestVaultResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestVaultResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestVaultResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; + withConfig(config: TestConfigDto): ITestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; + withCreatedAt(createdAt: string): ITestVaultResourcePromise; + withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; + withCorrelationId(correlationId: string): ITestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; + withStatus(status: TestResourceStatus): ITestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; + testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; + withDependency(dependency: IHandleReference): ITestVaultResourcePromise; + withEndpoints(endpoints: string[]): ITestVaultResourcePromise; + withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; + withVaultDirect(option: string): ITestVaultResourcePromise; +} +export interface ITestVaultResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): ITestVaultResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestVaultResourcePromise; + withEntrypoint(entrypoint: string): ITestVaultResourcePromise; + withImageTag(tag: string): ITestVaultResourcePromise; + withImageRegistry(registry: string): ITestVaultResourcePromise; + withImage(image: string, options?: WithImageOptions): ITestVaultResourcePromise; + withImageSHA256(sha256: string): ITestVaultResourcePromise; + withContainerRuntimeArgs(args: string[]): ITestVaultResourcePromise; + withLifetime(lifetime: ContainerLifetime): ITestVaultResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestVaultResourcePromise; + publishAsContainer(): ITestVaultResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestVaultResourcePromise; + withContainerName(name: string): ITestVaultResourcePromise; + withBuildArg(name: string, value: IParameterResource): ITestVaultResourcePromise; + withBuildSecret(name: string, value: IParameterResource): ITestVaultResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ITestVaultResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestVaultResourcePromise; + withContainerNetworkAlias(alias: string): ITestVaultResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ITestVaultResourcePromise; + withOtlpExporter(): ITestVaultResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ITestVaultResourcePromise; + publishAsConnectionString(): ITestVaultResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestVaultResourcePromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestVaultResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestVaultResourcePromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestVaultResourcePromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): ITestVaultResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestVaultResourcePromise; + withArgs(args: string[]): ITestVaultResourcePromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): ITestVaultResourcePromise; + withReferenceUri(name: string, uri: string): ITestVaultResourcePromise; + withReferenceExternalService(externalService: IExternalServiceResource): ITestVaultResourcePromise; + withReferenceEndpoint(endpointReference: IEndpointReference): ITestVaultResourcePromise; + withEndpoint(options?: WithEndpointOptions): ITestVaultResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ITestVaultResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestVaultResourcePromise; + withExternalHttpEndpoints(): ITestVaultResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ITestVaultResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ITestVaultResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestVaultResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestVaultResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestVaultResourcePromise; + excludeFromManifest(): ITestVaultResourcePromise; + waitFor(dependency: IHandleReference): ITestVaultResourcePromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; + waitForStart(dependency: IHandleReference): ITestVaultResourcePromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; + withExplicitStart(): ITestVaultResourcePromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestVaultResourcePromise; + withHealthCheck(key: string): ITestVaultResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestVaultResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestVaultResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ITestVaultResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ITestVaultResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestVaultResourcePromise; + withoutHttpsCertificate(): ITestVaultResourcePromise; + withParentRelationship(parent: IHandleReference): ITestVaultResourcePromise; + withChildRelationship(child: IHandleReference): ITestVaultResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ITestVaultResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestVaultResourcePromise; + excludeFromMcp(): ITestVaultResourcePromise; + withRemoteImageName(remoteImageName: string): ITestVaultResourcePromise; + withRemoteImageTag(remoteImageTag: string): ITestVaultResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestVaultResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ITestVaultResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestVaultResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestVaultResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestVaultResourcePromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestVaultResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestVaultResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; + withConfig(config: TestConfigDto): ITestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; + withCreatedAt(createdAt: string): ITestVaultResourcePromise; + withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; + withCorrelationId(correlationId: string): ITestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; + withStatus(status: TestResourceStatus): ITestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; + testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; + withDependency(dependency: IHandleReference): ITestVaultResourcePromise; + withEndpoints(endpoints: string[]): ITestVaultResourcePromise; + withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; + withVaultDirect(option: string): ITestVaultResourcePromise; } // ============================================================================ @@ -23369,7 +24971,7 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -23379,7 +24981,7 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new TestVaultResource(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise { + withBuildArg(name: string, value: IParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new TestVaultResource(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): TestVaultResourcePromise { + withBuildSecret(name: string, value: IParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withBuildSecretInternal(name, value)); } @@ -23732,41 +25334,11 @@ export class TestVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(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 TestVaultResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise { - return new TestVaultResourcePromise(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: IEnvironmentCallbackContext) => 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( @@ -23777,12 +25349,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -23792,12 +25364,27 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new TestVaultResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -23807,12 +25394,12 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -23822,7 +25409,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -23857,12 +25444,32 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new TestVaultResource(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withReferenceInternal(source: IHandleReference, 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; @@ -23875,7 +25482,7 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -23908,12 +25515,12 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -23923,7 +25530,7 @@ export class TestVaultResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -24048,7 +25655,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -24063,10 +25670,30 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new TestVaultResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -24085,7 +25712,7 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -24096,7 +25723,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -24136,7 +25763,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } @@ -24156,22 +25783,22 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new TestVaultResource(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): TestVaultResourcePromise { + waitFor(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -24181,27 +25808,27 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new TestVaultResource(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): TestVaultResourcePromise { + waitForStart(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -24211,7 +25838,7 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new TestVaultResource(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): TestVaultResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise { const exitCode = options?.exitCode; return new TestVaultResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -24284,7 +25911,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -24300,7 +25927,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): TestVaultResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise { const commandOptions = options?.commandOptions; return new TestVaultResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } @@ -24336,11 +25963,11 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 TestVaultResource(result, this._client); @@ -24368,32 +25995,32 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new TestVaultResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): TestVaultResourcePromise { + withParentRelationship(parent: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new TestVaultResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): TestVaultResourcePromise { + withChildRelationship(child: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withChildRelationshipInternal(child)); } @@ -24489,7 +26116,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -24508,7 +26135,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -24517,7 +26144,27 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new TestVaultResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -24532,7 +26179,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -24565,7 +26212,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -24580,12 +26227,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -24600,12 +26247,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -24620,12 +26267,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -24640,12 +26287,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -24660,7 +26307,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._onResourceReadyInternal(callback)); } @@ -24699,7 +26346,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -24714,7 +26361,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -24764,7 +26411,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -24816,7 +26463,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -24831,12 +26478,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -24846,12 +26493,12 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -24861,7 +26508,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -24910,7 +26557,7 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withCancellableOperationInternal(operation)); } @@ -24929,134 +26576,6 @@ export class TestVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new TestVaultResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new TestVaultResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - } /** @@ -25075,7 +26594,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): TestVaultResourcePromise { + withContainerRegistry(registry: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } @@ -25140,12 +26659,12 @@ export class TestVaultResourcePromise implements PromiseLike } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise { + withBuildArg(name: string, value: IParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): TestVaultResourcePromise { + withBuildSecret(name: string, value: IParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } @@ -25189,33 +26708,28 @@ export class TestVaultResourcePromise implements PromiseLike return new TestVaultResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: ParameterResource): TestVaultResourcePromise { + withEnvironmentParameter(name: string, parameter: IParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): TestVaultResourcePromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } @@ -25225,12 +26739,17 @@ export class TestVaultResourcePromise implements PromiseLike } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): TestVaultResourcePromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -25240,12 +26759,12 @@ export class TestVaultResourcePromise implements PromiseLike } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): TestVaultResourcePromise { + withReferenceExternalService(externalService: IExternalServiceResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): TestVaultResourcePromise { + withReferenceEndpoint(endpointReference: IEndpointReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -25270,7 +26789,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -25280,17 +26799,22 @@ export class TestVaultResourcePromise implements PromiseLike } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -25300,7 +26824,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestVaultResourcePromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } @@ -25310,22 +26834,22 @@ export class TestVaultResourcePromise implements PromiseLike } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): TestVaultResourcePromise { + waitFor(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): TestVaultResourcePromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): TestVaultResourcePromise { + waitForStart(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): TestVaultResourcePromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } @@ -25335,7 +26859,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): TestVaultResourcePromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } @@ -25350,7 +26874,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } @@ -25375,12 +26899,12 @@ export class TestVaultResourcePromise implements PromiseLike } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): TestVaultResourcePromise { + withParentRelationship(parent: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): TestVaultResourcePromise { + withChildRelationship(child: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -25410,12 +26934,17 @@ export class TestVaultResourcePromise implements PromiseLike } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestVaultResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -25430,27 +26959,27 @@ export class TestVaultResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestVaultResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestVaultResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestVaultResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestVaultResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -25465,7 +26994,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -25500,17 +27029,17 @@ export class TestVaultResourcePromise implements PromiseLike } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): TestVaultResourcePromise { + testWaitFor(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): TestVaultResourcePromise { + withDependency(dependency: IHandleReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -25525,7 +27054,7 @@ export class TestVaultResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } @@ -25534,46 +27063,21 @@ export class TestVaultResourcePromise implements PromiseLike return new TestVaultResourcePromise(this._promise.then(obj => obj.withVaultDirect(option))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IComputeResource +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IComputeResource { + toJSON(): MarshalledHandle; + withRemoteImageName(remoteImageName: string): IComputeResourcePromise; + withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; +} +export interface IComputeResourcePromise extends PromiseLike { + withRemoteImageName(remoteImageName: string): IComputeResourcePromise; + withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; } // ============================================================================ @@ -25644,6 +27148,19 @@ export class ComputeResourcePromise implements PromiseLike { } +// ============================================================================ +// IContainerFilesDestinationResource +// ============================================================================ + +export interface IContainerFilesDestinationResource { + toJSON(): MarshalledHandle; + publishWithContainerFiles(source: IHandleReference, destinationPath: string): IContainerFilesDestinationResourcePromise; +} + +export interface IContainerFilesDestinationResourcePromise extends PromiseLike { + publishWithContainerFiles(source: IHandleReference, destinationPath: string): IContainerFilesDestinationResourcePromise; +} + // ============================================================================ // ContainerFilesDestinationResource // ============================================================================ @@ -25654,17 +27171,17 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { + private async _publishWithContainerFilesInternal(source: IHandleReference, 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 ContainerFilesDestinationResource(result, this._client); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: ResourceBuilderBase, destinationPath: string): ContainerFilesDestinationResourcePromise { + publishWithContainerFiles(source: IHandleReference, destinationPath: string): ContainerFilesDestinationResourcePromise { return new ContainerFilesDestinationResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); } @@ -25686,12 +27203,97 @@ export class ContainerFilesDestinationResourcePromise implements PromiseLike obj.publishWithContainerFiles(source, destinationPath))); } } +// ============================================================================ +// IResource +// ============================================================================ + +export interface IResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: IHandleReference): IResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; + excludeFromManifest(): IResourcePromise; + withExplicitStart(): IResourcePromise; + withHealthCheck(key: string): IResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; + withParentRelationship(parent: IHandleReference): IResourcePromise; + withChildRelationship(child: IHandleReference): IResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; + excludeFromMcp(): IResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; + withConfig(config: TestConfigDto): IResourcePromise; + withCreatedAt(createdAt: string): IResourcePromise; + withModifiedAt(modifiedAt: string): IResourcePromise; + withCorrelationId(correlationId: string): IResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; + withStatus(status: TestResourceStatus): IResourcePromise; + withNestedConfig(config: TestNestedDto): IResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; + testWaitFor(dependency: IHandleReference): IResourcePromise; + withDependency(dependency: IHandleReference): IResourcePromise; + withEndpoints(endpoints: string[]): IResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; +} + +export interface IResourcePromise extends PromiseLike { + withContainerRegistry(registry: IHandleReference): IResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; + withUrl(url: string, options?: WithUrlOptions): IResourcePromise; + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; + excludeFromManifest(): IResourcePromise; + withExplicitStart(): IResourcePromise; + withHealthCheck(key: string): IResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; + withParentRelationship(parent: IHandleReference): IResourcePromise; + withChildRelationship(child: IHandleReference): IResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; + excludeFromMcp(): IResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; + withConfig(config: TestConfigDto): IResourcePromise; + withCreatedAt(createdAt: string): IResourcePromise; + withModifiedAt(modifiedAt: string): IResourcePromise; + withCorrelationId(correlationId: string): IResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; + withStatus(status: TestResourceStatus): IResourcePromise; + withNestedConfig(config: TestNestedDto): IResourcePromise; + withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; + testWaitFor(dependency: IHandleReference): IResourcePromise; + withDependency(dependency: IHandleReference): IResourcePromise; + withEndpoints(endpoints: string[]): IResourcePromise; + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; +} + // ============================================================================ // Resource // ============================================================================ @@ -25702,7 +27304,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', @@ -25712,7 +27314,7 @@ export class Resource extends ResourceBuilderBase { } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ResourcePromise { + withContainerRegistry(registry: IHandleReference): ResourcePromise { return new ResourcePromise(this._withContainerRegistryInternal(registry)); } @@ -25753,7 +27355,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); @@ -25768,10 +27370,30 @@ export class Resource extends ResourceBuilderBase { } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { return new ResourcePromise(this._withUrlsCallbackInternal(callback)); } + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + /** @internal */ private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; @@ -25790,7 +27412,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( @@ -25801,7 +27423,7 @@ export class Resource extends ResourceBuilderBase { } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { const displayText = options?.displayText; return new ResourcePromise(this._withUrlExpressionInternal(url, displayText)); } @@ -25871,7 +27493,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; const arg = new ExecuteCommandContext(argHandle, this._client); @@ -25887,38 +27509,38 @@ export class Resource extends ResourceBuilderBase { } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { const commandOptions = options?.commandOptions; return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withParentRelationshipInternal(parent: IHandleReference): 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); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { + withParentRelationship(parent: IHandleReference): ResourcePromise { return new ResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: IHandleReference): 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); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ResourcePromise { + withChildRelationship(child: IHandleReference): ResourcePromise { return new ResourcePromise(this._withChildRelationshipInternal(child)); } @@ -25955,7 +27577,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; const arg = new PipelineStepContext(argHandle, this._client); @@ -25974,7 +27596,7 @@ export class Resource extends ResourceBuilderBase { } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; @@ -25983,7 +27605,27 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); @@ -25998,7 +27640,7 @@ export class Resource extends ResourceBuilderBase { } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { return new ResourcePromise(this._withPipelineConfigurationInternal(callback)); } @@ -26012,7 +27654,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; const arg = new BeforeResourceStartedEvent(argHandle, this._client); @@ -26027,12 +27669,12 @@ export class Resource extends ResourceBuilderBase { } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ResourcePromise { return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; const arg = new ResourceStoppedEvent(argHandle, this._client); @@ -26047,12 +27689,12 @@ export class Resource extends ResourceBuilderBase { } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ResourcePromise { return new ResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; const arg = new InitializeResourceEvent(argHandle, this._client); @@ -26067,12 +27709,12 @@ export class Resource extends ResourceBuilderBase { } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ResourcePromise { return new ResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; const arg = new ResourceReadyEvent(argHandle, this._client); @@ -26087,7 +27729,7 @@ export class Resource extends ResourceBuilderBase { } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ResourcePromise { return new ResourcePromise(this._onResourceReadyInternal(callback)); } @@ -26171,7 +27813,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; const arg = new TestCallbackContext(argHandle, this._client); @@ -26223,7 +27865,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { + private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; const arg = new TestResourceContext(argHandle, this._client); @@ -26238,12 +27880,12 @@ export class Resource extends ResourceBuilderBase { } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { return new ResourcePromise(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: ResourceBuilderBase): Promise { + private async _testWaitForInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', @@ -26253,12 +27895,12 @@ export class Resource extends ResourceBuilderBase { } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ResourcePromise { + testWaitFor(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: ResourceBuilderBase): Promise { + private async _withDependencyInternal(dependency: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', @@ -26268,7 +27910,7 @@ export class Resource extends ResourceBuilderBase { } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ResourcePromise { + withDependency(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._withDependencyInternal(dependency)); } @@ -26288,7 +27930,7 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -26302,138 +27944,10 @@ export class Resource extends ResourceBuilderBase { } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { return new ResourcePromise(this._withCancellableOperationInternal(operation)); } - /** @internal */ - private async _withMergeLabelInternal(label: string): Promise { - const rpcArgs: Record = { builder: this._handle, label }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds a label to the resource */ - withMergeLabel(label: string): ResourcePromise { - return new ResourcePromise(this._withMergeLabelInternal(label)); - } - - /** @internal */ - private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { - const rpcArgs: Record = { builder: this._handle, label, category }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ResourcePromise { - return new ResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); - } - - /** @internal */ - private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ResourcePromise { - return new ResourcePromise(this._withMergeEndpointInternal(endpointName, port)); - } - - /** @internal */ - private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { - const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise { - return new ResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); - } - - /** @internal */ - private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { - const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; - if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; - if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise { - const enableConsole = options?.enableConsole; - const maxFiles = options?.maxFiles; - return new ResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); - } - - /** @internal */ - private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise { - return new ResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); - } - - /** @internal */ - private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { - const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise { - return new ResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); - } - } /** @@ -26452,7 +27966,7 @@ export class ResourcePromise implements PromiseLike { } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ResourcePromise { + withContainerRegistry(registry: IHandleReference): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } @@ -26467,17 +27981,22 @@ export class ResourcePromise implements PromiseLike { } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise { + withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { + withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } @@ -26502,17 +28021,17 @@ export class ResourcePromise implements PromiseLike { } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { + withParentRelationship(parent: IHandleReference): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ResourcePromise { + withChildRelationship(child: IHandleReference): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } @@ -26527,12 +28046,17 @@ export class ResourcePromise implements PromiseLike { } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } @@ -26542,22 +28066,22 @@ export class ResourcePromise implements PromiseLike { } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } @@ -26602,17 +28126,17 @@ export class ResourcePromise implements PromiseLike { } /** Adds validation callback */ - withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: ResourceBuilderBase): ResourcePromise { + testWaitFor(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: ResourceBuilderBase): ResourcePromise { + withDependency(dependency: IHandleReference): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); } @@ -26622,50 +28146,27 @@ export class ResourcePromise implements PromiseLike { } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); } - /** Adds a label to the resource */ - withMergeLabel(label: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); - } - - /** Adds a categorized label to the resource */ - withMergeLabelCategorized(label: string, category: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); - } - - /** Configures a named endpoint */ - withMergeEndpoint(endpointName: string, port: number): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); - } - - /** Configures a named endpoint with scheme */ - withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); - } - - /** Configures resource logging */ - withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); - } - - /** Configures resource logging with file path */ - withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); - } +} - /** Configures a route */ - withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); - } +// ============================================================================ +// IResourceWithArgs +// ============================================================================ - /** Configures a route with middleware */ - withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); - } +export interface IResourceWithArgs { + toJSON(): MarshalledHandle; + withArgs(args: string[]): IResourceWithArgsPromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; +} +export interface IResourceWithArgsPromise extends PromiseLike { + withArgs(args: string[]): IResourceWithArgsPromise; + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; } // ============================================================================ @@ -26693,7 +28194,7 @@ export class ResourceWithArgs extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; const obj = new CommandLineArgsCallbackContext(objHandle, this._client); @@ -26708,10 +28209,30 @@ export class ResourceWithArgs extends ResourceBuilderBase Promise): ResourceWithArgsPromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { return new ResourceWithArgsPromise(this._withArgsCallbackInternal(callback)); } + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new ResourceWithArgs(result, this._client); + } + + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._withArgsCallbackAsyncInternal(callback)); + } + } /** @@ -26735,10 +28256,38 @@ export class ResourceWithArgsPromise implements PromiseLike { } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallback(callback))); } + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + } + +} + +// ============================================================================ +// IResourceWithConnectionString +// ============================================================================ + +export interface IResourceWithConnectionString { + toJSON(): MarshalledHandle; + withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; + getConnectionProperty(key: string): Promise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; + withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; +} + +export interface IResourceWithConnectionStringPromise extends PromiseLike { + withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; + getConnectionProperty(key: string): Promise; + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; + withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; } // ============================================================================ @@ -26751,7 +28300,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', @@ -26761,7 +28310,7 @@ 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 { + private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; const arg = new ConnectionStringAvailableEvent(argHandle, this._client); @@ -26796,12 +28354,12 @@ export class ResourceWithConnectionString extends ResourceBuilderBase Promise): ResourceWithConnectionStringPromise { + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _withConnectionStringInternal(connectionString: ReferenceExpression): Promise { + private async _withConnectionStringInternal(connectionString: IReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', @@ -26811,7 +28369,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase obj.withConnectionProperty(name, value))); } @@ -26857,13 +28415,18 @@ 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 { + onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise { + withConnectionString(connectionString: IReferenceExpression): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionString(connectionString))); } @@ -26874,6 +28437,21 @@ export class ResourceWithConnectionStringPromise implements PromiseLike { + withContainerFilesSource(sourcePath: string): IResourceWithContainerFilesPromise; + clearContainerFilesSources(): IResourceWithContainerFilesPromise; +} + // ============================================================================ // ResourceWithContainerFiles // ============================================================================ @@ -26942,6 +28520,39 @@ export class ResourceWithContainerFilesPromise implements PromiseLike; + asHttp2Service(): IResourceWithEndpointsPromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; +} + +export interface IResourceWithEndpointsPromise extends PromiseLike { + withMcpServer(options?: WithMcpServerOptions): IResourceWithEndpointsPromise; + withEndpoint(options?: WithEndpointOptions): IResourceWithEndpointsPromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): IResourceWithEndpointsPromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): IResourceWithEndpointsPromise; + withExternalHttpEndpoints(): IResourceWithEndpointsPromise; + getEndpoint(name: string): Promise; + asHttp2Service(): IResourceWithEndpointsPromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; +} + // ============================================================================ // ResourceWithEndpoints // ============================================================================ @@ -27067,9 +28678,9 @@ export class ResourceWithEndpoints extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -27091,7 +28702,7 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; const arg = new EndpointReference(argHandle, this._client); @@ -27106,7 +28717,7 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): ResourceWithEndpointsPromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ResourceWithEndpointsPromise { return new ResourceWithEndpointsPromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } @@ -27161,7 +28772,7 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); @@ -27176,7 +28787,7 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): ResourceWithEndpointsPromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); } @@ -27223,7 +28834,7 @@ export class ResourceWithEndpointsPromise implements PromiseLike { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } @@ -27233,7 +28844,7 @@ export class ResourceWithEndpointsPromise implements PromiseLike Promise): ResourceWithEndpointsPromise { + withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ResourceWithEndpointsPromise { return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } @@ -27248,12 +28859,57 @@ export class ResourceWithEndpointsPromise implements PromiseLike Promise): ResourceWithEndpointsPromise { + onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } } +// ============================================================================ +// IResourceWithEnvironment +// ============================================================================ + +export interface IResourceWithEnvironment { + toJSON(): MarshalledHandle; + withOtlpExporter(): IResourceWithEnvironmentPromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IResourceWithEnvironmentPromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; + withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; + withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; + withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; + withoutHttpsCertificate(): IResourceWithEnvironmentPromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; +} + +export interface IResourceWithEnvironmentPromise extends PromiseLike { + withOtlpExporter(): IResourceWithEnvironmentPromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; + withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IResourceWithEnvironmentPromise; + withReference(source: IHandleReference, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; + withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; + withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; + withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; + withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; + withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; + withoutHttpsCertificate(): IResourceWithEnvironmentPromise; + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; +} + // ============================================================================ // ResourceWithEnvironment // ============================================================================ @@ -27294,41 +28950,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: IEnvironmentCallbackContext) => 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( @@ -27339,12 +28965,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentEndpoint', @@ -27354,12 +28980,27 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { + 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 on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); + } + + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', @@ -27369,12 +29010,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', @@ -27384,12 +29025,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withReferenceInternal(source: IHandleReference, 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; @@ -27402,7 +29043,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', @@ -27435,12 +29076,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', @@ -27450,7 +29091,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { 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 ResourceWithEnvironment(result, this._client); @@ -27517,7 +29158,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; const arg = new TestEnvironmentContext(argHandle, this._client); @@ -27532,7 +29173,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._testWithEnvironmentCallbackInternal(callback)); } @@ -27578,38 +29219,33 @@ 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: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 { + withEnvironmentParameter(name: string, parameter: IParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): ResourceWithEnvironmentPromise { + withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + withReference(source: IHandleReference, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } @@ -27619,12 +29255,12 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + withReferenceEndpoint(endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } @@ -27649,7 +29285,7 @@ export class ResourceWithEnvironmentPromise implements PromiseLike Promise): ResourceWithEnvironmentPromise { + testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } @@ -27660,6 +29296,27 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { + waitFor(dependency: IHandleReference): IResourceWithWaitSupportPromise; + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; + waitForStart(dependency: IHandleReference): IResourceWithWaitSupportPromise; + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IResourceWithWaitSupportPromise; +} + // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -27670,22 +29327,22 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { + private async _waitForInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): ResourceWithWaitSupportPromise { + waitFor(dependency: IHandleReference): ResourceWithWaitSupportPromise { return new ResourceWithWaitSupportPromise(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', @@ -27695,27 +29352,27 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { + private async _waitForStartInternal(dependency: IHandleReference): Promise { 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); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ResourceWithWaitSupportPromise { + waitForStart(dependency: IHandleReference): ResourceWithWaitSupportPromise { return new ResourceWithWaitSupportPromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', @@ -27725,23 +29382,23 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { const exitCode = options?.exitCode; return new ResourceWithWaitSupportPromise(this._waitForCompletionInternal(dependency, exitCode)); } @@ -27764,27 +29421,27 @@ export class ResourceWithWaitSupportPromise implements PromiseLike obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): ResourceWithWaitSupportPromise { + waitForStart(dependency: IHandleReference): ResourceWithWaitSupportPromise { return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } @@ -27855,6 +29512,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise; + toString(): string; +} + +export class ReferenceExpression implements IReferenceExpression { // Expression mode fields private readonly _format?: string; private readonly _valueProviders?: unknown[]; // Conditional mode fields private readonly _condition?: unknown; - private readonly _whenTrue?: ReferenceExpression; - private readonly _whenFalse?: ReferenceExpression; + private readonly _whenTrue?: IReferenceExpression; + private readonly _whenFalse?: IReferenceExpression; private readonly _matchValue?: string; // Handle mode fields (when wrapping a server-returned handle) @@ -55,12 +63,12 @@ export class ReferenceExpression { constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor(condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression); constructor( handleOrFormatOrCondition: Handle | string | unknown, clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, - whenTrueOrWhenFalse?: ReferenceExpression, - whenFalse?: ReferenceExpression + whenTrueOrWhenFalse?: IReferenceExpression, + whenFalse?: IReferenceExpression ) { if (typeof handleOrFormatOrCondition === 'string') { this._format = handleOrFormatOrCondition; @@ -90,7 +98,7 @@ export class ReferenceExpression { * @param values - The interpolated values (handles to value providers) * @returns A ReferenceExpression instance */ - static create(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { + static create(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { // Build the format string with {0}, {1}, etc. placeholders let format = ''; for (let i = 0; i < strings.length; i++) { @@ -118,9 +126,9 @@ export class ReferenceExpression { static createConditional( condition: unknown, matchValue: string, - whenTrue: ReferenceExpression, - whenFalse: ReferenceExpression - ): ReferenceExpression { + whenTrue: IReferenceExpression, + whenFalse: IReferenceExpression + ): IReferenceExpression { return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); } @@ -161,7 +169,7 @@ export class ReferenceExpression { * @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 { + async getValue(cancellationToken?: AbortSignal | ICancellationToken): Promise { if (!this._handle || !this._client) { throw new Error('getValue is only available on server-returned ReferenceExpression instances'); } @@ -258,7 +266,7 @@ function extractHandleForExpr(value: unknown): unknown { * await api.withEnvironment("REDIS_URL", expr); * ``` */ -export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { +export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { return ReferenceExpression.create(strings, ...values); } @@ -266,11 +274,15 @@ export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): Re // ResourceBuilderBase // ============================================================================ +export interface IHandleReference { + toJSON(): MarshalledHandle; +} + /** * Base class for resource builders (e.g., RedisBuilder, ContainerBuilder). * Provides handle management and JSON serialization. */ -export class ResourceBuilderBase { +export class ResourceBuilderBase implements IHandleReference { constructor(protected _handle: THandle, protected _client: AspireClient) {} toJSON(): MarshalledHandle { return this._handle.toJSON(); } diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts index 3df2a47d497..24a89d2cedf 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts @@ -104,6 +104,17 @@ function isAbortSignal(value: unknown): value is AbortSignal { ); } +function isCancellationTokenLike(value: unknown): value is ICancellationToken { + return ( + value !== null && + typeof value === 'object' && + 'register' in value && + typeof (value as { register?: unknown }).register === 'function' && + 'toJSON' in value && + typeof (value as { toJSON?: unknown }).toJSON === 'function' + ); +} + function isPlainObject(value: unknown): value is Record { if (value === null || typeof value !== 'object') { return false; @@ -205,7 +216,12 @@ export class Handle { * const connectionString = await connectionStringExpression.getValue(cancellationToken); * ``` */ -export class CancellationToken { +export interface ICancellationToken { + toJSON(): string | undefined; + register(client?: AspireClient): string | undefined; +} + +export class CancellationToken implements ICancellationToken { private readonly _signal?: AbortSignal; private readonly _remoteTokenId?: string; @@ -230,8 +246,8 @@ export class CancellationToken { * 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) { + static fromValue(value: unknown): ICancellationToken { + if (isCancellationTokenLike(value)) { return value; } @@ -569,7 +585,7 @@ function resolveCancellationClient(client?: AspireClient): 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 */ -export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | ICancellationToken): string | undefined; /** * Registers cancellation support using the single connected AspireClient. * @@ -586,21 +602,21 @@ export function registerCancellation(client: AspireClient, signalOrToken?: Abort * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation(signalOrToken?: AbortSignal | ICancellationToken): string | undefined; export function registerCancellation( - clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, - maybeSignalOrToken?: AbortSignal | CancellationToken + clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, + maybeSignalOrToken?: AbortSignal | ICancellationToken ): string | undefined { const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; const signalOrToken = client ? maybeSignalOrToken - : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; if (!signalOrToken) { return undefined; } - if (signalOrToken instanceof CancellationToken) { + if (isCancellationTokenLike(signalOrToken)) { return signalOrToken.register(client); } @@ -648,7 +664,7 @@ async function marshalTransportValue( return value; } - if (value instanceof CancellationToken) { + if (isCancellationTokenLike(value)) { const cancellationId = value.register(client); if (cancellationId !== undefined) { cancellationIds.push(cancellationId); From 902834c55112f8d6f07e3de9266eecb7f6907899 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 26 Mar 2026 22:02:00 -0700 Subject: [PATCH 2/4] Address TypeScript runtime review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Resources/base.ts | 17 +++++- .../Resources/transport.ts | 61 ++++++++++++------- .../Snapshots/base.verified.ts | 17 +++++- .../Snapshots/transport.verified.ts | 61 ++++++++++++------- 4 files changed, 112 insertions(+), 44 deletions(-) diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts index e380bd12749..6eba4421328 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts @@ -123,13 +123,28 @@ export class ReferenceExpression implements IReferenceExpression { * @param matchValue - The value to compare the condition against (defaults to "True") * @returns A ReferenceExpression instance in conditional mode */ + static createConditional( + condition: unknown, + whenTrue: IReferenceExpression, + whenFalse: IReferenceExpression + ): IReferenceExpression; static createConditional( condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression + ): IReferenceExpression; + static createConditional( + condition: unknown, + matchValueOrWhenTrue: string | IReferenceExpression, + whenTrueOrWhenFalse: IReferenceExpression, + whenFalse?: IReferenceExpression ): IReferenceExpression { - return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + if (typeof matchValueOrWhenTrue === 'string') { + return new ReferenceExpression(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); + } + + return new ReferenceExpression(condition, 'True', matchValueOrWhenTrue, whenTrueOrWhenFalse); } /** diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts index 80eca54a17a..20d00dd13ac 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts @@ -575,6 +575,22 @@ function resolveCancellationClient(client?: AspireClient): AspireClient { ); } +function isAspireClientLike(value: unknown): value is AspireClient { + if (!value || typeof value !== 'object') { + return false; + } + + const candidate = value as { + invokeCapability?: unknown; + cancelToken?: unknown; + connected?: unknown; + }; + + return typeof candidate.invokeCapability === 'function' + && typeof candidate.cancelToken === 'function' + && typeof candidate.connected === 'boolean'; +} + /** * Registers cancellation support for a local signal or SDK cancellation token. * Returns a cancellation ID that should be passed to methods accepting cancellation input. @@ -590,7 +606,7 @@ export function registerCancellation(client: AspireClient, signalOrToken?: Abort * 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 + * @returns The cancellation ID, or undefined if no value was provided, the signal was already aborted, or the token maps to CancellationToken.None * * @example * const controller = new AbortController(); @@ -607,7 +623,7 @@ export function registerCancellation( clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, maybeSignalOrToken?: AbortSignal | ICancellationToken ): string | undefined { - const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const client = isAspireClientLike(clientOrSignalOrToken) ? clientOrSignalOrToken : undefined; const signalOrToken = client ? maybeSignalOrToken : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; @@ -624,7 +640,7 @@ export function registerCancellation( const cancellationClient = resolveCancellationClient(client); if (signal.aborted) { - throw createAbortError('The operation was aborted before it was sent to the AppHost.'); + return undefined; } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -677,29 +693,32 @@ async function marshalTransportValue( throw createCircularReferenceError(capabilityId, path); } - const nextAncestors = new Set(ancestors); - nextAncestors.add(value); + ancestors.add(value); - if (hasTransportValue(value)) { - return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, nextAncestors); - } + try { + if (hasTransportValue(value)) { + return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, ancestors); + } - if (Array.isArray(value)) { - return await Promise.all( - value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, nextAncestors)) - ); - } + if (Array.isArray(value)) { + return await Promise.all( + value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, ancestors)) + ); + } - 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) - ); + if (isPlainObject(value)) { + const entries = await Promise.all( + Object.entries(value).map(async ([key, nestedValue]) => + [key, await marshalTransportValue(nestedValue, client, cancellationIds, capabilityId, `${path}.${key}`, ancestors)] as const) + ); - return Object.fromEntries(entries); - } + return Object.fromEntries(entries); + } - return value; + return value; + } finally { + ancestors.delete(value); + } } /** diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts index e380bd12749..6eba4421328 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts @@ -123,13 +123,28 @@ export class ReferenceExpression implements IReferenceExpression { * @param matchValue - The value to compare the condition against (defaults to "True") * @returns A ReferenceExpression instance in conditional mode */ + static createConditional( + condition: unknown, + whenTrue: IReferenceExpression, + whenFalse: IReferenceExpression + ): IReferenceExpression; static createConditional( condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression + ): IReferenceExpression; + static createConditional( + condition: unknown, + matchValueOrWhenTrue: string | IReferenceExpression, + whenTrueOrWhenFalse: IReferenceExpression, + whenFalse?: IReferenceExpression ): IReferenceExpression { - return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + if (typeof matchValueOrWhenTrue === 'string') { + return new ReferenceExpression(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); + } + + return new ReferenceExpression(condition, 'True', matchValueOrWhenTrue, whenTrueOrWhenFalse); } /** diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts index 24a89d2cedf..440989abacd 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts @@ -575,6 +575,22 @@ function resolveCancellationClient(client?: AspireClient): AspireClient { ); } +function isAspireClientLike(value: unknown): value is AspireClient { + if (!value || typeof value !== 'object') { + return false; + } + + const candidate = value as { + invokeCapability?: unknown; + cancelToken?: unknown; + connected?: unknown; + }; + + return typeof candidate.invokeCapability === 'function' + && typeof candidate.cancelToken === 'function' + && typeof candidate.connected === 'boolean'; +} + /** * Registers cancellation support for a local signal or SDK cancellation token. * Returns a cancellation ID that should be passed to methods accepting cancellation input. @@ -590,7 +606,7 @@ export function registerCancellation(client: AspireClient, signalOrToken?: Abort * 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 + * @returns The cancellation ID, or undefined if no value was provided, the signal was already aborted, or the token maps to CancellationToken.None * * @example * const controller = new AbortController(); @@ -607,7 +623,7 @@ export function registerCancellation( clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, maybeSignalOrToken?: AbortSignal | ICancellationToken ): string | undefined { - const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const client = isAspireClientLike(clientOrSignalOrToken) ? clientOrSignalOrToken : undefined; const signalOrToken = client ? maybeSignalOrToken : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; @@ -624,7 +640,7 @@ export function registerCancellation( const cancellationClient = resolveCancellationClient(client); if (signal.aborted) { - throw createAbortError('The operation was aborted before it was sent to the AppHost.'); + return undefined; } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -677,29 +693,32 @@ async function marshalTransportValue( throw createCircularReferenceError(capabilityId, path); } - const nextAncestors = new Set(ancestors); - nextAncestors.add(value); + ancestors.add(value); - if (hasTransportValue(value)) { - return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, nextAncestors); - } + try { + if (hasTransportValue(value)) { + return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, ancestors); + } - if (Array.isArray(value)) { - return await Promise.all( - value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, nextAncestors)) - ); - } + if (Array.isArray(value)) { + return await Promise.all( + value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, ancestors)) + ); + } - 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) - ); + if (isPlainObject(value)) { + const entries = await Promise.all( + Object.entries(value).map(async ([key, nestedValue]) => + [key, await marshalTransportValue(nestedValue, client, cancellationIds, capabilityId, `${path}.${key}`, ancestors)] as const) + ); - return Object.fromEntries(entries); - } + return Object.fromEntries(entries); + } - return value; + return value; + } finally { + ancestors.delete(value); + } } /** From bb0e14cfcfc0e6658cad2f06f6f9ce026a5773b3 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 26 Mar 2026 22:58:40 -0700 Subject: [PATCH 3/4] Address latest TypeScript review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../AtsTypeScriptCodeGenerator.cs | 13 ++++-- .../Resources/transport.ts | 41 +++++++++---------- .../Snapshots/transport.verified.ts | 41 +++++++++---------- 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs index ff402b7bc78..c02a2d1b111 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs @@ -1058,14 +1058,21 @@ private void GenerateBuilderInterface(BuilderModel builder) private void GenerateBuilderPromiseInterface(BuilderModel builder) { + var capabilities = builder.Capabilities.Where(c => + c.CapabilityKind != AtsCapabilityKind.PropertyGetter && + c.CapabilityKind != AtsCapabilityKind.PropertySetter).ToList(); + + if (capabilities.Count == 0) + { + return; + } + var interfaceName = GetInterfaceName(builder.BuilderClassName); var promiseInterfaceName = GetPromiseInterfaceName(builder.BuilderClassName); WriteLine($"export interface {promiseInterfaceName} extends PromiseLike<{interfaceName}> {{"); - foreach (var capability in builder.Capabilities.Where(c => - c.CapabilityKind != AtsCapabilityKind.PropertyGetter && - c.CapabilityKind != AtsCapabilityKind.PropertySetter)) + foreach (var capability in capabilities) { var (requiredParams, optionalParams) = SeparateParameters(capability.Parameters); var hasOptionals = optionalParams.Count > 0; diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts index 20d00dd13ac..7ee687fa852 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts @@ -640,7 +640,7 @@ export function registerCancellation( 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()}`; @@ -693,32 +693,29 @@ async function marshalTransportValue( throw createCircularReferenceError(capabilityId, path); } - ancestors.add(value); - - try { - if (hasTransportValue(value)) { - return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, ancestors); - } + const nextAncestors = new Set(ancestors); + nextAncestors.add(value); - if (Array.isArray(value)) { - return await Promise.all( - value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, ancestors)) - ); - } + if (hasTransportValue(value)) { + return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, 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}`, ancestors)] as const) - ); + if (Array.isArray(value)) { + return await Promise.all( + value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, nextAncestors)) + ); + } - return Object.fromEntries(entries); - } + 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 value; - } finally { - ancestors.delete(value); + return Object.fromEntries(entries); } + + return value; } /** diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts index 440989abacd..71f762b8009 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts @@ -640,7 +640,7 @@ export function registerCancellation( 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()}`; @@ -693,32 +693,29 @@ async function marshalTransportValue( throw createCircularReferenceError(capabilityId, path); } - ancestors.add(value); - - try { - if (hasTransportValue(value)) { - return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, ancestors); - } + const nextAncestors = new Set(ancestors); + nextAncestors.add(value); - if (Array.isArray(value)) { - return await Promise.all( - value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, ancestors)) - ); - } + if (hasTransportValue(value)) { + return await marshalTransportValue(await value.toTransportValue(), client, cancellationIds, capabilityId, path, 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}`, ancestors)] as const) - ); + if (Array.isArray(value)) { + return await Promise.all( + value.map((item, index) => marshalTransportValue(item, client, cancellationIds, capabilityId, `${path}[${index}]`, nextAncestors)) + ); + } - return Object.fromEntries(entries); - } + 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 value; - } finally { - ancestors.delete(value); + return Object.fromEntries(entries); } + + return value; } /** From c89d8c03cdd1a03833ba18c5a6aa5d106d5d7094 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Fri, 27 Mar 2026 10:17:41 -0700 Subject: [PATCH 4/4] Retarget TS codegen fix to main Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 19 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 19 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 19 - .../ValidationAppHost/aspire.config.json | 19 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 19 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 19 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 19 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../.modules/.codegen-hash | 1 - .../.modules/aspire.ts | 21672 ---------------- .../Aspire.Hosting.SqlServer/.modules/base.ts | 586 - .../.modules/transport.ts | 1019 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 18 - .../ValidationAppHost/aspire.config.json | 21 - .../AtsTypeScriptCodeGenerator.cs | 97 +- .../Resources/base.ts | 121 +- .../Resources/transport.ts | 66 +- .../AtsTypeScriptCodeGeneratorTests.cs | 24 +- .../Snapshots/AtsGeneratedAspire.verified.ts | 1334 +- ...TwoPassScanningGeneratedAspire.verified.ts | 18260 +++++++------ .../Snapshots/base.verified.ts | 123 +- .../Snapshots/transport.verified.ts | 66 +- 60 files changed, 10891 insertions(+), 33352 deletions(-) delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json deleted file mode 100644 index 90a92f76c30..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppConfiguration/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.AppConfiguration": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json deleted file mode 100644 index c0b2dab06a6..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppContainers/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:49511;http://localhost:51415", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:48887", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:33229" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.AppContainers": "", - "Aspire.Hosting.Azure.OperationalInsights": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json deleted file mode 100644 index 4b3029c52fd..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.AppService/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:49511;http://localhost:51415", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:48887", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:33229" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.AppService": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json deleted file mode 100644 index dccb0d3c2ed..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ApplicationInsights/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:43145;http://localhost:38016", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:43154", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:41056" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.ApplicationInsights": "", - "Aspire.Hosting.Azure.OperationalInsights": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json deleted file mode 100644 index 8a35fe619ef..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:55134;http://localhost:18351", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:34251", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:60108" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.CognitiveServices": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json deleted file mode 100644 index 09e159192da..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ContainerRegistry/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.ContainerRegistry": "", - "Aspire.Hosting.Azure.AppContainers": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json deleted file mode 100644 index 999262fdac7..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CosmosDB/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:52066;http://localhost:47700", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62976", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34207" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.CosmosDB": "", - "Aspire.Hosting.Azure.KeyVault": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json deleted file mode 100644 index b1f8bd42a1e..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.EventHubs": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json deleted file mode 100644 index 7af441395ff..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Functions/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:43912;http://localhost:19322", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:30254", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:15931" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.Functions": "", - "Aspire.Hosting.Azure.Storage": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json deleted file mode 100644 index c72f101e58f..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:52800;http://localhost:51322", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10120", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:11479" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.KeyVault": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json deleted file mode 100644 index 2f865da8beb..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.Kusto": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json deleted file mode 100644 index 02118f93186..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.OperationalInsights/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:52066;http://localhost:47700", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62976", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34207" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.OperationalInsights": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json deleted file mode 100644 index 20b26516d67..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.PostgreSQL/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:52067;http://localhost:47701", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62977", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34208" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.PostgreSQL": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json deleted file mode 100644 index 2f25f8f4007..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.Redis": "", - "Aspire.Hosting.Azure.KeyVault": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json deleted file mode 100644 index 5e2741ff33a..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Search/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.Search": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json deleted file mode 100644 index 90a06a55176..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:24190;http://localhost:42530", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:60807", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:16724" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.ServiceBus": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json deleted file mode 100644 index 9a3103790a9..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.SignalR/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.SignalR": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json deleted file mode 100644 index ce2c8af01da..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:58695;http://localhost:30637", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:44501", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:55515" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.Sql": "", - "Aspire.Hosting.Azure.Storage": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json deleted file mode 100644 index ceee2f18d08..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:52066;http://localhost:47700", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:62976", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:34207" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.Storage": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json deleted file mode 100644 index eead8e72b01..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.WebPubSub/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure.WebPubSub": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json deleted file mode 100644 index 711232c0e1a..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Azure": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json deleted file mode 100644 index 7533e4034df..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.DevTunnels/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.DevTunnels": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json deleted file mode 100644 index a38b51803e0..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Docker/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29650;http://localhost:28831", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10875", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13219" - } - } - }, - "packages": { - "Aspire.Hosting.Docker": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json deleted file mode 100644 index c072bdb4e2b..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Foundry": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json deleted file mode 100644 index 25ad85a7f62..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Garnet/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Garnet": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json deleted file mode 100644 index 4ffbf86d15a..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.GitHub.Models": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json deleted file mode 100644 index dc13f6ddea4..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.JavaScript/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29670;http://localhost:28851", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10895", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13239" - } - } - }, - "packages": { - "Aspire.Hosting.JavaScript": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json deleted file mode 100644 index 848ee3d0fce..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Kafka/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:16114;http://localhost:53304", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:18137", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:39824" - } - } - }, - "packages": { - "Aspire.Hosting.Kafka": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json deleted file mode 100644 index 47a723d877d..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Keycloak/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:44486;http://localhost:17648", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:12771", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:44457" - } - } - }, - "packages": { - "Aspire.Hosting.Keycloak": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json deleted file mode 100644 index de646c6a39b..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Kubernetes/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29650;http://localhost:28831", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10875", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13219" - } - } - }, - "packages": { - "Aspire.Hosting.Kubernetes": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json deleted file mode 100644 index bdab4f58165..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Maui/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:17001;http://localhost:17000", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:17003", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17004" - } - } - }, - "packages": { - "Aspire.Hosting.Maui": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json deleted file mode 100644 index 1cb1e8bca7a..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Milvus/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Milvus": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json deleted file mode 100644 index 7d07f8c3f87..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.MongoDB/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.MongoDB": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json deleted file mode 100644 index 4bcc40ab752..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.MySql/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.MySql": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json deleted file mode 100644 index d8640d44a58..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Nats/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Nats": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json deleted file mode 100644 index 1e855592fc3..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.OpenAI/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.OpenAI": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json deleted file mode 100644 index 7589b8e04ad..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Oracle/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Oracle": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json deleted file mode 100644 index 46bb4da9991..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Orleans/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Orleans": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json deleted file mode 100644 index 7e80ed7454a..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.PostgreSQL/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:33490;http://localhost:28305", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21575", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17364" - } - } - }, - "packages": { - "Aspire.Hosting.PostgreSQL": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json deleted file mode 100644 index accb86a6fa4..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Python/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Python": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json deleted file mode 100644 index bd9623a4f7d..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Qdrant/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Qdrant": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json deleted file mode 100644 index 1fa13dd959e..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.RabbitMQ/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:18076;http://localhost:48822", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:56384", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:64883" - } - } - }, - "packages": { - "Aspire.Hosting.RabbitMQ": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json deleted file mode 100644 index ced7648752f..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Redis/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29650;http://localhost:28831", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10875", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13219" - } - } - }, - "packages": { - "Aspire.Hosting.Redis": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json deleted file mode 100644 index 609d38e1e0a..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Seq/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Seq": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash deleted file mode 100644 index 3f17e86e478..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/.codegen-hash +++ /dev/null @@ -1 +0,0 @@ -154718CD9A4E1EEC05481800BD54DCC8B0899333A6698A5BE99F75680DCE5C8F \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts deleted file mode 100644 index 82809546dcb..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/aspire.ts +++ /dev/null @@ -1,21672 +0,0 @@ -// aspire.ts - Capability-based Aspire SDK -// This SDK uses the ATS (Aspire Type System) capability API. -// Capabilities are endpoints like 'Aspire.Hosting/createBuilder'. -// -// GENERATED CODE - DO NOT EDIT - -import { - AspireClient as AspireClientRpc, - Handle, - MarshalledHandle, - AppHostUsageError, - CancellationToken, - CapabilityError, - registerCallback, - wrapIfHandle, - registerHandleWrapper -} from './transport.js'; - -import type { - ICancellationToken, - IReferenceExpression -} from './base.js'; - -import { - ResourceBuilderBase, - ReferenceExpression, - refExpr, - AspireDict, - AspireList -} from './base.js'; - -// ============================================================================ -// Handle Type Aliases (Internal - not exported to users) -// ============================================================================ - -/** Handle to SqlServerDatabaseResource */ -type SqlServerDatabaseResourceHandle = Handle<'Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerDatabaseResource'>; - -/** Handle to SqlServerServerResource */ -type SqlServerServerResourceHandle = Handle<'Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerServerResource'>; - -/** 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'>; - -/** Handle to ContainerResource */ -type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource'>; - -/** Handle to CSharpAppResource */ -type CSharpAppResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource'>; - -/** Handle to DistributedApplicationModel */ -type DistributedApplicationModelHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel'>; - -/** Handle to DotnetToolResource */ -type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; - -/** Handle to EndpointReference */ -type EndpointReferenceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference'>; - -/** Handle to EndpointReferenceExpression */ -type EndpointReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression'>; - -/** Handle to EnvironmentCallbackContext */ -type EnvironmentCallbackContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext'>; - -/** Handle to ExecutableResource */ -type ExecutableResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource'>; - -/** Handle to ExecuteCommandContext */ -type ExecuteCommandContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext'>; - -/** Handle to IComputeResource */ -type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource'>; - -/** Handle to IContainerFilesDestinationResource */ -type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; - -/** Handle to InitializeResourceEvent */ -type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; - -/** Handle to IResource */ -type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; - -/** Handle to IResourceWithArgs */ -type IResourceWithArgsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs'>; - -/** Handle to IResourceWithConnectionString */ -type IResourceWithConnectionStringHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString'>; - -/** Handle to IResourceWithEndpoints */ -type IResourceWithEndpointsHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints'>; - -/** Handle to IResourceWithEnvironment */ -type IResourceWithEnvironmentHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment'>; - -/** Handle to IResourceWithWaitSupport */ -type IResourceWithWaitSupportHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport'>; - -/** Handle to ParameterResource */ -type ParameterResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource'>; - -/** Handle to ProjectResource */ -type ProjectResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource'>; - -/** Handle to ReferenceExpression */ -type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression'>; - -/** Handle to ReferenceExpressionBuilder */ -type ReferenceExpressionBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder'>; - -/** Handle to 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'>; - -/** Handle to DistributedApplication */ -type DistributedApplicationHandle = Handle<'Aspire.Hosting/Aspire.Hosting.DistributedApplication'>; - -/** Handle to DistributedApplicationExecutionContext */ -type DistributedApplicationExecutionContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext'>; - -/** Handle to DistributedApplicationEventSubscription */ -type DistributedApplicationEventSubscriptionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Eventing.DistributedApplicationEventSubscription'>; - -/** Handle to IDistributedApplicationEventing */ -type IDistributedApplicationEventingHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing'>; - -/** Handle to ExternalServiceResource */ -type ExternalServiceResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ExternalServiceResource'>; - -/** Handle to IDistributedApplicationBuilder */ -type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder'>; - -/** Handle to IResourceWithContainerFiles */ -type IResourceWithContainerFilesHandle = Handle<'Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles'>; - -/** Handle to 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'>; - -/** Handle to Dict */ -type DictstringanyHandle = Handle<'Aspire.Hosting/Dict'>; - -/** Handle to List */ -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[]'>; - -/** Handle to IServiceProvider */ -type IServiceProviderHandle = Handle<'System.ComponentModel/System.IServiceProvider'>; - -// ============================================================================ -// Enum Types -// ============================================================================ - -/** Enum type for CertificateTrustScope */ -export enum CertificateTrustScope { - None = "None", - Append = "Append", - Override = "Override", - System = "System", -} - -/** Enum type for ContainerLifetime */ -export enum ContainerLifetime { - Session = "Session", - Persistent = "Persistent", -} - -/** Enum type for DistributedApplicationOperation */ -export enum DistributedApplicationOperation { - Run = "Run", - Publish = "Publish", -} - -/** Enum type for EndpointProperty */ -export enum EndpointProperty { - Url = "Url", - Host = "Host", - IPV4Host = "IPV4Host", - Port = "Port", - Scheme = "Scheme", - TargetPort = "TargetPort", - HostAndPort = "HostAndPort", - TlsEnabled = "TlsEnabled", -} - -/** Enum type for IconVariant */ -export enum IconVariant { - Regular = "Regular", - Filled = "Filled", -} - -/** Enum type for ImagePullPolicy */ -export enum ImagePullPolicy { - Default = "Default", - Always = "Always", - Missing = "Missing", - Never = "Never", -} - -/** Enum type for OtlpProtocol */ -export enum OtlpProtocol { - Grpc = "Grpc", - HttpProtobuf = "HttpProtobuf", - HttpJson = "HttpJson", -} - -/** Enum type for ProbeType */ -export enum ProbeType { - Startup = "Startup", - Readiness = "Readiness", - Liveness = "Liveness", -} - -/** Enum type for ProtocolType */ -export enum ProtocolType { - IP = "IP", - IPv6HopByHopOptions = "IPv6HopByHopOptions", - Unspecified = "Unspecified", - Icmp = "Icmp", - Igmp = "Igmp", - Ggp = "Ggp", - IPv4 = "IPv4", - Tcp = "Tcp", - Pup = "Pup", - Udp = "Udp", - Idp = "Idp", - IPv6 = "IPv6", - IPv6RoutingHeader = "IPv6RoutingHeader", - IPv6FragmentHeader = "IPv6FragmentHeader", - IPSecEncapsulatingSecurityPayload = "IPSecEncapsulatingSecurityPayload", - IPSecAuthenticationHeader = "IPSecAuthenticationHeader", - IcmpV6 = "IcmpV6", - IPv6NoNextHeader = "IPv6NoNextHeader", - IPv6DestinationOptions = "IPv6DestinationOptions", - ND = "ND", - Raw = "Raw", - Ipx = "Ipx", - Spx = "Spx", - SpxII = "SpxII", - Unknown = "Unknown", -} - -/** Enum type for UrlDisplayLocation */ -export enum UrlDisplayLocation { - SummaryAndDetails = "SummaryAndDetails", - DetailsOnly = "DetailsOnly", -} - -/** Enum type for WaitBehavior */ -export enum WaitBehavior { - WaitOnResourceUnavailable = "WaitOnResourceUnavailable", - StopOnResourceUnavailable = "StopOnResourceUnavailable", -} - -// ============================================================================ -// DTO Interfaces -// ============================================================================ - -/** DTO interface for CommandOptions */ -export interface CommandOptions { - description?: string; - parameter?: any; - confirmationMessage?: string; - iconName?: string; - iconVariant?: IconVariant; - isHighlighted?: boolean; - updateState?: any; -} - -/** DTO interface for CreateBuilderOptions */ -export interface CreateBuilderOptions { - args?: string[]; - projectDirectory?: string; - appHostFilePath?: string; - containerRegistryOverride?: string; - disableDashboard?: boolean; - dashboardApplicationName?: string; - allowUnsecuredTransport?: boolean; - enableResourceLogging?: boolean; -} - -/** DTO interface for ExecuteCommandResult */ -export interface ExecuteCommandResult { - success?: boolean; - canceled?: boolean; - errorMessage?: string; -} - -/** DTO interface for ResourceEventDto */ -export interface ResourceEventDto { - resourceName?: string; - resourceId?: string; - state?: string; - stateStyle?: string; - healthStatus?: string; - exitCode?: number; -} - -/** DTO interface for ResourceUrlAnnotation */ -export interface ResourceUrlAnnotation { - url?: string; - displayText?: string; - endpoint?: EndpointReferenceHandle; - displayLocation?: UrlDisplayLocation; -} - -// ============================================================================ -// Options Interfaces -// ============================================================================ - -export interface AddConnectionStringOptions { - environmentVariableName?: string; -} - -export interface AddContainerRegistryFromStringOptions { - repository?: string; -} - -export interface AddContainerRegistryOptions { - repository?: IParameterResource; -} - -export interface AddDatabaseOptions { - databaseName?: string; -} - -export interface AddDockerfileOptions { - dockerfilePath?: string; - stage?: string; -} - -export interface AddParameterFromConfigurationOptions { - secret?: boolean; -} - -export interface AddParameterOptions { - secret?: boolean; -} - -export interface AddParameterWithValueOptions { - publishValueAsDefault?: boolean; - secret?: boolean; -} - -export interface AddSqlServerOptions { - password?: IParameterResource; - port?: number; -} - -export interface AppendFormattedOptions { - format?: string; -} - -export interface AppendValueProviderOptions { - format?: string; -} - -export interface CompleteStepMarkdownOptions { - completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface CompleteStepOptions { - completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface CompleteTaskMarkdownOptions { - completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface CompleteTaskOptions { - completionMessage?: string; - completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface CreateMarkdownTaskOptions { - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface CreateTaskOptions { - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface PublishAsDockerFileOptions { - configure?: (obj: IContainerResource) => Promise; -} - -export interface PublishResourceUpdateOptions { - state?: string; - stateStyle?: string; -} - -export interface RunOptions { - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface SaveStateJsonOptions { - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface UpdateTaskMarkdownOptions { - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface UpdateTaskOptions { - cancellationToken?: AbortSignal | ICancellationToken; -} - -export interface WaitForCompletionOptions { - exitCode?: number; -} - -export interface WaitForResourceStateOptions { - targetState?: string; -} - -export interface WithBindMountOptions { - isReadOnly?: boolean; -} - -export interface WithCommandOptions { - commandOptions?: CommandOptions; -} - -export interface WithDataBindMountOptions { - isReadOnly?: boolean; -} - -export interface WithDataVolumeOptions { - name?: string; - isReadOnly?: boolean; -} - -export interface WithDescriptionOptions { - enableMarkdown?: boolean; -} - -export interface WithDockerfileBaseImageOptions { - buildImage?: string; - runtimeImage?: string; -} - -export interface WithDockerfileOptions { - dockerfilePath?: string; - stage?: string; -} - -export interface WithEndpointOptions { - port?: number; - targetPort?: number; - scheme?: string; - name?: string; - env?: string; - isProxied?: boolean; - isExternal?: boolean; - protocol?: ProtocolType; -} - -export interface WithExternalServiceHttpHealthCheckOptions { - path?: string; - statusCode?: number; -} - -export interface WithHostPortOptions { - port?: number; -} - -export interface WithHttpEndpointOptions { - port?: number; - targetPort?: number; - name?: string; - env?: string; - isProxied?: boolean; -} - -export interface WithHttpHealthCheckOptions { - path?: string; - statusCode?: number; - endpointName?: string; -} - -export interface WithHttpProbeOptions { - path?: string; - initialDelaySeconds?: number; - periodSeconds?: number; - timeoutSeconds?: number; - failureThreshold?: number; - successThreshold?: number; - endpointName?: string; -} - -export interface WithHttpsDeveloperCertificateOptions { - password?: IParameterResource; -} - -export interface WithHttpsEndpointOptions { - port?: number; - targetPort?: number; - name?: string; - env?: string; - isProxied?: boolean; -} - -export interface WithIconNameOptions { - iconVariant?: IconVariant; -} - -export interface WithImageOptions { - tag?: string; -} - -export interface WithMcpServerOptions { - path?: string; - endpointName?: string; -} - -export interface WithPipelineStepFactoryOptions { - dependsOn?: string[]; - requiredBy?: string[]; - tags?: string[]; - description?: string; -} - -export interface WithReferenceOptions { - connectionName?: string; - optional?: boolean; - name?: string; -} - -export interface WithRequiredCommandOptions { - helpLink?: string; -} - -export interface WithUrlExpressionOptions { - displayText?: string; -} - -export interface WithUrlOptions { - displayText?: string; -} - -export interface WithVolumeOptions { - name?: string; - isReadOnly?: boolean; -} - -// ============================================================================ -// IAfterResourcesCreatedEvent -// ============================================================================ - -export interface IAfterResourcesCreatedEvent { - toJSON(): MarshalledHandle; - services: { - get: () => Promise; - }; - model: { - get: () => Promise; - }; -} - -// ============================================================================ -// 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); - }, - }; - -} - -// ============================================================================ -// IBeforeResourceStartedEvent -// ============================================================================ - -export interface IBeforeResourceStartedEvent { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; -} - -// ============================================================================ -// 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); - }, - }; - -} - -// ============================================================================ -// IBeforeStartEvent -// ============================================================================ - -export interface IBeforeStartEvent { - toJSON(): MarshalledHandle; - services: { - get: () => Promise; - }; - model: { - get: () => Promise; - }; -} - -// ============================================================================ -// 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); - }, - }; - -} - -// ============================================================================ -// ICommandLineArgsCallbackContext -// ============================================================================ - -export interface ICommandLineArgsCallbackContext { - toJSON(): MarshalledHandle; - readonly args: AspireList; - cancellationToken: { - get: () => Promise; - }; - executionContext: { - get: () => Promise; - set: (value: IDistributedApplicationExecutionContext) => Promise; - }; - logger: { - get: () => Promise; - set: (value: ILogger) => Promise; - }; - resource: { - get: () => Promise; - }; -} - -// ============================================================================ -// CommandLineArgsCallbackContext -// ============================================================================ - -/** - * Type class for CommandLineArgsCallbackContext. - */ -export class CommandLineArgsCallbackContext { - constructor(private _handle: CommandLineArgsCallbackContextHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the Args property */ - private _args?: AspireList; - get args(): AspireList { - if (!this._args) { - this._args = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.args', - 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.args' - ); - } - return this._args; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - const result = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', - { context: this._handle } - ); - return CancellationToken.fromValue(result); - }, - }; - - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.executionContext', - { context: this._handle } - ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, - set: async (value: IDistributedApplicationExecutionContext): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setExecutionContext', - { context: this._handle, value } - ); - } - }; - - /** 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); - }, - set: async (value: ILogger): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setLogger', - { context: this._handle, value } - ); - } - }; - - /** 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); - }, - }; - -} - -// ============================================================================ -// IConnectionStringAvailableEvent -// ============================================================================ - -export interface IConnectionStringAvailableEvent { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; -} - -// ============================================================================ -// 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); - }, - }; - -} - -// ============================================================================ -// IDistributedApplication -// ============================================================================ - -export interface IDistributedApplication { - toJSON(): MarshalledHandle; - run(options?: RunOptions): IDistributedApplicationPromise; -} - -export interface IDistributedApplicationPromise extends PromiseLike { - run(options?: RunOptions): IDistributedApplicationPromise; -} - -// ============================================================================ -// DistributedApplication -// ============================================================================ - -/** - * Type class for DistributedApplication. - */ -export class DistributedApplication { - constructor(private _handle: DistributedApplicationHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Runs the distributed application */ - /** @internal */ - async _runInternal(cancellationToken?: AbortSignal | ICancellationToken): Promise { - const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); - await this._client.invokeCapability( - 'Aspire.Hosting/run', - rpcArgs - ); - return this; - } - - run(options?: RunOptions): DistributedApplicationPromise { - const cancellationToken = options?.cancellationToken; - return new DistributedApplicationPromise(this._runInternal(cancellationToken)); - } - -} - -/** - * Thenable wrapper for DistributedApplication that enables fluent chaining. - */ -export class DistributedApplicationPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: DistributedApplication) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Runs the distributed application */ - run(options?: RunOptions): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.run(options))); - } - -} - -// ============================================================================ -// IDistributedApplicationExecutionContext -// ============================================================================ - -export interface IDistributedApplicationExecutionContext { - toJSON(): MarshalledHandle; - publisherName: { - get: () => Promise; - set: (value: string) => Promise; - }; - operation: { - get: () => Promise; - }; - serviceProvider: { - get: () => Promise; - }; - isPublishMode: { - get: () => Promise; - }; - isRunMode: { - get: () => Promise; - }; -} - -// ============================================================================ -// DistributedApplicationExecutionContext -// ============================================================================ - -/** - * Type class for DistributedApplicationExecutionContext. - */ -export class DistributedApplicationExecutionContext { - constructor(private _handle: DistributedApplicationExecutionContextHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the PublisherName property */ - publisherName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/DistributedApplicationExecutionContext.publisherName', - { context: this._handle } - ); - }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting/DistributedApplicationExecutionContext.setPublisherName', - { context: this._handle, value } - ); - } - }; - - /** Gets the Operation property */ - operation = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/DistributedApplicationExecutionContext.operation', - { context: this._handle } - ); - }, - }; - - /** 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 => { - return await this._client.invokeCapability( - 'Aspire.Hosting/DistributedApplicationExecutionContext.isPublishMode', - { context: this._handle } - ); - }, - }; - - /** Gets the IsRunMode property */ - isRunMode = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/DistributedApplicationExecutionContext.isRunMode', - { context: this._handle } - ); - }, - }; - -} - -// ============================================================================ -// IDistributedApplicationModel -// ============================================================================ - -export interface IDistributedApplicationModel { - toJSON(): MarshalledHandle; - getResources(): Promise; - findResourceByName(name: string): IResourcePromise; -} - -export interface IDistributedApplicationModelPromise extends PromiseLike { - getResources(): Promise; - findResourceByName(name: string): IResourcePromise; -} - -// ============================================================================ -// 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))); - } - -} - -// ============================================================================ -// IEndpointReference -// ============================================================================ - -export interface IEndpointReference { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - endpointName: { - get: () => Promise; - }; - errorMessage: { - get: () => Promise; - set: (value: string) => Promise; - }; - isAllocated: { - get: () => Promise; - }; - exists: { - get: () => Promise; - }; - isHttp: { - get: () => Promise; - }; - isHttps: { - get: () => Promise; - }; - tlsEnabled: { - get: () => Promise; - }; - port: { - get: () => Promise; - }; - targetPort: { - get: () => Promise; - }; - host: { - get: () => Promise; - }; - scheme: { - get: () => Promise; - }; - url: { - get: () => Promise; - }; - getValueAsync(options?: GetValueAsyncOptions): Promise; - getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; -} - -export interface IEndpointReferencePromise extends PromiseLike { - getValueAsync(options?: GetValueAsyncOptions): Promise; - getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; -} - -// ============================================================================ -// EndpointReference -// ============================================================================ - -/** - * Type class for EndpointReference. - */ -export class EndpointReference { - constructor(private _handle: EndpointReferenceHandle, 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/EndpointReference.resource', - { context: this._handle } - ); - return new ResourceWithEndpoints(handle, this._client); - }, - }; - - /** Gets the EndpointName property */ - endpointName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.endpointName', - { context: this._handle } - ); - }, - }; - - /** Gets the ErrorMessage property */ - errorMessage = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.errorMessage', - { context: this._handle } - ); - }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.setErrorMessage', - { context: this._handle, value } - ); - } - }; - - /** Gets the IsAllocated property */ - isAllocated = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.isAllocated', - { context: this._handle } - ); - }, - }; - - /** Gets the Exists property */ - exists = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.exists', - { context: this._handle } - ); - }, - }; - - /** Gets the IsHttp property */ - isHttp = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.isHttp', - { context: this._handle } - ); - }, - }; - - /** Gets the IsHttps property */ - isHttps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.isHttps', - { context: this._handle } - ); - }, - }; - - /** Gets the TlsEnabled property */ - tlsEnabled = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', - { context: this._handle } - ); - }, - }; - - /** Gets the Port property */ - port = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.port', - { context: this._handle } - ); - }, - }; - - /** Gets the TargetPort property */ - targetPort = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.targetPort', - { context: this._handle } - ); - }, - }; - - /** Gets the Host property */ - host = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.host', - { context: this._handle } - ); - }, - }; - - /** Gets the Scheme property */ - scheme = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.scheme', - { context: this._handle } - ); - }, - }; - - /** Gets the Url property */ - url = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.url', - { context: this._handle } - ); - }, - }; - - /** Gets the URL of the endpoint asynchronously */ - async getValueAsync(options?: GetValueAsyncOptions): Promise { - const cancellationToken = options?.cancellationToken; - const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/getValueAsync', - rpcArgs - ); - } - - /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ - async getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { - const rpcArgs: Record = { context: this._handle, enabledValue, disabledValue }; - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReference.getTlsValue', - rpcArgs - ); - } - -} - -/** - * Thenable wrapper for EndpointReference that enables fluent chaining. - */ -export class EndpointReferencePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: EndpointReference) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Gets the URL of the endpoint asynchronously */ - getValueAsync(options?: GetValueAsyncOptions): Promise { - return this._promise.then(obj => obj.getValueAsync(options)); - } - - /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ - getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { - return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); - } - -} - -// ============================================================================ -// IEndpointReferenceExpression -// ============================================================================ - -export interface IEndpointReferenceExpression { - toJSON(): MarshalledHandle; - endpoint: { - get: () => Promise; - }; - property: { - get: () => Promise; - }; - valueExpression: { - get: () => Promise; - }; -} - -// ============================================================================ -// EndpointReferenceExpression -// ============================================================================ - -/** - * Type class for EndpointReferenceExpression. - */ -export class EndpointReferenceExpression { - constructor(private _handle: EndpointReferenceExpressionHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the Endpoint property */ - endpoint = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.endpoint', - { context: this._handle } - ); - return new EndpointReference(handle, this._client); - }, - }; - - /** Gets the Property property */ - property = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.property', - { context: this._handle } - ); - }, - }; - - /** Gets the ValueExpression property */ - valueExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.valueExpression', - { context: this._handle } - ); - }, - }; - -} - -// ============================================================================ -// IEnvironmentCallbackContext -// ============================================================================ - -export interface IEnvironmentCallbackContext { - toJSON(): MarshalledHandle; - readonly environmentVariables: AspireDict; - cancellationToken: { - get: () => Promise; - }; - logger: { - get: () => Promise; - set: (value: ILogger) => Promise; - }; - resource: { - get: () => Promise; - }; - executionContext: { - get: () => Promise; - }; -} - -// ============================================================================ -// EnvironmentCallbackContext -// ============================================================================ - -/** - * Type class for EnvironmentCallbackContext. - */ -export class EnvironmentCallbackContext { - constructor(private _handle: EnvironmentCallbackContextHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the EnvironmentVariables property */ - private _environmentVariables?: AspireDict; - get environmentVariables(): AspireDict { - if (!this._environmentVariables) { - this._environmentVariables = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.environmentVariables', - 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.environmentVariables' - ); - } - return this._environmentVariables; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - 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); - }, - set: async (value: ILogger): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.setLogger', - { context: this._handle, value } - ); - } - }; - - /** 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); - }, - }; - - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.executionContext', - { context: this._handle } - ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, - }; - -} - -// ============================================================================ -// IExecuteCommandContext -// ============================================================================ - -export interface IExecuteCommandContext { - toJSON(): MarshalledHandle; - serviceProvider: { - get: () => Promise; - set: (value: IServiceProvider) => Promise; - }; - resourceName: { - get: () => Promise; - set: (value: string) => Promise; - }; - cancellationToken: { - get: () => Promise; - set: (value: AbortSignal | ICancellationToken) => Promise; - }; -} - -// ============================================================================ -// ExecuteCommandContext -// ============================================================================ - -/** - * Type class for ExecuteCommandContext. - */ -export class ExecuteCommandContext { - constructor(private _handle: ExecuteCommandContextHandle, 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/ExecuteCommandContext.serviceProvider', - { context: this._handle } - ); - return new ServiceProvider(handle, this._client); - }, - set: async (value: IServiceProvider): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setServiceProvider', - { context: this._handle, value } - ); - } - }; - - /** Gets the ResourceName property */ - resourceName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.resourceName', - { context: this._handle } - ); - }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setResourceName', - { context: this._handle, value } - ); - } - }; - - /** Gets the CancellationToken property */ - cancellationToken = { - 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 | ICancellationToken): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value: CancellationToken.fromValue(value) } - ); - } - }; - -} - -// ============================================================================ -// IInitializeResourceEvent -// ============================================================================ - -export interface IInitializeResourceEvent { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - eventing: { - get: () => Promise; - }; - logger: { - get: () => Promise; - }; - notifications: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; -} - -// ============================================================================ -// 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); - }, - }; - -} - -// ============================================================================ -// IPipelineConfigurationContext -// ============================================================================ - -export interface IPipelineConfigurationContext { - toJSON(): MarshalledHandle; - services: { - get: () => Promise; - set: (value: IServiceProvider) => Promise; - }; - steps: { - get: () => Promise; - set: (value: IPipelineStep[]) => Promise; - }; - model: { - get: () => Promise; - set: (value: IDistributedApplicationModel) => Promise; - }; - getStepsByTag(tag: string): Promise; -} - -export interface IPipelineConfigurationContextPromise extends PromiseLike { - getStepsByTag(tag: string): Promise; -} - -// ============================================================================ -// PipelineConfigurationContext -// ============================================================================ - -/** - * Type class for PipelineConfigurationContext. - */ -export class PipelineConfigurationContext { - constructor(private _handle: PipelineConfigurationContextHandle, 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.Pipelines/PipelineConfigurationContext.services', - { context: this._handle } - ); - return new ServiceProvider(handle, this._client); - }, - set: async (value: IServiceProvider): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setServices', - { context: this._handle, value } - ); - } - }; - - /** Gets the Steps property */ - steps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', - { context: this._handle } - ); - }, - set: async (value: IPipelineStep[]): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', - { context: this._handle, value } - ); - } - }; - - /** 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); - }, - set: async (value: IDistributedApplicationModel): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setModel', - { context: this._handle, value } - ); - } - }; - - /** Gets pipeline steps with the specified tag */ - async getStepsByTag(tag: string): Promise { - const rpcArgs: Record = { context: this._handle, tag }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/getStepsByTag', - rpcArgs - ); - } - -} - -/** - * Thenable wrapper for PipelineConfigurationContext that enables fluent chaining. - */ -export class PipelineConfigurationContextPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: PipelineConfigurationContext) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Gets pipeline steps with the specified tag */ - getStepsByTag(tag: string): Promise { - return this._promise.then(obj => obj.getStepsByTag(tag)); - } - -} - -// ============================================================================ -// IPipelineContext -// ============================================================================ - -export interface IPipelineContext { - toJSON(): MarshalledHandle; - model: { - get: () => Promise; - }; - executionContext: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; - logger: { - get: () => Promise; - }; - cancellationToken: { - get: () => Promise; - set: (value: AbortSignal | ICancellationToken) => Promise; - }; - summary: { - get: () => Promise; - }; -} - -// ============================================================================ -// PipelineContext -// ============================================================================ - -/** - * Type class for PipelineContext. - */ -export class PipelineContext { - constructor(private _handle: PipelineContextHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the Model property */ - model = { - get: async (): Promise => { - 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 | ICancellationToken): 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); - }, - }; - -} - -// ============================================================================ -// IPipelineStep -// ============================================================================ - -export interface IPipelineStep { - toJSON(): MarshalledHandle; - name: { - get: () => Promise; - set: (value: string) => Promise; - }; - description: { - get: () => Promise; - set: (value: string) => Promise; - }; - readonly dependsOnSteps: AspireList; - readonly requiredBySteps: AspireList; - readonly tags: AspireList; - resource: { - get: () => Promise; - set: (value: IResource) => Promise; - }; - dependsOn(stepName: string): IPipelineStepPromise; - requiredBy(stepName: string): IPipelineStepPromise; -} - -export interface IPipelineStepPromise extends PromiseLike { - dependsOn(stepName: string): IPipelineStepPromise; - requiredBy(stepName: string): IPipelineStepPromise; -} - -// ============================================================================ -// PipelineStep -// ============================================================================ - -/** - * Type class for PipelineStep. - */ -export class PipelineStep { - constructor(private _handle: PipelineStepHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the Name property */ - name = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStep.name', - { context: this._handle } - ); - }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStep.setName', - { context: this._handle, value } - ); - } - }; - - /** Gets the Description property */ - description = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStep.description', - { context: this._handle } - ); - }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStep.setDescription', - { context: this._handle, value } - ); - } - }; - - /** Gets the DependsOnSteps property */ - private _dependsOnSteps?: AspireList; - get dependsOnSteps(): AspireList { - if (!this._dependsOnSteps) { - this._dependsOnSteps = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.Pipelines/PipelineStep.dependsOnSteps', - 'Aspire.Hosting.Pipelines/PipelineStep.dependsOnSteps' - ); - } - return this._dependsOnSteps; - } - - /** Gets the RequiredBySteps property */ - private _requiredBySteps?: AspireList; - get requiredBySteps(): AspireList { - if (!this._requiredBySteps) { - this._requiredBySteps = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.Pipelines/PipelineStep.requiredBySteps', - 'Aspire.Hosting.Pipelines/PipelineStep.requiredBySteps' - ); - } - return this._requiredBySteps; - } - - /** Gets the Tags property */ - private _tags?: AspireList; - get tags(): AspireList { - if (!this._tags) { - this._tags = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.Pipelines/PipelineStep.tags', - 'Aspire.Hosting.Pipelines/PipelineStep.tags' - ); - } - return this._tags; - } - - /** 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); - }, - set: async (value: IResource): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStep.setResource', - { context: this._handle, value } - ); - } - }; - - /** Adds a dependency on another step by name */ - /** @internal */ - async _dependsOnInternal(stepName: string): Promise { - const rpcArgs: Record = { context: this._handle, stepName }; - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/dependsOn', - rpcArgs - ); - return this; - } - - dependsOn(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._dependsOnInternal(stepName)); - } - - /** Specifies that another step requires this step by name */ - /** @internal */ - async _requiredByInternal(stepName: string): Promise { - const rpcArgs: Record = { context: this._handle, stepName }; - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/requiredBy', - rpcArgs - ); - return this; - } - - requiredBy(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._requiredByInternal(stepName)); - } - -} - -/** - * Thenable wrapper for PipelineStep that enables fluent chaining. - */ -export class PipelineStepPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: PipelineStep) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Adds a dependency on another step by name */ - dependsOn(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._promise.then(obj => obj.dependsOn(stepName))); - } - - /** Specifies that another step requires this step by name */ - requiredBy(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._promise.then(obj => obj.requiredBy(stepName))); - } - -} - -// ============================================================================ -// IPipelineStepContext -// ============================================================================ - -export interface IPipelineStepContext { - toJSON(): MarshalledHandle; - pipelineContext: { - get: () => Promise; - set: (value: IPipelineContext) => Promise; - }; - reportingStep: { - get: () => Promise; - set: (value: IReportingStep) => Promise; - }; - model: { - get: () => Promise; - }; - executionContext: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; - logger: { - get: () => Promise; - }; - cancellationToken: { - get: () => Promise; - }; - summary: { - get: () => Promise; - }; -} - -// ============================================================================ -// PipelineStepContext -// ============================================================================ - -/** - * Type class for PipelineStepContext. - */ -export class PipelineStepContext { - constructor(private _handle: PipelineStepContextHandle, 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/PipelineStepContext.pipelineContext', - { context: this._handle } - ); - return new PipelineContext(handle, this._client); - }, - set: async (value: IPipelineContext): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStepContext.setPipelineContext', - { context: this._handle, value } - ); - } - }; - - /** 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); - }, - set: async (value: IReportingStep): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStepContext.setReportingStep', - { context: this._handle, value } - ); - } - }; - - /** 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 => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStepContext.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/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 => { - 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); - }, - }; - -} - -// ============================================================================ -// IPipelineStepFactoryContext -// ============================================================================ - -export interface IPipelineStepFactoryContext { - toJSON(): MarshalledHandle; - pipelineContext: { - get: () => Promise; - set: (value: IPipelineContext) => Promise; - }; - resource: { - get: () => Promise; - set: (value: IResource) => Promise; - }; -} - -// ============================================================================ -// 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); - }, - set: async (value: IPipelineContext): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setPipelineContext', - { context: this._handle, value } - ); - } - }; - - /** 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); - }, - set: async (value: IResource): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setResource', - { context: this._handle, value } - ); - } - }; - -} - -// ============================================================================ -// IPipelineSummary -// ============================================================================ - -export interface IPipelineSummary { - toJSON(): MarshalledHandle; - add(key: string, value: string): IPipelineSummaryPromise; - addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; -} - -export interface IPipelineSummaryPromise extends PromiseLike { - add(key: string, value: string): IPipelineSummaryPromise; - addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; -} - -// ============================================================================ -// 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))); - } - -} - -// ============================================================================ -// IProjectResourceOptions -// ============================================================================ - -export interface IProjectResourceOptions { - toJSON(): MarshalledHandle; - launchProfileName: { - get: () => Promise; - set: (value: string) => Promise; - }; - excludeLaunchProfile: { - get: () => Promise; - set: (value: boolean) => Promise; - }; - excludeKestrelEndpoints: { - get: () => Promise; - set: (value: boolean) => Promise; - }; -} - -// ============================================================================ -// ProjectResourceOptions -// ============================================================================ - -/** - * Type class for ProjectResourceOptions. - */ -export class ProjectResourceOptions { - constructor(private _handle: ProjectResourceOptionsHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the LaunchProfileName property */ - launchProfileName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.launchProfileName', - { context: this._handle } - ); - }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.setLaunchProfileName', - { context: this._handle, value } - ); - } - }; - - /** Gets the ExcludeLaunchProfile property */ - excludeLaunchProfile = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.excludeLaunchProfile', - { context: this._handle } - ); - }, - set: async (value: boolean): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.setExcludeLaunchProfile', - { context: this._handle, value } - ); - } - }; - - /** Gets the ExcludeKestrelEndpoints property */ - excludeKestrelEndpoints = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.excludeKestrelEndpoints', - { context: this._handle } - ); - }, - set: async (value: boolean): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.setExcludeKestrelEndpoints', - { context: this._handle, value } - ); - } - }; - -} - -// ============================================================================ -// IReferenceExpressionBuilder -// ============================================================================ - -export interface IReferenceExpressionBuilder { - toJSON(): MarshalledHandle; - isEmpty: { - get: () => Promise; - }; - appendLiteral(value: string): IReferenceExpressionBuilderPromise; - appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; - appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; - build(): Promise; -} - -export interface IReferenceExpressionBuilderPromise extends PromiseLike { - appendLiteral(value: string): IReferenceExpressionBuilderPromise; - appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; - appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; - build(): Promise; -} - -// ============================================================================ -// ReferenceExpressionBuilder -// ============================================================================ - -/** - * Type class for ReferenceExpressionBuilder. - */ -export class ReferenceExpressionBuilder { - constructor(private _handle: ReferenceExpressionBuilderHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the IsEmpty property */ - isEmpty = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ReferenceExpressionBuilder.isEmpty', - { context: this._handle } - ); - }, - }; - - /** Appends a literal string to the reference expression */ - /** @internal */ - async _appendLiteralInternal(value: string): Promise { - const rpcArgs: Record = { context: this._handle, value }; - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/appendLiteral', - rpcArgs - ); - return this; - } - - appendLiteral(value: string): ReferenceExpressionBuilderPromise { - return new ReferenceExpressionBuilderPromise(this._appendLiteralInternal(value)); - } - - /** Appends a formatted string value to the reference expression */ - /** @internal */ - async _appendFormattedInternal(value: string, format?: string): Promise { - const rpcArgs: Record = { context: this._handle, value }; - if (format !== undefined) rpcArgs.format = format; - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/appendFormatted', - rpcArgs - ); - return this; - } - - appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { - const format = options?.format; - return new ReferenceExpressionBuilderPromise(this._appendFormattedInternal(value, format)); - } - - /** Appends a value provider to the reference expression */ - /** @internal */ - async _appendValueProviderInternal(valueProvider: any, format?: string): Promise { - const rpcArgs: Record = { context: this._handle, valueProvider }; - if (format !== undefined) rpcArgs.format = format; - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/appendValueProvider', - rpcArgs - ); - return this; - } - - appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { - const format = options?.format; - return new ReferenceExpressionBuilderPromise(this._appendValueProviderInternal(valueProvider, format)); - } - - /** Builds the reference expression */ - async build(): Promise { - const rpcArgs: Record = { context: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/build', - rpcArgs - ); - } - -} - -/** - * Thenable wrapper for ReferenceExpressionBuilder that enables fluent chaining. - */ -export class ReferenceExpressionBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ReferenceExpressionBuilder) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Appends a literal string to the reference expression */ - appendLiteral(value: string): ReferenceExpressionBuilderPromise { - return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendLiteral(value))); - } - - /** Appends a formatted string value to the reference expression */ - appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { - return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendFormatted(value, options))); - } - - /** Appends a value provider to the reference expression */ - appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { - return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendValueProvider(valueProvider, options))); - } - - /** Builds the reference expression */ - build(): Promise { - return this._promise.then(obj => obj.build()); - } - -} - -// ============================================================================ -// IResourceEndpointsAllocatedEvent -// ============================================================================ - -export interface IResourceEndpointsAllocatedEvent { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; -} - -// ============================================================================ -// ResourceEndpointsAllocatedEvent -// ============================================================================ - -/** - * Type class for ResourceEndpointsAllocatedEvent. - */ -export class ResourceEndpointsAllocatedEvent { - constructor(private _handle: ResourceEndpointsAllocatedEventHandle, 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/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); - }, - }; - -} - -// ============================================================================ -// IResourceLoggerService -// ============================================================================ - -export interface IResourceLoggerService { - toJSON(): MarshalledHandle; - completeLog(resource: IResource): IResourceLoggerServicePromise; - completeLogByName(resourceName: string): IResourceLoggerServicePromise; -} - -export interface IResourceLoggerServicePromise extends PromiseLike { - completeLog(resource: IResource): IResourceLoggerServicePromise; - completeLogByName(resourceName: string): IResourceLoggerServicePromise; -} - -// ============================================================================ -// 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: IResource): Promise { - const rpcArgs: Record = { loggerService: this._handle, resource }; - await this._client.invokeCapability( - 'Aspire.Hosting/completeLog', - rpcArgs - ); - return this; - } - - completeLog(resource: IResource): 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: IResource): 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))); - } - -} - -// ============================================================================ -// IResourceNotificationService -// ============================================================================ - -export interface IResourceNotificationService { - toJSON(): MarshalledHandle; - waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): IResourceNotificationServicePromise; - waitForResourceStates(resourceName: string, targetStates: string[]): Promise; - waitForResourceHealthy(resourceName: string): Promise; - waitForDependencies(resource: IResource): IResourceNotificationServicePromise; - tryGetResourceState(resourceName: string): Promise; - publishResourceUpdate(resource: IResource, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; -} - -export interface IResourceNotificationServicePromise extends PromiseLike { - waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): IResourceNotificationServicePromise; - waitForResourceStates(resourceName: string, targetStates: string[]): Promise; - waitForResourceHealthy(resourceName: string): Promise; - waitForDependencies(resource: IResource): IResourceNotificationServicePromise; - tryGetResourceState(resourceName: string): Promise; - publishResourceUpdate(resource: IResource, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; -} - -// ============================================================================ -// 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: IResource): Promise { - const rpcArgs: Record = { notificationService: this._handle, resource }; - await this._client.invokeCapability( - 'Aspire.Hosting/waitForDependencies', - rpcArgs - ); - return this; - } - - waitForDependencies(resource: IResource): 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: IResource, 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: IResource, 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: IResource): 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: IResource, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { - return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); - } - -} - -// ============================================================================ -// IResourceReadyEvent -// ============================================================================ - -export interface IResourceReadyEvent { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; -} - -// ============================================================================ -// 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); - }, - }; - -} - -// ============================================================================ -// IResourceStoppedEvent -// ============================================================================ - -export interface IResourceStoppedEvent { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - services: { - get: () => Promise; - }; -} - -// ============================================================================ -// 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); - }, - }; - -} - -// ============================================================================ -// IResourceUrlsCallbackContext -// ============================================================================ - -export interface IResourceUrlsCallbackContext { - toJSON(): MarshalledHandle; - resource: { - get: () => Promise; - }; - readonly urls: AspireList; - cancellationToken: { - get: () => Promise; - }; - logger: { - get: () => Promise; - set: (value: ILogger) => Promise; - }; - executionContext: { - get: () => Promise; - }; -} - -// ============================================================================ -// ResourceUrlsCallbackContext -// ============================================================================ - -/** - * Type class for ResourceUrlsCallbackContext. - */ -export class ResourceUrlsCallbackContext { - constructor(private _handle: ResourceUrlsCallbackContextHandle, 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/ResourceUrlsCallbackContext.resource', - { context: this._handle } - ); - return new Resource(handle, this._client); - }, - }; - - /** Gets the Urls property */ - private _urls?: AspireList; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - 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); - }, - set: async (value: ILogger): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.setLogger', - { context: this._handle, value } - ); - } - }; - - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', - { context: this._handle } - ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, - }; - -} - -// ============================================================================ -// IUpdateCommandStateContext -// ============================================================================ - -export interface IUpdateCommandStateContext { - toJSON(): MarshalledHandle; - serviceProvider: { - get: () => Promise; - set: (value: IServiceProvider) => Promise; - }; -} - -// ============================================================================ -// 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); - }, - set: async (value: IServiceProvider): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.setServiceProvider', - { context: this._handle, value } - ); - } - }; - -} - -// ============================================================================ -// IConfiguration -// ============================================================================ - -export interface IConfiguration { - toJSON(): MarshalledHandle; - getConfigValue(key: string): Promise; - getConnectionString(name: string): Promise; - getSection(key: string): Promise; - getChildren(): Promise; - exists(key: string): Promise; -} - -export interface IConfigurationPromise extends PromiseLike { - getConfigValue(key: string): Promise; - getConnectionString(name: string): Promise; - getSection(key: string): Promise; - getChildren(): Promise; - exists(key: string): Promise; -} - -// ============================================================================ -// 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)); - } - -} - -// ============================================================================ -// IDistributedApplicationBuilder -// ============================================================================ - -export interface IDistributedApplicationBuilder { - toJSON(): MarshalledHandle; - appHostDirectory: { - get: () => Promise; - }; - environment: { - get: () => Promise; - }; - eventing: { - get: () => Promise; - }; - executionContext: { - get: () => Promise; - }; - userSecretsManager: { - get: () => Promise; - }; - build(): IDistributedApplicationPromise; - addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; - addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; - addContainer(name: string, image: string): IContainerResourcePromise; - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; - addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; - addExternalService(name: string, url: string): IExternalServiceResourcePromise; - addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; - addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; - addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; - addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; - addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; - addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; - addCSharpApp(name: string, path: string): IProjectResourcePromise; - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; - getConfiguration(): IConfigurationPromise; - subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; - subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; - addSqlServer(name: string, options?: AddSqlServerOptions): ISqlServerServerResourcePromise; -} - -export interface IDistributedApplicationBuilderPromise extends PromiseLike { - build(): IDistributedApplicationPromise; - addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; - addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; - addContainer(name: string, image: string): IContainerResourcePromise; - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; - addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; - addExternalService(name: string, url: string): IExternalServiceResourcePromise; - addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; - addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; - addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; - addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; - addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; - addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; - addCSharpApp(name: string, path: string): IProjectResourcePromise; - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; - getConfiguration(): IConfigurationPromise; - subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; - subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; - addSqlServer(name: string, options?: AddSqlServerOptions): ISqlServerServerResourcePromise; -} - -// ============================================================================ -// DistributedApplicationBuilder -// ============================================================================ - -/** - * Type class for DistributedApplicationBuilder. - */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, - }; - - /** Gets the 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 => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', - { context: this._handle } - ); - return new DistributedApplicationEventing(handle, this._client); - }, - }; - - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', - { context: this._handle } - ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, - }; - - /** 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 { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', - rpcArgs - ); - return new DistributedApplication(result, this._client); - } - - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); - } - - /** Adds a connection string with a reference expression */ - /** @internal */ - async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: IReferenceExpression): 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: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); - } - - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); - } - - /** Adds a container registry resource */ - /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: IParameterResource, repository?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistry', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - 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 { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); - } - - /** Adds a container resource built from a Dockerfile */ - /** @internal */ - async _addDockerfileInternal(name: string, contextPath: string, dockerfilePath?: string, stage?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, contextPath }; - if (dockerfilePath !== undefined) rpcArgs.dockerfilePath = dockerfilePath; - if (stage !== undefined) rpcArgs.stage = stage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addDockerfile', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); - } - - /** Adds a .NET tool resource */ - /** @internal */ - async _addDotnetToolInternal(name: string, packageId: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, packageId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addDotnetTool', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); - } - - /** Adds an executable resource */ - /** @internal */ - async _addExecutableInternal(name: string, command: string, workingDirectory: string, args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, name, command, workingDirectory, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExecutable', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); - } - - /** Adds an external service resource */ - /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); - } - - /** Adds 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: IParameterResource): 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: IParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); - } - - /** Adds a parameter resource */ - /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); - } - - /** Adds a parameter 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 { - const rpcArgs: Record = { builder: this._handle, name, configurationKey }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameterFromConfiguration', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); - } - - /** Adds a connection string resource */ - /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', - rpcArgs - ); - return new ResourceWithConnectionString(result, this._client); - } - - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); - } - - /** Adds a .NET project resource */ - /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); - } - - /** Adds a project resource with configuration options */ - /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); - } - - /** Adds a C# application resource */ - /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); - } - - /** Adds a C# application resource with configuration options */ - /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { - 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: IBeforeStartEvent) => 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: IAfterResourcesCreatedEvent) => 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 a SQL Server container resource */ - /** @internal */ - async _addSqlServerInternal(name: string, password?: IParameterResource, port?: number): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (password !== undefined) rpcArgs.password = password; - if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/addSqlServer', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { - const password = options?.password; - const port = options?.port; - return new SqlServerServerResourcePromise(this._addSqlServerInternal(name, password, port)); - } - -} - -/** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. - */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); - } - - /** Adds a connection string with a reference expression */ - addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): 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: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); - } - - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => 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))); - } - - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); - } - - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); - } - - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); - } - - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); - } - - /** Adds 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: IParameterResource): 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))); - } - - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); - } - - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); - } - - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); - } - - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); - } - - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => 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: IBeforeStartEvent) => Promise): Promise { - return this._promise.then(obj => obj.subscribeBeforeStart(callback)); - } - - /** Subscribes to the AfterResourcesCreated event */ - subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise { - return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); - } - - /** Adds a SQL Server container resource */ - addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.addSqlServer(name, options))); - } - -} - -// ============================================================================ -// IDistributedApplicationEventing -// ============================================================================ - -export interface IDistributedApplicationEventing { - toJSON(): MarshalledHandle; - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): IDistributedApplicationEventingPromise; -} - -export interface IDistributedApplicationEventingPromise extends PromiseLike { - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): IDistributedApplicationEventingPromise; -} - -// ============================================================================ -// DistributedApplicationEventing -// ============================================================================ - -/** - * Type class for DistributedApplicationEventing. - */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Invokes the Unsubscribe method */ - /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; - await this._client.invokeCapability( - 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', - rpcArgs - ); - return this; - } - - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); - } - -} - -/** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. - */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); - } - -} - -// ============================================================================ -// IHostEnvironment -// ============================================================================ - -export interface IHostEnvironment { - toJSON(): MarshalledHandle; - isDevelopment(): Promise; - isProduction(): Promise; - isStaging(): Promise; - isEnvironment(environmentName: string): Promise; -} - -export interface IHostEnvironmentPromise extends PromiseLike { - isDevelopment(): Promise; - isProduction(): Promise; - isStaging(): Promise; - isEnvironment(environmentName: string): Promise; -} - -// ============================================================================ -// HostEnvironment -// ============================================================================ - -/** - * Type class for HostEnvironment. - */ -export class HostEnvironment { - constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Checks if running in Development environment */ - async isDevelopment(): Promise { - 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)); - } - -} - -// ============================================================================ -// ILogger -// ============================================================================ - -export interface ILogger { - toJSON(): MarshalledHandle; - logInformation(message: string): ILoggerPromise; - logWarning(message: string): ILoggerPromise; - logError(message: string): ILoggerPromise; - logDebug(message: string): ILoggerPromise; - log(level: string, message: string): ILoggerPromise; -} - -export interface ILoggerPromise extends PromiseLike { - logInformation(message: string): ILoggerPromise; - logWarning(message: string): ILoggerPromise; - logError(message: string): ILoggerPromise; - logDebug(message: string): ILoggerPromise; - log(level: string, message: string): ILoggerPromise; -} - -// ============================================================================ -// 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))); - } - -} - -// ============================================================================ -// ILoggerFactory -// ============================================================================ - -export interface ILoggerFactory { - toJSON(): MarshalledHandle; - createLogger(categoryName: string): ILoggerPromise; -} - -export interface ILoggerFactoryPromise extends PromiseLike { - createLogger(categoryName: string): ILoggerPromise; -} - -// ============================================================================ -// 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))); - } - -} - -// ============================================================================ -// IReportingStep -// ============================================================================ - -export interface IReportingStep { - toJSON(): MarshalledHandle; - createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; - createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; - logStep(level: string, message: string): IReportingStepPromise; - logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; - completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; - completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; -} - -export interface IReportingStepPromise extends PromiseLike { - createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; - createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; - logStep(level: string, message: string): IReportingStepPromise; - logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; - completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; - completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; -} - -// ============================================================================ -// 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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))); - } - -} - -// ============================================================================ -// IReportingTask -// ============================================================================ - -export interface IReportingTask { - toJSON(): MarshalledHandle; - updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; - updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; - completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; - completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; -} - -export interface IReportingTaskPromise extends PromiseLike { - updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; - updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; - completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; - completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; -} - -// ============================================================================ -// 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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 | ICancellationToken): 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))); - } - -} - -// ============================================================================ -// IServiceProvider -// ============================================================================ - -export interface IServiceProvider { - toJSON(): MarshalledHandle; - getEventing(): IDistributedApplicationEventingPromise; - getLoggerFactory(): ILoggerFactoryPromise; - getResourceLoggerService(): IResourceLoggerServicePromise; - getDistributedApplicationModel(): IDistributedApplicationModelPromise; - getResourceNotificationService(): IResourceNotificationServicePromise; - getUserSecretsManager(): IUserSecretsManagerPromise; -} - -export interface IServiceProviderPromise extends PromiseLike { - getEventing(): IDistributedApplicationEventingPromise; - getLoggerFactory(): ILoggerFactoryPromise; - getResourceLoggerService(): IResourceLoggerServicePromise; - getDistributedApplicationModel(): IDistributedApplicationModelPromise; - getResourceNotificationService(): IResourceNotificationServicePromise; - getUserSecretsManager(): IUserSecretsManagerPromise; -} - -// ============================================================================ -// 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())); - } - -} - -// ============================================================================ -// IUserSecretsManager -// ============================================================================ - -export interface IUserSecretsManager { - toJSON(): MarshalledHandle; - isAvailable: { - get: () => Promise; - }; - filePath: { - get: () => Promise; - }; - trySetSecret(name: string, value: string): Promise; - saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; - getOrSetSecret(resourceBuilder: IResource, name: string, value: string): IUserSecretsManagerPromise; -} - -export interface IUserSecretsManagerPromise extends PromiseLike { - trySetSecret(name: string, value: string): Promise; - saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; - getOrSetSecret(resourceBuilder: IResource, name: string, value: string): IUserSecretsManagerPromise; -} - -// ============================================================================ -// 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 | ICancellationToken): 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: IResource, 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: IResource, 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: IResource, name: string, value: string): UserSecretsManagerPromise { - return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); - } - -} - -// ============================================================================ -// IConnectionStringResource -// ============================================================================ - -export interface IConnectionStringResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IConnectionStringResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; - withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; - getConnectionProperty(key: string): Promise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; - excludeFromManifest(): IConnectionStringResourcePromise; - waitFor(dependency: IResource): IConnectionStringResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - waitForStart(dependency: IResource): IConnectionStringResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - withExplicitStart(): IConnectionStringResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; - withHealthCheck(key: string): IConnectionStringResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; - withParentRelationship(parent: IResource): IConnectionStringResourcePromise; - withChildRelationship(child: IResource): IConnectionStringResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; - excludeFromMcp(): IConnectionStringResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; -} - -export interface IConnectionStringResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IConnectionStringResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; - withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; - getConnectionProperty(key: string): Promise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; - excludeFromManifest(): IConnectionStringResourcePromise; - waitFor(dependency: IResource): IConnectionStringResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - waitForStart(dependency: IResource): IConnectionStringResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - withExplicitStart(): IConnectionStringResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; - withHealthCheck(key: string): IConnectionStringResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; - withParentRelationship(parent: IResource): IConnectionStringResourcePromise; - withChildRelationship(child: IResource): IConnectionStringResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; - excludeFromMcp(): IConnectionStringResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; -} - -// ============================================================================ -// ConnectionStringResource -// ============================================================================ - -export class ConnectionStringResource extends ResourceBuilderBase { - constructor(handle: ConnectionStringResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ConnectionStringResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { - const helpLink = options?.helpLink; - return new ConnectionStringResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withConnectionPropertyInternal(name, value)); - } - - /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withConnectionPropertyValueInternal(name, value)); - } - - /** 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: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { - const displayText = options?.displayText; - return new ConnectionStringResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { - const displayText = options?.displayText; - return new ConnectionStringResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { - const exitCode = options?.exitCode; - return new ConnectionStringResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { - const commandOptions = options?.commandOptions; - return new ConnectionStringResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { - const iconVariant = options?.iconVariant; - return new ConnectionStringResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ConnectionStringResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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: IConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for ConnectionStringResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ConnectionStringResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ConnectionStringResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** 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: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IContainerRegistryResource -// ============================================================================ - -export interface IContainerRegistryResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IContainerRegistryResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; - excludeFromManifest(): IContainerRegistryResourcePromise; - withExplicitStart(): IContainerRegistryResourcePromise; - withHealthCheck(key: string): IContainerRegistryResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; - withParentRelationship(parent: IResource): IContainerRegistryResourcePromise; - withChildRelationship(child: IResource): IContainerRegistryResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; - excludeFromMcp(): IContainerRegistryResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; -} - -export interface IContainerRegistryResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IContainerRegistryResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; - excludeFromManifest(): IContainerRegistryResourcePromise; - withExplicitStart(): IContainerRegistryResourcePromise; - withHealthCheck(key: string): IContainerRegistryResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; - withParentRelationship(parent: IResource): IContainerRegistryResourcePromise; - withChildRelationship(child: IResource): IContainerRegistryResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; - excludeFromMcp(): IContainerRegistryResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; -} - -// ============================================================================ -// ContainerRegistryResource -// ============================================================================ - -export class ContainerRegistryResource extends ResourceBuilderBase { - constructor(handle: ContainerRegistryResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ContainerRegistryResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { - const helpLink = options?.helpLink; - return new ContainerRegistryResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { - const displayText = options?.displayText; - return new ContainerRegistryResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { - const displayText = options?.displayText; - return new ContainerRegistryResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { - const commandOptions = options?.commandOptions; - return new ContainerRegistryResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - const iconVariant = options?.iconVariant; - return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ContainerRegistryResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for ContainerRegistryResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ContainerRegistryResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ContainerRegistryResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IContainerResource -// ============================================================================ - -export interface IContainerResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IContainerResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; - withEntrypoint(entrypoint: string): IContainerResourcePromise; - withImageTag(tag: string): IContainerResourcePromise; - withImageRegistry(registry: string): IContainerResourcePromise; - withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; - withImageSHA256(sha256: string): IContainerResourcePromise; - withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; - withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; - publishAsContainer(): IContainerResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; - withContainerName(name: string): IContainerResourcePromise; - withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; - withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; - withContainerNetworkAlias(alias: string): IContainerResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; - withOtlpExporter(): IContainerResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; - publishAsConnectionString(): IContainerResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IContainerResourcePromise; - withArgs(args: string[]): IContainerResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IContainerResourcePromise; - withReferenceUri(name: string, uri: string): IContainerResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; - withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; - withExternalHttpEndpoints(): IContainerResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IContainerResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; - excludeFromManifest(): IContainerResourcePromise; - waitFor(dependency: IResource): IContainerResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; - waitForStart(dependency: IResource): IContainerResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; - withExplicitStart(): IContainerResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IContainerResourcePromise; - withHealthCheck(key: string): IContainerResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; - withoutHttpsCertificate(): IContainerResourcePromise; - withParentRelationship(parent: IResource): IContainerResourcePromise; - withChildRelationship(child: IResource): IContainerResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; - excludeFromMcp(): IContainerResourcePromise; - withRemoteImageName(remoteImageName: string): IContainerResourcePromise; - withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; -} - -export interface IContainerResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IContainerResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; - withEntrypoint(entrypoint: string): IContainerResourcePromise; - withImageTag(tag: string): IContainerResourcePromise; - withImageRegistry(registry: string): IContainerResourcePromise; - withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; - withImageSHA256(sha256: string): IContainerResourcePromise; - withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; - withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; - publishAsContainer(): IContainerResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; - withContainerName(name: string): IContainerResourcePromise; - withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; - withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; - withContainerNetworkAlias(alias: string): IContainerResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; - withOtlpExporter(): IContainerResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; - publishAsConnectionString(): IContainerResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IContainerResourcePromise; - withArgs(args: string[]): IContainerResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IContainerResourcePromise; - withReferenceUri(name: string, uri: string): IContainerResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; - withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; - withExternalHttpEndpoints(): IContainerResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IContainerResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; - excludeFromManifest(): IContainerResourcePromise; - waitFor(dependency: IResource): IContainerResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; - waitForStart(dependency: IResource): IContainerResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IContainerResourcePromise; - withExplicitStart(): IContainerResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IContainerResourcePromise; - withHealthCheck(key: string): IContainerResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; - withoutHttpsCertificate(): IContainerResourcePromise; - withParentRelationship(parent: IResource): IContainerResourcePromise; - withChildRelationship(child: IResource): IContainerResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; - excludeFromMcp(): IContainerResourcePromise; - withRemoteImageName(remoteImageName: string): IContainerResourcePromise; - withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; -} - -// ============================================================================ -// ContainerResource -// ============================================================================ - -export class ContainerResource extends ResourceBuilderBase { - constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source, target }; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBindMount', - rpcArgs - ); - return new 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: IParameterResource): 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: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); - } - - /** @internal */ - private async _withBuildSecretInternal(name: string, value: IParameterResource): 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: IParameterResource): 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 }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withContainerNetworkAliasInternal(alias: string): Promise { - 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 }; - if (path !== undefined) rpcArgs.path = path; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withMcpServer', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new ContainerResourcePromise(this._withMcpServerInternal(path, endpointName)); - } - - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ContainerResourcePromise { - return new ContainerResourcePromise(this._withOtlpExporterInternal()); - } - - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise { - return new ContainerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); - } - - /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishAsConnectionString', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Publishes the resource as a connection string */ - publishAsConnectionString(): ContainerResourcePromise { - return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new 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 _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); - } - - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); - } - - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); - } - - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds arguments */ - withArgs(args: string[]): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsInternal(args)); - } - - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withReferenceInternal(source: IResource, 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 - ); - return new ContainerResource(result, this._client); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - const name = options?.name; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); - } - - /** @internal */ - private async _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withReferenceUriInternal(name, uri)); - } - - /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); - } - - /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); - } - - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new ContainerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); - } - - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ContainerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ContainerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ContainerResourcePromise { - return new ContainerResourcePromise(this._withExternalHttpEndpointsInternal()); - } - - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); - } - - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ContainerResourcePromise { - return new ContainerResourcePromise(this._asHttp2ServiceInternal()); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { - const displayText = options?.displayText; - return new ContainerResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { - const displayText = options?.displayText; - return new ContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerResourcePromise { - return new ContainerResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerResourcePromise { - return new ContainerResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ContainerResourcePromise { - const exitCode = options?.exitCode; - return new ContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new ContainerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { - const commandOptions = options?.commandOptions; - return new ContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { - return new ContainerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); - } - - /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { - return new ContainerResourcePromise(this._withCertificateTrustScopeInternal(scope)); - } - - /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { - const password = options?.password; - return new ContainerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); - } - - /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ContainerResourcePromise { - return new ContainerResourcePromise(this._withoutHttpsCertificateInternal()); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { - const iconVariant = options?.iconVariant; - return new ContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, probeType }; - if (path !== undefined) rpcArgs.path = path; - if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; - if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; - if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; - if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; - if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { - const path = options?.path; - const initialDelaySeconds = options?.initialDelaySeconds; - const periodSeconds = options?.periodSeconds; - const timeoutSeconds = options?.timeoutSeconds; - const failureThreshold = options?.failureThreshold; - const successThreshold = options?.successThreshold; - const endpointName = options?.endpointName; - return new ContainerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerResourcePromise { - return new ContainerResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** @internal */ - private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { resource: this._handle, target }; - if (name !== undefined) rpcArgs.name = name; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withVolume', - rpcArgs - ); - return new 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 }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for ContainerResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ContainerResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ContainerResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ContainerResourcePromise { - 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: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); - } - - /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): 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))); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); - } - - /** 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 environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); - } - - /** Adds arguments */ - withArgs(args: string[]): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); - } - - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { - 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: IBeforeResourceStartedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// ICSharpAppResource -// ============================================================================ - -export interface ICSharpAppResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): ICSharpAppResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; - withOtlpExporter(): ICSharpAppResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; - withReplicas(replicas: number): ICSharpAppResourcePromise; - disableForwardedHeaders(): ICSharpAppResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ICSharpAppResourcePromise; - withArgs(args: string[]): ICSharpAppResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): ICSharpAppResourcePromise; - withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; - withExternalHttpEndpoints(): ICSharpAppResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ICSharpAppResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ICSharpAppResourcePromise; - excludeFromManifest(): ICSharpAppResourcePromise; - waitFor(dependency: IResource): ICSharpAppResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - waitForStart(dependency: IResource): ICSharpAppResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - withExplicitStart(): ICSharpAppResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; - withHealthCheck(key: string): ICSharpAppResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; - withoutHttpsCertificate(): ICSharpAppResourcePromise; - withParentRelationship(parent: IResource): ICSharpAppResourcePromise; - withChildRelationship(child: IResource): ICSharpAppResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; - excludeFromMcp(): ICSharpAppResourcePromise; - withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; - withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; -} - -export interface ICSharpAppResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): ICSharpAppResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; - withOtlpExporter(): ICSharpAppResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; - withReplicas(replicas: number): ICSharpAppResourcePromise; - disableForwardedHeaders(): ICSharpAppResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ICSharpAppResourcePromise; - withArgs(args: string[]): ICSharpAppResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): ICSharpAppResourcePromise; - withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; - withExternalHttpEndpoints(): ICSharpAppResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ICSharpAppResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ICSharpAppResourcePromise; - excludeFromManifest(): ICSharpAppResourcePromise; - waitFor(dependency: IResource): ICSharpAppResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - waitForStart(dependency: IResource): ICSharpAppResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - withExplicitStart(): ICSharpAppResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; - withHealthCheck(key: string): ICSharpAppResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; - withoutHttpsCertificate(): ICSharpAppResourcePromise; - withParentRelationship(parent: IResource): ICSharpAppResourcePromise; - withChildRelationship(child: IResource): ICSharpAppResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; - excludeFromMcp(): ICSharpAppResourcePromise; - withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; - withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; -} - -// ============================================================================ -// CSharpAppResource -// ============================================================================ - -export class CSharpAppResource extends ResourceBuilderBase { - constructor(handle: CSharpAppResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new CSharpAppResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withMcpServer', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new CSharpAppResourcePromise(this._withMcpServerInternal(path, endpointName)); - } - - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withOtlpExporterInternal()); - } - - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); - } - - /** @internal */ - private async _withReplicasInternal(replicas: number): Promise { - const rpcArgs: Record = { builder: this._handle, replicas }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReplicas', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets the number of replicas */ - withReplicas(replicas: number): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withReplicasInternal(replicas)); - } - - /** @internal */ - private async _disableForwardedHeadersInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/disableForwardedHeaders', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Disables forwarded headers for the project */ - disableForwardedHeaders(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._disableForwardedHeadersInternal()); - } - - /** @internal */ - private async _publishAsDockerFileInternal(configure?: (obj: IContainerResource) => 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/publishProjectAsDockerFileWithConfigure', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Publishes a project as a Docker file with optional container configuration */ - publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { - const configure = options?.configure; - return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); - } - - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); - } - - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); - } - - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds arguments */ - withArgs(args: string[]): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withArgsInternal(args)); - } - - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withReferenceInternal(source: IResource, 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 - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - const name = options?.name; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); - } - - /** @internal */ - private async _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withReferenceUriInternal(name, uri)); - } - - /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withReferenceExternalServiceInternal(externalService)); - } - - /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withReferenceEndpointInternal(endpointReference)); - } - - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new CSharpAppResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); - } - - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new CSharpAppResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new CSharpAppResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withExternalHttpEndpointsInternal()); - } - - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); - } - - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._asHttp2ServiceInternal()); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { - const displayText = options?.displayText; - return new CSharpAppResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { - const displayText = options?.displayText; - return new CSharpAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); - } - - /** @internal */ - private async _publishWithContainerFilesInternal(source: IResourceWithContainerFiles, destinationPath: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, destinationPath }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFilesFromResource', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): CSharpAppResourcePromise { - const exitCode = options?.exitCode; - return new CSharpAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new CSharpAppResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { - const commandOptions = options?.commandOptions; - return new CSharpAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); - } - - /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withCertificateTrustScopeInternal(scope)); - } - - /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { - const password = options?.password; - return new CSharpAppResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); - } - - /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withoutHttpsCertificateInternal()); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { - const iconVariant = options?.iconVariant; - return new CSharpAppResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, probeType }; - if (path !== undefined) rpcArgs.path = path; - if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; - if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; - if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; - if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; - if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { - const path = options?.path; - const initialDelaySeconds = options?.initialDelaySeconds; - const periodSeconds = options?.periodSeconds; - const timeoutSeconds = options?.timeoutSeconds; - const failureThreshold = options?.failureThreshold; - const successThreshold = options?.successThreshold; - const endpointName = options?.endpointName; - return new CSharpAppResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new CSharpAppResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for CSharpAppResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class CSharpAppResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: CSharpAppResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); - } - - /** Sets the number of replicas */ - withReplicas(replicas: number): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); - } - - /** Disables forwarded headers for the project */ - disableForwardedHeaders(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); - } - - /** Publishes a project as a Docker file with optional container configuration */ - publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); - } - - /** Adds arguments */ - withArgs(args: string[]): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); - } - - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); - } - - /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IDotnetToolResource -// ============================================================================ - -export interface IDotnetToolResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IDotnetToolResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; - withToolPackage(packageId: string): IDotnetToolResourcePromise; - withToolVersion(version: string): IDotnetToolResourcePromise; - withToolPrerelease(): IDotnetToolResourcePromise; - withToolSource(source: string): IDotnetToolResourcePromise; - withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; - withToolIgnoreFailedSources(): IDotnetToolResourcePromise; - publishAsDockerFile(): IDotnetToolResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; - withExecutableCommand(command: string): IDotnetToolResourcePromise; - withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; - withOtlpExporter(): IDotnetToolResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IDotnetToolResourcePromise; - withArgs(args: string[]): IDotnetToolResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IDotnetToolResourcePromise; - withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; - withExternalHttpEndpoints(): IDotnetToolResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IDotnetToolResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; - excludeFromManifest(): IDotnetToolResourcePromise; - waitFor(dependency: IResource): IDotnetToolResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - waitForStart(dependency: IResource): IDotnetToolResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - withExplicitStart(): IDotnetToolResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; - withHealthCheck(key: string): IDotnetToolResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; - withoutHttpsCertificate(): IDotnetToolResourcePromise; - withParentRelationship(parent: IResource): IDotnetToolResourcePromise; - withChildRelationship(child: IResource): IDotnetToolResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; - excludeFromMcp(): IDotnetToolResourcePromise; - withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; - withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; -} - -export interface IDotnetToolResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IDotnetToolResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; - withToolPackage(packageId: string): IDotnetToolResourcePromise; - withToolVersion(version: string): IDotnetToolResourcePromise; - withToolPrerelease(): IDotnetToolResourcePromise; - withToolSource(source: string): IDotnetToolResourcePromise; - withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; - withToolIgnoreFailedSources(): IDotnetToolResourcePromise; - publishAsDockerFile(): IDotnetToolResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; - withExecutableCommand(command: string): IDotnetToolResourcePromise; - withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; - withOtlpExporter(): IDotnetToolResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IDotnetToolResourcePromise; - withArgs(args: string[]): IDotnetToolResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IDotnetToolResourcePromise; - withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; - withExternalHttpEndpoints(): IDotnetToolResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IDotnetToolResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; - excludeFromManifest(): IDotnetToolResourcePromise; - waitFor(dependency: IResource): IDotnetToolResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - waitForStart(dependency: IResource): IDotnetToolResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - withExplicitStart(): IDotnetToolResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; - withHealthCheck(key: string): IDotnetToolResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; - withoutHttpsCertificate(): IDotnetToolResourcePromise; - withParentRelationship(parent: IResource): IDotnetToolResourcePromise; - withChildRelationship(child: IResource): IDotnetToolResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; - excludeFromMcp(): IDotnetToolResourcePromise; - withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; - withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; -} - -// ============================================================================ -// DotnetToolResource -// ============================================================================ - -export class DotnetToolResource extends ResourceBuilderBase { - constructor(handle: DotnetToolResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new DotnetToolResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withToolPackageInternal(packageId: string): Promise { - const rpcArgs: Record = { builder: this._handle, packageId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withToolPackage', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the tool package ID */ - withToolPackage(packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withToolPackageInternal(packageId)); - } - - /** @internal */ - private async _withToolVersionInternal(version: string): Promise { - const rpcArgs: Record = { builder: this._handle, version }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withToolVersion', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the tool version */ - withToolVersion(version: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withToolVersionInternal(version)); - } - - /** @internal */ - private async _withToolPrereleaseInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withToolPrerelease', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Allows prerelease tool versions */ - withToolPrerelease(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withToolPrereleaseInternal()); - } - - /** @internal */ - private async _withToolSourceInternal(source: string): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withToolSource', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a NuGet source for the tool */ - withToolSource(source: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withToolSourceInternal(source)); - } - - /** @internal */ - private async _withToolIgnoreExistingFeedsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withToolIgnoreExistingFeeds', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Ignores existing NuGet feeds */ - withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withToolIgnoreExistingFeedsInternal()); - } - - /** @internal */ - private async _withToolIgnoreFailedSourcesInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withToolIgnoreFailedSources', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Ignores failed NuGet sources */ - withToolIgnoreFailedSources(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withToolIgnoreFailedSourcesInternal()); - } - - /** @internal */ - private async _publishAsDockerFileInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishAsDockerFile', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Publishes the executable as a Docker container */ - publishAsDockerFile(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._publishAsDockerFileInternal()); - } - - /** @internal */ - private async _publishAsDockerFileWithConfigureInternal(configure: (obj: IContainerResource) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; - const obj = new ContainerResource(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishAsDockerFileWithConfigure', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Publishes an executable as a Docker file with optional container configuration */ - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); - } - - /** @internal */ - private async _withExecutableCommandInternal(command: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExecutableCommand', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the executable command */ - withExecutableCommand(command: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withExecutableCommandInternal(command)); - } - - /** @internal */ - private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { - const rpcArgs: Record = { builder: this._handle, workingDirectory }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withWorkingDirectory', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the executable working directory */ - withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); - } - - /** @internal */ - private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withMcpServer', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new DotnetToolResourcePromise(this._withMcpServerInternal(path, endpointName)); - } - - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withOtlpExporterInternal()); - } - - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { - const helpLink = options?.helpLink; - return new DotnetToolResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); - } - - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); - } - - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); - } - - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds arguments */ - withArgs(args: string[]): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withArgsInternal(args)); - } - - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withArgsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withReferenceInternal(source: IResource, 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 - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - const name = options?.name; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); - } - - /** @internal */ - private async _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withReferenceUriInternal(name, uri)); - } - - /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withReferenceExternalServiceInternal(externalService)); - } - - /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withReferenceEndpointInternal(endpointReference)); - } - - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new DotnetToolResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); - } - - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new DotnetToolResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new DotnetToolResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withExternalHttpEndpointsInternal()); - } - - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); - } - - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._asHttp2ServiceInternal()); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { - const displayText = options?.displayText; - return new DotnetToolResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { - const displayText = options?.displayText; - return new DotnetToolResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): DotnetToolResourcePromise { - const exitCode = options?.exitCode; - return new DotnetToolResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new DotnetToolResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { - const commandOptions = options?.commandOptions; - return new DotnetToolResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); - } - - /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withCertificateTrustScopeInternal(scope)); - } - - /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { - const password = options?.password; - return new DotnetToolResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); - } - - /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withoutHttpsCertificateInternal()); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { - const iconVariant = options?.iconVariant; - return new DotnetToolResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, probeType }; - if (path !== undefined) rpcArgs.path = path; - if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; - if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; - if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; - if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; - if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { - const path = options?.path; - const initialDelaySeconds = options?.initialDelaySeconds; - const periodSeconds = options?.periodSeconds; - const timeoutSeconds = options?.timeoutSeconds; - const failureThreshold = options?.failureThreshold; - const successThreshold = options?.successThreshold; - const endpointName = options?.endpointName; - return new DotnetToolResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new DotnetToolResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for DotnetToolResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class DotnetToolResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Sets the tool package ID */ - withToolPackage(packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPackage(packageId))); - } - - /** Sets the tool version */ - withToolVersion(version: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolVersion(version))); - } - - /** Allows prerelease tool versions */ - withToolPrerelease(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPrerelease())); - } - - /** Adds a NuGet source for the tool */ - withToolSource(source: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolSource(source))); - } - - /** Ignores existing NuGet feeds */ - withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreExistingFeeds())); - } - - /** Ignores failed NuGet sources */ - withToolIgnoreFailedSources(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreFailedSources())); - } - - /** Publishes the executable as a Docker container */ - publishAsDockerFile(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); - } - - /** Publishes an executable as a Docker file with optional container configuration */ - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); - } - - /** Sets the executable command */ - withExecutableCommand(command: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); - } - - /** Sets the executable working directory */ - withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); - } - - /** Adds arguments */ - withArgs(args: string[]): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); - } - - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.asHttp2Service())); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IExecutableResource -// ============================================================================ - -export interface IExecutableResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IExecutableResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; - publishAsDockerFile(): IExecutableResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; - withExecutableCommand(command: string): IExecutableResourcePromise; - withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; - withOtlpExporter(): IExecutableResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IExecutableResourcePromise; - withArgs(args: string[]): IExecutableResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IExecutableResourcePromise; - withReferenceUri(name: string, uri: string): IExecutableResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; - withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; - withExternalHttpEndpoints(): IExecutableResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IExecutableResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; - excludeFromManifest(): IExecutableResourcePromise; - waitFor(dependency: IResource): IExecutableResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; - waitForStart(dependency: IResource): IExecutableResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; - withExplicitStart(): IExecutableResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IExecutableResourcePromise; - withHealthCheck(key: string): IExecutableResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; - withoutHttpsCertificate(): IExecutableResourcePromise; - withParentRelationship(parent: IResource): IExecutableResourcePromise; - withChildRelationship(child: IResource): IExecutableResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; - excludeFromMcp(): IExecutableResourcePromise; - withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; - withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; -} - -export interface IExecutableResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IExecutableResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; - publishAsDockerFile(): IExecutableResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; - withExecutableCommand(command: string): IExecutableResourcePromise; - withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; - withOtlpExporter(): IExecutableResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IExecutableResourcePromise; - withArgs(args: string[]): IExecutableResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IExecutableResourcePromise; - withReferenceUri(name: string, uri: string): IExecutableResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; - withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; - withExternalHttpEndpoints(): IExecutableResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IExecutableResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; - excludeFromManifest(): IExecutableResourcePromise; - waitFor(dependency: IResource): IExecutableResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; - waitForStart(dependency: IResource): IExecutableResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IExecutableResourcePromise; - withExplicitStart(): IExecutableResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IExecutableResourcePromise; - withHealthCheck(key: string): IExecutableResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; - withoutHttpsCertificate(): IExecutableResourcePromise; - withParentRelationship(parent: IResource): IExecutableResourcePromise; - withChildRelationship(child: IResource): IExecutableResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; - excludeFromMcp(): IExecutableResourcePromise; - withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; - withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; -} - -// ============================================================================ -// ExecutableResource -// ============================================================================ - -export class ExecutableResource extends ResourceBuilderBase { - constructor(handle: ExecutableResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ExecutableResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _publishAsDockerFileInternal(): Promise { - 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: IContainerResource) => 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: IContainerResource) => 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 }; - if (path !== undefined) rpcArgs.path = path; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withMcpServer', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new ExecutableResourcePromise(this._withMcpServerInternal(path, endpointName)); - } - - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withOtlpExporterInternal()); - } - - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { - const helpLink = options?.helpLink; - return new ExecutableResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); - } - - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); - } - - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); - } - - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds arguments */ - withArgs(args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsInternal(args)); - } - - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withReferenceInternal(source: IResource, 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 - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - const name = options?.name; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); - } - - /** @internal */ - private async _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withReferenceUriInternal(name, uri)); - } - - /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withReferenceExternalServiceInternal(externalService)); - } - - /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withReferenceEndpointInternal(endpointReference)); - } - - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new ExecutableResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); - } - - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ExecutableResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ExecutableResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withExternalHttpEndpointsInternal()); - } - - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); - } - - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._asHttp2ServiceInternal()); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { - const displayText = options?.displayText; - return new ExecutableResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { - const displayText = options?.displayText; - return new ExecutableResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ExecutableResourcePromise { - const exitCode = options?.exitCode; - return new ExecutableResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new ExecutableResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { - const commandOptions = options?.commandOptions; - return new ExecutableResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); - } - - /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withCertificateTrustScopeInternal(scope)); - } - - /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { - const password = options?.password; - return new ExecutableResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); - } - - /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withoutHttpsCertificateInternal()); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { - const iconVariant = options?.iconVariant; - return new ExecutableResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, probeType }; - if (path !== undefined) rpcArgs.path = path; - if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; - if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; - if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; - if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; - if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { - const path = options?.path; - const initialDelaySeconds = options?.initialDelaySeconds; - const periodSeconds = options?.periodSeconds; - const timeoutSeconds = options?.timeoutSeconds; - const failureThreshold = options?.failureThreshold; - const successThreshold = options?.successThreshold; - const endpointName = options?.endpointName; - return new ExecutableResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for ExecutableResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ExecutableResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ExecutableResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** 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: IContainerResource) => 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))); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); - } - - /** Adds arguments */ - withArgs(args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); - } - - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.asHttp2Service())); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IExternalServiceResource -// ============================================================================ - -export interface IExternalServiceResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IExternalServiceResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; - withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; - excludeFromManifest(): IExternalServiceResourcePromise; - withExplicitStart(): IExternalServiceResourcePromise; - withHealthCheck(key: string): IExternalServiceResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; - withParentRelationship(parent: IResource): IExternalServiceResourcePromise; - withChildRelationship(child: IResource): IExternalServiceResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; - excludeFromMcp(): IExternalServiceResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; -} - -export interface IExternalServiceResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IExternalServiceResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; - withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; - excludeFromManifest(): IExternalServiceResourcePromise; - withExplicitStart(): IExternalServiceResourcePromise; - withHealthCheck(key: string): IExternalServiceResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; - withParentRelationship(parent: IResource): IExternalServiceResourcePromise; - withChildRelationship(child: IResource): IExternalServiceResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; - excludeFromMcp(): IExternalServiceResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; -} - -// ============================================================================ -// ExternalServiceResource -// ============================================================================ - -export class ExternalServiceResource extends ResourceBuilderBase { - constructor(handle: ExternalServiceResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ExternalServiceResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withExternalServiceHttpHealthCheckInternal(path?: string, statusCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalServiceHttpHealthCheck', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds an HTTP health check to an external service */ - withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - return new ExternalServiceResourcePromise(this._withExternalServiceHttpHealthCheckInternal(path, statusCode)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { - const helpLink = options?.helpLink; - return new ExternalServiceResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { - const displayText = options?.displayText; - return new ExternalServiceResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { - const displayText = options?.displayText; - return new ExternalServiceResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { - const commandOptions = options?.commandOptions; - return new ExternalServiceResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { - const iconVariant = options?.iconVariant; - return new ExternalServiceResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ExternalServiceResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for ExternalServiceResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ExternalServiceResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ExternalServiceResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds an HTTP health check to an external service */ - withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExternalServiceHttpHealthCheck(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IParameterResource -// ============================================================================ - -export interface IParameterResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IParameterResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; - withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; - excludeFromManifest(): IParameterResourcePromise; - withExplicitStart(): IParameterResourcePromise; - withHealthCheck(key: string): IParameterResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; - withParentRelationship(parent: IResource): IParameterResourcePromise; - withChildRelationship(child: IResource): IParameterResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; - excludeFromMcp(): IParameterResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; -} - -export interface IParameterResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IParameterResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; - withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; - excludeFromManifest(): IParameterResourcePromise; - withExplicitStart(): IParameterResourcePromise; - withHealthCheck(key: string): IParameterResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; - withParentRelationship(parent: IResource): IParameterResourcePromise; - withChildRelationship(child: IResource): IParameterResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; - excludeFromMcp(): IParameterResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; -} - -// ============================================================================ -// ParameterResource -// ============================================================================ - -export class ParameterResource extends ResourceBuilderBase { - constructor(handle: ParameterResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ParameterResourcePromise { - return new ParameterResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ParameterResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withDescriptionInternal(description: string, enableMarkdown?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, description }; - if (enableMarkdown !== undefined) rpcArgs.enableMarkdown = enableMarkdown; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDescription', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets a parameter description */ - withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { - const enableMarkdown = options?.enableMarkdown; - return new ParameterResourcePromise(this._withDescriptionInternal(description, enableMarkdown)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { - const helpLink = options?.helpLink; - return new ParameterResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { - const displayText = options?.displayText; - return new ParameterResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { - const displayText = options?.displayText; - return new ParameterResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ParameterResourcePromise { - return new ParameterResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ParameterResourcePromise { - return new ParameterResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { - const commandOptions = options?.commandOptions; - return new ParameterResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ParameterResourcePromise { - return new ParameterResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ParameterResourcePromise { - return new ParameterResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { - const iconVariant = options?.iconVariant; - return new ParameterResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ParameterResourcePromise { - return new ParameterResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for ParameterResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ParameterResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ParameterResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Sets a parameter description */ - withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withDescription(description, options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IProjectResource -// ============================================================================ - -export interface IProjectResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IProjectResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; - withOtlpExporter(): IProjectResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; - withReplicas(replicas: number): IProjectResourcePromise; - disableForwardedHeaders(): IProjectResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IProjectResourcePromise; - withArgs(args: string[]): IProjectResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IProjectResourcePromise; - withReferenceUri(name: string, uri: string): IProjectResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; - withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; - withExternalHttpEndpoints(): IProjectResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IProjectResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IProjectResourcePromise; - excludeFromManifest(): IProjectResourcePromise; - waitFor(dependency: IResource): IProjectResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; - waitForStart(dependency: IResource): IProjectResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; - withExplicitStart(): IProjectResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IProjectResourcePromise; - withHealthCheck(key: string): IProjectResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; - withoutHttpsCertificate(): IProjectResourcePromise; - withParentRelationship(parent: IResource): IProjectResourcePromise; - withChildRelationship(child: IResource): IProjectResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; - excludeFromMcp(): IProjectResourcePromise; - withRemoteImageName(remoteImageName: string): IProjectResourcePromise; - withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; -} - -export interface IProjectResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IProjectResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; - withOtlpExporter(): IProjectResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; - withReplicas(replicas: number): IProjectResourcePromise; - disableForwardedHeaders(): IProjectResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IProjectResourcePromise; - withArgs(args: string[]): IProjectResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): IProjectResourcePromise; - withReferenceUri(name: string, uri: string): IProjectResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; - withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; - withExternalHttpEndpoints(): IProjectResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IProjectResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IProjectResourcePromise; - excludeFromManifest(): IProjectResourcePromise; - waitFor(dependency: IResource): IProjectResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; - waitForStart(dependency: IResource): IProjectResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IProjectResourcePromise; - withExplicitStart(): IProjectResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IProjectResourcePromise; - withHealthCheck(key: string): IProjectResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; - withoutHttpsCertificate(): IProjectResourcePromise; - withParentRelationship(parent: IResource): IProjectResourcePromise; - withChildRelationship(child: IResource): IProjectResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; - excludeFromMcp(): IProjectResourcePromise; - withRemoteImageName(remoteImageName: string): IProjectResourcePromise; - withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; -} - -// ============================================================================ -// ProjectResource -// ============================================================================ - -export class ProjectResource extends ResourceBuilderBase { - constructor(handle: ProjectResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ProjectResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withMcpServer', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new ProjectResourcePromise(this._withMcpServerInternal(path, endpointName)); - } - - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withOtlpExporterInternal()); - } - - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { - return new ProjectResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); - } - - /** @internal */ - private async _withReplicasInternal(replicas: number): Promise { - const rpcArgs: Record = { builder: this._handle, replicas }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReplicas', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the number of replicas */ - withReplicas(replicas: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReplicasInternal(replicas)); - } - - /** @internal */ - private async _disableForwardedHeadersInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/disableForwardedHeaders', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Disables forwarded headers for the project */ - disableForwardedHeaders(): ProjectResourcePromise { - return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); - } - - /** @internal */ - private async _publishAsDockerFileInternal(configure?: (obj: IContainerResource) => 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/publishProjectAsDockerFileWithConfigure', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** 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 _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new 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)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); - } - - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): 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 | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); - } - - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); - } - - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds arguments */ - withArgs(args: string[]): ProjectResourcePromise { - return new ProjectResourcePromise(this._withArgsInternal(args)); - } - - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withArgsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withReferenceInternal(source: IResource, 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 - ); - return new ProjectResource(result, this._client); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - const name = options?.name; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); - } - - /** @internal */ - private async _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReferenceUriInternal(name, uri)); - } - - /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReferenceExternalServiceInternal(externalService)); - } - - /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReferenceEndpointInternal(endpointReference)); - } - - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new ProjectResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); - } - - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ProjectResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ProjectResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withExternalHttpEndpointsInternal()); - } - - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); - } - - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ProjectResourcePromise { - return new ProjectResourcePromise(this._asHttp2ServiceInternal()); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise { - const displayText = options?.displayText; - return new ProjectResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { - const displayText = options?.displayText; - return new ProjectResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); - } - - /** @internal */ - private async _publishWithContainerFilesInternal(source: IResourceWithContainerFiles, destinationPath: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, destinationPath }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFilesFromResource', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ProjectResourcePromise { - return new ProjectResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ProjectResourcePromise { - const exitCode = options?.exitCode; - return new ProjectResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new ProjectResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { - const commandOptions = options?.commandOptions; - return new ProjectResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { - return new ProjectResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); - } - - /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { - return new ProjectResourcePromise(this._withCertificateTrustScopeInternal(scope)); - } - - /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { - const password = options?.password; - return new ProjectResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); - } - - /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { - const iconVariant = options?.iconVariant; - return new ProjectResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, probeType }; - if (path !== undefined) rpcArgs.path = path; - if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; - if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; - if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; - if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; - if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { - const path = options?.path; - const initialDelaySeconds = options?.initialDelaySeconds; - const periodSeconds = options?.periodSeconds; - const timeoutSeconds = options?.timeoutSeconds; - const failureThreshold = options?.failureThreshold; - const successThreshold = options?.successThreshold; - const endpointName = options?.endpointName; - return new ProjectResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ProjectResourcePromise { - return new ProjectResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for ProjectResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ProjectResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ProjectResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); - } - - /** Sets the number of replicas */ - withReplicas(replicas: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); - } - - /** Disables forwarded headers for the project */ - disableForwardedHeaders(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); - } - - /** 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))); - } - - /** 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 callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); - } - - /** Adds arguments */ - withArgs(args: string[]): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); - } - - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.asHttp2Service())); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); - } - - /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// ISqlServerDatabaseResource -// ============================================================================ - -export interface ISqlServerDatabaseResource { - toJSON(): MarshalledHandle; - parent: { - get: () => Promise; - }; - connectionStringExpression: { - get: () => Promise; - }; - uriExpression: { - get: () => Promise; - }; - jdbcConnectionString: { - get: () => Promise; - }; - databaseName: { - get: () => Promise; - }; - name: { - get: () => Promise; - }; - withContainerRegistry(registry: IResource): ISqlServerDatabaseResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerDatabaseResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerDatabaseResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerDatabaseResourcePromise; - withConnectionPropertyValue(name: string, value: string): ISqlServerDatabaseResourcePromise; - getConnectionProperty(key: string): Promise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ISqlServerDatabaseResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerDatabaseResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerDatabaseResourcePromise; - excludeFromManifest(): ISqlServerDatabaseResourcePromise; - withExplicitStart(): ISqlServerDatabaseResourcePromise; - withHealthCheck(key: string): ISqlServerDatabaseResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerDatabaseResourcePromise; - withParentRelationship(parent: IResource): ISqlServerDatabaseResourcePromise; - withChildRelationship(child: IResource): ISqlServerDatabaseResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerDatabaseResourcePromise; - excludeFromMcp(): ISqlServerDatabaseResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerDatabaseResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerDatabaseResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerDatabaseResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerDatabaseResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerDatabaseResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerDatabaseResourcePromise; - withCreationScript(script: string): ISqlServerDatabaseResourcePromise; -} - -export interface ISqlServerDatabaseResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): ISqlServerDatabaseResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerDatabaseResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerDatabaseResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerDatabaseResourcePromise; - withConnectionPropertyValue(name: string, value: string): ISqlServerDatabaseResourcePromise; - getConnectionProperty(key: string): Promise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerDatabaseResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ISqlServerDatabaseResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerDatabaseResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerDatabaseResourcePromise; - excludeFromManifest(): ISqlServerDatabaseResourcePromise; - withExplicitStart(): ISqlServerDatabaseResourcePromise; - withHealthCheck(key: string): ISqlServerDatabaseResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerDatabaseResourcePromise; - withParentRelationship(parent: IResource): ISqlServerDatabaseResourcePromise; - withChildRelationship(child: IResource): ISqlServerDatabaseResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerDatabaseResourcePromise; - excludeFromMcp(): ISqlServerDatabaseResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerDatabaseResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerDatabaseResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerDatabaseResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerDatabaseResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerDatabaseResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerDatabaseResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerDatabaseResourcePromise; - withCreationScript(script: string): ISqlServerDatabaseResourcePromise; -} - -// ============================================================================ -// SqlServerDatabaseResource -// ============================================================================ - -export class SqlServerDatabaseResource extends ResourceBuilderBase { - constructor(handle: SqlServerDatabaseResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** Gets the Parent property */ - parent = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.parent', - { context: this._handle } - ); - return new SqlServerServerResource(handle, this._client); - }, - }; - - /** Gets the ConnectionStringExpression property */ - connectionStringExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.connectionStringExpression', - { context: this._handle } - ); - }, - }; - - /** Gets the UriExpression property */ - uriExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.uriExpression', - { context: this._handle } - ); - }, - }; - - /** Gets the JdbcConnectionString property */ - jdbcConnectionString = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.jdbcConnectionString', - { context: this._handle } - ); - }, - }; - - /** Gets the DatabaseName property */ - databaseName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.databaseName', - { context: this._handle } - ); - }, - }; - - /** Gets the Name property */ - name = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerDatabaseResource.name', - { context: this._handle } - ); - }, - }; - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerDatabaseResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new SqlServerDatabaseResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerDatabaseResourcePromise { - const helpLink = options?.helpLink; - return new SqlServerDatabaseResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withConnectionPropertyInternal(name, value)); - } - - /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(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: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): SqlServerDatabaseResourcePromise { - const displayText = options?.displayText; - return new SqlServerDatabaseResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerDatabaseResourcePromise { - const displayText = options?.displayText; - return new SqlServerDatabaseResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerDatabaseResourcePromise { - const commandOptions = options?.commandOptions; - return new SqlServerDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): SqlServerDatabaseResourcePromise { - const iconVariant = options?.iconVariant; - return new SqlServerDatabaseResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerDatabaseResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new SqlServerDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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 SqlServerDatabaseResource(result, this._client); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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 SqlServerDatabaseResource(result, this._client); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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 SqlServerDatabaseResource(result, this._client); - } - - /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._onConnectionStringAvailableInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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 SqlServerDatabaseResource(result, this._client); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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 SqlServerDatabaseResource(result, this._client); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._onResourceReadyInternal(callback)); - } - - /** @internal */ - private async _withCreationScriptInternal(script: string): Promise { - const rpcArgs: Record = { builder: this._handle, script }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/withCreationScript', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Defines the SQL script used to create the database */ - withCreationScript(script: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withCreationScriptInternal(script)); - } - -} - -/** - * Thenable wrapper for SqlServerDatabaseResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class SqlServerDatabaseResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: SqlServerDatabaseResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(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: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - - /** Defines the SQL script used to create the database */ - withCreationScript(script: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withCreationScript(script))); - } - -} - -// ============================================================================ -// ISqlServerServerResource -// ============================================================================ - -export interface ISqlServerServerResource { - toJSON(): MarshalledHandle; - primaryEndpoint: { - get: () => Promise; - }; - host: { - get: () => Promise; - }; - port: { - get: () => Promise; - }; - passwordParameter: { - get: () => Promise; - set: (value: IParameterResource) => Promise; - }; - userNameReference: { - get: () => Promise; - }; - uriExpression: { - get: () => Promise; - }; - jdbcConnectionString: { - get: () => Promise; - }; - connectionStringExpression: { - get: () => Promise; - }; - readonly databases: AspireDict; - entrypoint: { - get: () => Promise; - set: (value: string) => Promise; - }; - shellExecution: { - get: () => Promise; - set: (value: boolean) => Promise; - }; - name: { - get: () => Promise; - }; - withContainerRegistry(registry: IResource): ISqlServerServerResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ISqlServerServerResourcePromise; - withEntrypoint(entrypoint: string): ISqlServerServerResourcePromise; - withImageTag(tag: string): ISqlServerServerResourcePromise; - withImageRegistry(registry: string): ISqlServerServerResourcePromise; - withImage(image: string, options?: WithImageOptions): ISqlServerServerResourcePromise; - withImageSHA256(sha256: string): ISqlServerServerResourcePromise; - withContainerRuntimeArgs(args: string[]): ISqlServerServerResourcePromise; - withLifetime(lifetime: ContainerLifetime): ISqlServerServerResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ISqlServerServerResourcePromise; - publishAsContainer(): ISqlServerServerResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ISqlServerServerResourcePromise; - withContainerName(name: string): ISqlServerServerResourcePromise; - withBuildArg(name: string, value: IParameterResource): ISqlServerServerResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ISqlServerServerResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ISqlServerServerResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerServerResourcePromise; - withContainerNetworkAlias(alias: string): ISqlServerServerResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ISqlServerServerResourcePromise; - withOtlpExporter(): ISqlServerServerResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ISqlServerServerResourcePromise; - publishAsConnectionString(): ISqlServerServerResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerServerResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ISqlServerServerResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ISqlServerServerResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ISqlServerServerResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ISqlServerServerResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ISqlServerServerResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerServerResourcePromise; - withConnectionPropertyValue(name: string, value: string): ISqlServerServerResourcePromise; - withArgs(args: string[]): ISqlServerServerResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): ISqlServerServerResourcePromise; - getConnectionProperty(key: string): Promise; - withReferenceUri(name: string, uri: string): ISqlServerServerResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ISqlServerServerResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ISqlServerServerResourcePromise; - withEndpoint(options?: WithEndpointOptions): ISqlServerServerResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ISqlServerServerResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ISqlServerServerResourcePromise; - withExternalHttpEndpoints(): ISqlServerServerResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ISqlServerServerResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ISqlServerServerResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerServerResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerServerResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ISqlServerServerResourcePromise; - excludeFromManifest(): ISqlServerServerResourcePromise; - waitFor(dependency: IResource): ISqlServerServerResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; - waitForStart(dependency: IResource): ISqlServerServerResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; - withExplicitStart(): ISqlServerServerResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ISqlServerServerResourcePromise; - withHealthCheck(key: string): ISqlServerServerResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ISqlServerServerResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerServerResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ISqlServerServerResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ISqlServerServerResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ISqlServerServerResourcePromise; - withoutHttpsCertificate(): ISqlServerServerResourcePromise; - withParentRelationship(parent: IResource): ISqlServerServerResourcePromise; - withChildRelationship(child: IResource): ISqlServerServerResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerServerResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ISqlServerServerResourcePromise; - excludeFromMcp(): ISqlServerServerResourcePromise; - withRemoteImageName(remoteImageName: string): ISqlServerServerResourcePromise; - withRemoteImageTag(remoteImageTag: string): ISqlServerServerResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerServerResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ISqlServerServerResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerServerResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerServerResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerServerResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerServerResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ISqlServerServerResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerServerResourcePromise; - addDatabase(name: string, options?: AddDatabaseOptions): ISqlServerDatabaseResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ISqlServerServerResourcePromise; - withDataBindMount(source: string, options?: WithDataBindMountOptions): ISqlServerServerResourcePromise; - withPassword(password: IParameterResource): ISqlServerServerResourcePromise; - withHostPort(options?: WithHostPortOptions): ISqlServerServerResourcePromise; -} - -export interface ISqlServerServerResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): ISqlServerServerResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ISqlServerServerResourcePromise; - withEntrypoint(entrypoint: string): ISqlServerServerResourcePromise; - withImageTag(tag: string): ISqlServerServerResourcePromise; - withImageRegistry(registry: string): ISqlServerServerResourcePromise; - withImage(image: string, options?: WithImageOptions): ISqlServerServerResourcePromise; - withImageSHA256(sha256: string): ISqlServerServerResourcePromise; - withContainerRuntimeArgs(args: string[]): ISqlServerServerResourcePromise; - withLifetime(lifetime: ContainerLifetime): ISqlServerServerResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ISqlServerServerResourcePromise; - publishAsContainer(): ISqlServerServerResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ISqlServerServerResourcePromise; - withContainerName(name: string): ISqlServerServerResourcePromise; - withBuildArg(name: string, value: IParameterResource): ISqlServerServerResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ISqlServerServerResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ISqlServerServerResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ISqlServerServerResourcePromise; - withContainerNetworkAlias(alias: string): ISqlServerServerResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ISqlServerServerResourcePromise; - withOtlpExporter(): ISqlServerServerResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ISqlServerServerResourcePromise; - publishAsConnectionString(): ISqlServerServerResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ISqlServerServerResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ISqlServerServerResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ISqlServerServerResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ISqlServerServerResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ISqlServerServerResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ISqlServerServerResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): ISqlServerServerResourcePromise; - withConnectionPropertyValue(name: string, value: string): ISqlServerServerResourcePromise; - withArgs(args: string[]): ISqlServerServerResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withReference(source: IResource, options?: WithReferenceOptions): ISqlServerServerResourcePromise; - getConnectionProperty(key: string): Promise; - withReferenceUri(name: string, uri: string): ISqlServerServerResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ISqlServerServerResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ISqlServerServerResourcePromise; - withEndpoint(options?: WithEndpointOptions): ISqlServerServerResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ISqlServerServerResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ISqlServerServerResourcePromise; - withExternalHttpEndpoints(): ISqlServerServerResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ISqlServerServerResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ISqlServerServerResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ISqlServerServerResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ISqlServerServerResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ISqlServerServerResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ISqlServerServerResourcePromise; - excludeFromManifest(): ISqlServerServerResourcePromise; - waitFor(dependency: IResource): ISqlServerServerResourcePromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; - waitForStart(dependency: IResource): ISqlServerServerResourcePromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ISqlServerServerResourcePromise; - withExplicitStart(): ISqlServerServerResourcePromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ISqlServerServerResourcePromise; - withHealthCheck(key: string): ISqlServerServerResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ISqlServerServerResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ISqlServerServerResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ISqlServerServerResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ISqlServerServerResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ISqlServerServerResourcePromise; - withoutHttpsCertificate(): ISqlServerServerResourcePromise; - withParentRelationship(parent: IResource): ISqlServerServerResourcePromise; - withChildRelationship(child: IResource): ISqlServerServerResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ISqlServerServerResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ISqlServerServerResourcePromise; - excludeFromMcp(): ISqlServerServerResourcePromise; - withRemoteImageName(remoteImageName: string): ISqlServerServerResourcePromise; - withRemoteImageTag(remoteImageTag: string): ISqlServerServerResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ISqlServerServerResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ISqlServerServerResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ISqlServerServerResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ISqlServerServerResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ISqlServerServerResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ISqlServerServerResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ISqlServerServerResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ISqlServerServerResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ISqlServerServerResourcePromise; - addDatabase(name: string, options?: AddDatabaseOptions): ISqlServerDatabaseResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ISqlServerServerResourcePromise; - withDataBindMount(source: string, options?: WithDataBindMountOptions): ISqlServerServerResourcePromise; - withPassword(password: IParameterResource): ISqlServerServerResourcePromise; - withHostPort(options?: WithHostPortOptions): ISqlServerServerResourcePromise; -} - -// ============================================================================ -// SqlServerServerResource -// ============================================================================ - -export class SqlServerServerResource extends ResourceBuilderBase { - constructor(handle: SqlServerServerResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** Gets the PrimaryEndpoint property */ - primaryEndpoint = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.primaryEndpoint', - { context: this._handle } - ); - return new EndpointReference(handle, this._client); - }, - }; - - /** Gets the Host property */ - host = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.host', - { context: this._handle } - ); - return new EndpointReferenceExpression(handle, this._client); - }, - }; - - /** Gets the Port property */ - port = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.port', - { context: this._handle } - ); - return new EndpointReferenceExpression(handle, this._client); - }, - }; - - /** Gets the PasswordParameter property */ - passwordParameter = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.passwordParameter', - { context: this._handle } - ); - return new ParameterResource(handle, this._client); - }, - set: async (value: IParameterResource): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.setPasswordParameter', - { context: this._handle, value } - ); - } - }; - - /** Gets the UserNameReference property */ - userNameReference = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.userNameReference', - { context: this._handle } - ); - }, - }; - - /** Gets the UriExpression property */ - uriExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.uriExpression', - { context: this._handle } - ); - }, - }; - - /** Gets the JdbcConnectionString property */ - jdbcConnectionString = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.jdbcConnectionString', - { context: this._handle } - ); - }, - }; - - /** Gets the ConnectionStringExpression property */ - connectionStringExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.connectionStringExpression', - { context: this._handle } - ); - }, - }; - - /** Gets the Databases property */ - private _databases?: AspireDict; - get databases(): AspireDict { - if (!this._databases) { - this._databases = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.databases', - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.databases' - ); - } - return this._databases; - } - - /** Gets the Entrypoint property */ - entrypoint = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.entrypoint', - { context: this._handle } - ); - }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.setEntrypoint', - { context: this._handle, value } - ); - } - }; - - /** Gets the ShellExecution property */ - shellExecution = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.shellExecution', - { context: this._handle } - ); - }, - set: async (value: boolean): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.setShellExecution', - { context: this._handle, value } - ); - } - }; - - /** Gets the Name property */ - name = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.name', - { context: this._handle } - ); - }, - }; - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withBindMountInternal(source: string, target: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source, target }; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBindMount', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): SqlServerServerResourcePromise { - const isReadOnly = options?.isReadOnly; - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the container image tag */ - withImageTag(tag: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the container image registry */ - withImageRegistry(registry: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): SqlServerServerResourcePromise { - const tag = options?.tag; - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the image SHA256 digest */ - withImageSHA256(sha256: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Configures the resource to be published as a container */ - publishAsContainer(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Configures the resource to use a Dockerfile */ - withDockerfile(contextPath: string, options?: WithDockerfileOptions): SqlServerServerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Sets the container name */ - withContainerName(name: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withContainerNameInternal(name)); - } - - /** @internal */ - private async _withBuildArgInternal(name: string, value: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterBuildArg', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withBuildArgInternal(name, value)); - } - - /** @internal */ - private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterBuildSecret', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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 SqlServerServerResource(result, this._client); - } - - /** Configures endpoint proxy support */ - withEndpointProxySupport(proxyEnabled: boolean): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerServerResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new SqlServerServerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withContainerNetworkAliasInternal(alias: string): Promise { - const rpcArgs: Record = { builder: this._handle, alias }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerNetworkAlias', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a network alias for the container */ - withContainerNetworkAlias(alias: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withContainerNetworkAliasInternal(alias)); - } - - /** @internal */ - private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withMcpServer', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): SqlServerServerResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new SqlServerServerResourcePromise(this._withMcpServerInternal(path, endpointName)); - } - - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withOtlpExporterInternal()); - } - - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); - } - - /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishAsConnectionString', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Publishes the resource as a connection string */ - publishAsConnectionString(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._publishAsConnectionStringInternal()); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerServerResourcePromise { - const helpLink = options?.helpLink; - return new SqlServerServerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentCallbackInternal(callback)); - } - - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); - } - - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); - } - - /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withConnectionPropertyInternal(name, value)); - } - - /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withConnectionPropertyValueInternal(name, value)); - } - - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds arguments */ - withArgs(args: string[]): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withArgsInternal(args)); - } - - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withReferenceInternal(source: IResource, 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 - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): SqlServerServerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - const name = options?.name; - return new SqlServerServerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); - } - - /** 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 _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withReferenceUriInternal(name, uri)); - } - - /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); - } - - /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); - } - - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): SqlServerServerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new SqlServerServerResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); - } - - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): SqlServerServerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new SqlServerServerResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): SqlServerServerResourcePromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new SqlServerServerResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withExternalHttpEndpointsInternal()); - } - - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); - } - - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._asHttp2ServiceInternal()); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): SqlServerServerResourcePromise { - const displayText = options?.displayText; - return new SqlServerServerResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerServerResourcePromise { - const displayText = options?.displayText; - return new SqlServerServerResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): SqlServerServerResourcePromise { - const exitCode = options?.exitCode; - return new SqlServerServerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): SqlServerServerResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new SqlServerServerResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerServerResourcePromise { - const commandOptions = options?.commandOptions; - return new SqlServerServerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); - } - - /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withCertificateTrustScopeInternal(scope)); - } - - /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): SqlServerServerResourcePromise { - const password = options?.password; - return new SqlServerServerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); - } - - /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withoutHttpsCertificateInternal()); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): SqlServerServerResourcePromise { - const iconVariant = options?.iconVariant; - return new SqlServerServerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, probeType }; - if (path !== undefined) rpcArgs.path = path; - if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; - if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; - if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; - if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; - if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): SqlServerServerResourcePromise { - const path = options?.path; - const initialDelaySeconds = options?.initialDelaySeconds; - const periodSeconds = options?.periodSeconds; - const timeoutSeconds = options?.timeoutSeconds; - const failureThreshold = options?.failureThreshold; - const successThreshold = options?.successThreshold; - const endpointName = options?.endpointName; - return new SqlServerServerResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerServerResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new SqlServerServerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** @internal */ - private async _withVolumeInternal(target: string, name?: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { resource: this._handle, target }; - if (name !== undefined) rpcArgs.name = name; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withVolume', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): SqlServerServerResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new SqlServerServerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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 SqlServerServerResource(result, this._client); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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 SqlServerServerResource(result, this._client); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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 SqlServerServerResource(result, this._client); - } - - /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._onConnectionStringAvailableInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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 SqlServerServerResource(result, this._client); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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 SqlServerServerResource(result, this._client); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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 SqlServerServerResource(result, this._client); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._onResourceReadyInternal(callback)); - } - - /** @internal */ - private async _addDatabaseInternal(name: string, databaseName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (databaseName !== undefined) rpcArgs.databaseName = databaseName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/addDatabase', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Adds a SQL Server database resource */ - addDatabase(name: string, options?: AddDatabaseOptions): SqlServerDatabaseResourcePromise { - const databaseName = options?.databaseName; - return new SqlServerDatabaseResourcePromise(this._addDatabaseInternal(name, databaseName)); - } - - /** @internal */ - private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (name !== undefined) rpcArgs.name = name; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/withDataVolume', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a named volume for the SQL Server data folder */ - withDataVolume(options?: WithDataVolumeOptions): SqlServerServerResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new SqlServerServerResourcePromise(this._withDataVolumeInternal(name, isReadOnly)); - } - - /** @internal */ - private async _withDataBindMountInternal(source: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/withDataBindMount', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a bind mount for the SQL Server data folder */ - withDataBindMount(source: string, options?: WithDataBindMountOptions): SqlServerServerResourcePromise { - const isReadOnly = options?.isReadOnly; - return new SqlServerServerResourcePromise(this._withDataBindMountInternal(source, isReadOnly)); - } - - /** @internal */ - private async _withPasswordInternal(password: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, password }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/withPassword', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Configures the password for the SQL Server resource */ - withPassword(password: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withPasswordInternal(password)); - } - - /** @internal */ - private async _withHostPortInternal(port?: number): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/withHostPort', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets the host port for the SQL Server resource */ - withHostPort(options?: WithHostPortOptions): SqlServerServerResourcePromise { - const port = options?.port; - return new SqlServerServerResourcePromise(this._withHostPortInternal(port)); - } - -} - -/** - * Thenable wrapper for SqlServerServerResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class SqlServerServerResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: SqlServerServerResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); - } - - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); - } - - /** Sets the container image tag */ - withImageTag(tag: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); - } - - /** Sets the container image registry */ - withImageRegistry(registry: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); - } - - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); - } - - /** Sets the image SHA256 digest */ - withImageSHA256(sha256: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); - } - - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); - } - - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); - } - - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); - } - - /** Configures the resource to be published as a container */ - publishAsContainer(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); - } - - /** Configures the resource to use a Dockerfile */ - withDockerfile(contextPath: string, options?: WithDockerfileOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); - } - - /** Sets the container name */ - withContainerName(name: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); - } - - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); - } - - /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); - } - - /** Configures endpoint proxy support */ - withEndpointProxySupport(proxyEnabled: boolean): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a network alias for the container */ - withContainerNetworkAlias(alias: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); - } - - /** Publishes the resource as a connection string */ - publishAsConnectionString(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** Adds arguments */ - withArgs(args: string[]): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Gets a connection property by key */ - getConnectionProperty(key: string): Promise { - return this._promise.then(obj => obj.getConnectionProperty(key)); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); - } - - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(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: IBeforeResourceStartedEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - - /** Adds a SQL Server database resource */ - addDatabase(name: string, options?: AddDatabaseOptions): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.addDatabase(name, options))); - } - - /** Adds a named volume for the SQL Server data folder */ - withDataVolume(options?: WithDataVolumeOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); - } - - /** Adds a bind mount for the SQL Server data folder */ - withDataBindMount(source: string, options?: WithDataBindMountOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withDataBindMount(source, options))); - } - - /** Configures the password for the SQL Server resource */ - withPassword(password: IParameterResource): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withPassword(password))); - } - - /** Sets the host port for the SQL Server resource */ - withHostPort(options?: WithHostPortOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withHostPort(options))); - } - -} - -// ============================================================================ -// IComputeResource -// ============================================================================ - -export interface IComputeResource { - toJSON(): MarshalledHandle; - withRemoteImageName(remoteImageName: string): IComputeResourcePromise; - withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; -} - -export interface IComputeResourcePromise extends PromiseLike { - withRemoteImageName(remoteImageName: string): IComputeResourcePromise; - withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; -} - -// ============================================================================ -// ComputeResource -// ============================================================================ - -export class ComputeResource extends ResourceBuilderBase { - constructor(handle: IComputeResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ComputeResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', - rpcArgs - ); - return new ComputeResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - -} - -/** - * Thenable wrapper for ComputeResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ComputeResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ComputeResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - -} - -// ============================================================================ -// IContainerFilesDestinationResource -// ============================================================================ - -export interface IContainerFilesDestinationResource { - toJSON(): MarshalledHandle; - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IContainerFilesDestinationResourcePromise; -} - -export interface IContainerFilesDestinationResourcePromise extends PromiseLike { - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): IContainerFilesDestinationResourcePromise; -} - -// ============================================================================ -// ContainerFilesDestinationResource -// ============================================================================ - -export class ContainerFilesDestinationResource extends ResourceBuilderBase { - constructor(handle: IContainerFilesDestinationResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _publishWithContainerFilesInternal(source: IResourceWithContainerFiles, destinationPath: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, destinationPath }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFilesFromResource', - rpcArgs - ); - return new ContainerFilesDestinationResource(result, this._client); - } - - /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ContainerFilesDestinationResourcePromise { - return new ContainerFilesDestinationResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); - } - -} - -/** - * Thenable wrapper for ContainerFilesDestinationResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ContainerFilesDestinationResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ContainerFilesDestinationResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): ContainerFilesDestinationResourcePromise { - return new ContainerFilesDestinationResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); - } - -} - -// ============================================================================ -// IResource -// ============================================================================ - -export interface IResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IResource): IResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; - excludeFromManifest(): IResourcePromise; - withExplicitStart(): IResourcePromise; - withHealthCheck(key: string): IResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; - withParentRelationship(parent: IResource): IResourcePromise; - withChildRelationship(child: IResource): IResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; - excludeFromMcp(): IResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; -} - -export interface IResourcePromise extends PromiseLike { - withContainerRegistry(registry: IResource): IResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; - excludeFromManifest(): IResourcePromise; - withExplicitStart(): IResourcePromise; - withHealthCheck(key: string): IResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; - withParentRelationship(parent: IResource): IResourcePromise; - withChildRelationship(child: IResource): IResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; - excludeFromMcp(): IResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; -} - -// ============================================================================ -// Resource -// ============================================================================ - -export class Resource extends ResourceBuilderBase { - constructor(handle: IResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ResourcePromise { - return new ResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (buildImage !== undefined) rpcArgs.buildImage = buildImage; - if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDockerfileBaseImage', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new ResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { - const helpLink = options?.helpLink; - return new ResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } - - /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrl', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ResourcePromise { - const displayText = options?.displayText; - return new ResourcePromise(this._withUrlInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { - const rpcArgs: Record = { builder: this._handle, url }; - if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlExpression', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { - const displayText = options?.displayText; - return new ResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { - return new ResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ResourcePromise { - return new ResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ResourcePromise { - return new ResourcePromise(this._withExplicitStartInternal()); - } - - /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ResourcePromise { - return new ResourcePromise(this._withHealthCheckInternal(key)); - } - - /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { - const executeCommandId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); - }); - const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; - if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { - const commandOptions = options?.commandOptions; - return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ResourcePromise { - return new ResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ResourcePromise { - return new ResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { - const iconVariant = options?.iconVariant; - return new ResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ResourcePromise { - return new ResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; - if (dependsOn !== undefined) rpcArgs.dependsOn = dependsOn; - if (requiredBy !== undefined) rpcArgs.requiredBy = requiredBy; - if (tags !== undefined) rpcArgs.tags = tags; - if (description !== undefined) rpcArgs.description = description; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => 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: IBeforeResourceStartedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); - } - - /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => 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: IResourceStoppedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onResourceStoppedInternal(callback)); - } - - /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => 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: IInitializeResourceEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onInitializeResourceInternal(callback)); - } - - /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => 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: IResourceReadyEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onResourceReadyInternal(callback)); - } - -} - -/** - * Thenable wrapper for Resource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: Resource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IResource): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: IResource): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: IResource): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); - } - - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); - } - - /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); - } - - /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); - } - - /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); - } - -} - -// ============================================================================ -// IResourceWithArgs -// ============================================================================ - -export interface IResourceWithArgs { - toJSON(): MarshalledHandle; - withArgs(args: string[]): IResourceWithArgsPromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; -} - -export interface IResourceWithArgsPromise extends PromiseLike { - withArgs(args: string[]): IResourceWithArgsPromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; -} - -// ============================================================================ -// ResourceWithArgs -// ============================================================================ - -export class ResourceWithArgs extends ResourceBuilderBase { - constructor(handle: IResourceWithArgsHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withArgsInternal(args: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, args }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgs', - rpcArgs - ); - return new ResourceWithArgs(result, this._client); - } - - /** Adds arguments */ - withArgs(args: string[]): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._withArgsInternal(args)); - } - - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallback', - rpcArgs - ); - return new ResourceWithArgs(result, this._client); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ResourceWithArgs(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._withArgsCallbackAsyncInternal(callback)); - } - -} - -/** - * Thenable wrapper for ResourceWithArgs that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithArgsPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithArgs) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Adds arguments */ - withArgs(args: string[]): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgs(args))); - } - - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); - } - -} - -// ============================================================================ -// IResourceWithConnectionString -// ============================================================================ - -export interface IResourceWithConnectionString { - toJSON(): MarshalledHandle; - withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; - getConnectionProperty(key: string): Promise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; -} - -export interface IResourceWithConnectionStringPromise extends PromiseLike { - withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; - getConnectionProperty(key: string): Promise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; -} - -// ============================================================================ -// ResourceWithConnectionString -// ============================================================================ - -export class ResourceWithConnectionString extends ResourceBuilderBase { - constructor(handle: IResourceWithConnectionStringHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', - rpcArgs - ); - return new ResourceWithConnectionString(result, this._client); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._withConnectionPropertyInternal(name, value)); - } - - /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', - rpcArgs - ); - return new ResourceWithConnectionString(result, this._client); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._withConnectionPropertyValueInternal(name, value)); - } - - /** 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 _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => 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: IConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); - } - -} - -/** - * Thenable wrapper for ResourceWithConnectionString that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithConnectionStringPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithConnectionString) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** 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: IConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); - } - -} - -// ============================================================================ -// IResourceWithContainerFiles -// ============================================================================ - -export interface IResourceWithContainerFiles { - toJSON(): MarshalledHandle; - withContainerFilesSource(sourcePath: string): IResourceWithContainerFilesPromise; - clearContainerFilesSources(): IResourceWithContainerFilesPromise; -} - -export interface IResourceWithContainerFilesPromise extends PromiseLike { - withContainerFilesSource(sourcePath: string): IResourceWithContainerFilesPromise; - clearContainerFilesSources(): IResourceWithContainerFilesPromise; -} - -// ============================================================================ -// ResourceWithContainerFiles -// ============================================================================ - -export class ResourceWithContainerFiles extends ResourceBuilderBase { - constructor(handle: IResourceWithContainerFilesHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerFilesSourceInternal(sourcePath: string): Promise { - const rpcArgs: Record = { builder: this._handle, sourcePath }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerFilesSource', - rpcArgs - ); - return new ResourceWithContainerFiles(result, this._client); - } - - /** Sets the source directory for container files */ - withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { - return new ResourceWithContainerFilesPromise(this._withContainerFilesSourceInternal(sourcePath)); - } - - /** @internal */ - private async _clearContainerFilesSourcesInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/clearContainerFilesSources', - rpcArgs - ); - return new ResourceWithContainerFiles(result, this._client); - } - - /** Clears all container file sources */ - clearContainerFilesSources(): ResourceWithContainerFilesPromise { - return new ResourceWithContainerFilesPromise(this._clearContainerFilesSourcesInternal()); - } - -} - -/** - * Thenable wrapper for ResourceWithContainerFiles that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithContainerFilesPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithContainerFiles) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Sets the source directory for container files */ - withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise { - return new ResourceWithContainerFilesPromise(this._promise.then(obj => obj.withContainerFilesSource(sourcePath))); - } - - /** Clears all container file sources */ - clearContainerFilesSources(): ResourceWithContainerFilesPromise { - return new ResourceWithContainerFilesPromise(this._promise.then(obj => obj.clearContainerFilesSources())); - } - -} - -// ============================================================================ -// IResourceWithEndpoints -// ============================================================================ - -export interface IResourceWithEndpoints { - toJSON(): MarshalledHandle; - withMcpServer(options?: WithMcpServerOptions): IResourceWithEndpointsPromise; - withEndpoint(options?: WithEndpointOptions): IResourceWithEndpointsPromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IResourceWithEndpointsPromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IResourceWithEndpointsPromise; - withExternalHttpEndpoints(): IResourceWithEndpointsPromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IResourceWithEndpointsPromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; -} - -export interface IResourceWithEndpointsPromise extends PromiseLike { - withMcpServer(options?: WithMcpServerOptions): IResourceWithEndpointsPromise; - withEndpoint(options?: WithEndpointOptions): IResourceWithEndpointsPromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IResourceWithEndpointsPromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IResourceWithEndpointsPromise; - withExternalHttpEndpoints(): IResourceWithEndpointsPromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IResourceWithEndpointsPromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; -} - -// ============================================================================ -// ResourceWithEndpoints -// ============================================================================ - -export class ResourceWithEndpoints extends ResourceBuilderBase { - constructor(handle: IResourceWithEndpointsHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withMcpServer', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new ResourceWithEndpointsPromise(this._withMcpServerInternal(path, endpointName)); - } - - /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (scheme !== undefined) rpcArgs.scheme = scheme; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - if (isExternal !== undefined) rpcArgs.isExternal = isExternal; - if (protocol !== undefined) rpcArgs.protocol = protocol; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEndpoint', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { - const port = options?.port; - const targetPort = options?.targetPort; - const scheme = options?.scheme; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - const isExternal = options?.isExternal; - const protocol = options?.protocol; - return new ResourceWithEndpointsPromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); - } - - /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpEndpoint', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ResourceWithEndpointsPromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; - if (name !== undefined) rpcArgs.name = name; - if (env !== undefined) rpcArgs.env = env; - if (isProxied !== undefined) rpcArgs.isProxied = isProxied; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsEndpoint', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise { - const port = options?.port; - const targetPort = options?.targetPort; - const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new ResourceWithEndpointsPromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); - } - - /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._withExternalHttpEndpointsInternal()); - } - - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); - } - - /** @internal */ - private async _asHttp2ServiceInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._asHttp2ServiceInternal()); - } - - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); - } - - /** @internal */ - private async _withHttpHealthCheckInternal(path?: string, statusCode?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (statusCode !== undefined) rpcArgs.statusCode = statusCode; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpHealthCheck', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new ResourceWithEndpointsPromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); - } - - /** @internal */ - private async _withHttpProbeInternal(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, probeType }; - if (path !== undefined) rpcArgs.path = path; - if (initialDelaySeconds !== undefined) rpcArgs.initialDelaySeconds = initialDelaySeconds; - if (periodSeconds !== undefined) rpcArgs.periodSeconds = periodSeconds; - if (timeoutSeconds !== undefined) rpcArgs.timeoutSeconds = timeoutSeconds; - if (failureThreshold !== undefined) rpcArgs.failureThreshold = failureThreshold; - if (successThreshold !== undefined) rpcArgs.successThreshold = successThreshold; - if (endpointName !== undefined) rpcArgs.endpointName = endpointName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new ResourceWithEndpoints(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { - const path = options?.path; - const initialDelaySeconds = options?.initialDelaySeconds; - const periodSeconds = options?.periodSeconds; - const timeoutSeconds = options?.timeoutSeconds; - const failureThreshold = options?.failureThreshold; - const successThreshold = options?.successThreshold; - const endpointName = options?.endpointName; - return new ResourceWithEndpointsPromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => 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: IResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); - } - -} - -/** - * Thenable wrapper for ResourceWithEndpoints that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithEndpointsPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithEndpoints) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withMcpServer(options))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); - } - - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); - } - - /** Configures resource for HTTP/2 */ - asHttp2Service(): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.asHttp2Service())); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); - } - - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); - } - - /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); - } - -} - -// ============================================================================ -// IResourceWithEnvironment -// ============================================================================ - -export interface IResourceWithEnvironment { - toJSON(): MarshalledHandle; - withOtlpExporter(): IResourceWithEnvironmentPromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IResourceWithEnvironmentPromise; - withReference(source: IResource, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; - withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; - withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; - withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; - withoutHttpsCertificate(): IResourceWithEnvironmentPromise; -} - -export interface IResourceWithEnvironmentPromise extends PromiseLike { - withOtlpExporter(): IResourceWithEnvironmentPromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IResourceWithEnvironmentPromise; - withReference(source: IResource, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; - withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; - withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; - withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; - withoutHttpsCertificate(): IResourceWithEnvironmentPromise; -} - -// ============================================================================ -// ResourceWithEnvironment -// ============================================================================ - -export class ResourceWithEnvironment extends ResourceBuilderBase { - constructor(handle: IResourceWithEnvironmentHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withOtlpExporterInternal()); - } - - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withOtlpExporterProtocolInternal(protocol)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); - } - - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - 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 on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentParameterInternal(name, parameter)); - } - - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); - } - - /** @internal */ - private async _withReferenceInternal(source: IResource, 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 - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - const name = options?.name; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); - } - - /** @internal */ - private async _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withReferenceUriInternal(name, uri)); - } - - /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withReferenceExternalServiceInternal(externalService)); - } - - /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withReferenceEndpointInternal(endpointReference)); - } - - /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withDeveloperCertificateTrustInternal(trust)); - } - - /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withCertificateTrustScopeInternal(scope)); - } - - /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { - const password = options?.password; - return new ResourceWithEnvironmentPromise(this._withHttpsDeveloperCertificateInternal(password)); - } - - /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withoutHttpsCertificateInternal()); - } - -} - -/** - * Thenable wrapper for ResourceWithEnvironment that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithEnvironment) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures OTLP telemetry export */ - withOtlpExporter(): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withOtlpExporter())); - } - - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); - } - - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); - } - - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); - } - - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); - } - - /** Adds a reference to another resource */ - withReference(source: IResource, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); - } - - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); - } - - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); - } - - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); - } - - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); - } - - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withoutHttpsCertificate())); - } - -} - -// ============================================================================ -// IResourceWithWaitSupport -// ============================================================================ - -export interface IResourceWithWaitSupport { - toJSON(): MarshalledHandle; - waitFor(dependency: IResource): IResourceWithWaitSupportPromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForStart(dependency: IResource): IResourceWithWaitSupportPromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IResourceWithWaitSupportPromise; -} - -export interface IResourceWithWaitSupportPromise extends PromiseLike { - waitFor(dependency: IResource): IResourceWithWaitSupportPromise; - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForStart(dependency: IResource): IResourceWithWaitSupportPromise; - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): IResourceWithWaitSupportPromise; -} - -// ============================================================================ -// ResourceWithWaitSupport -// ============================================================================ - -export class ResourceWithWaitSupport extends ResourceBuilderBase { - constructor(handle: IResourceWithWaitSupportHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _waitForInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', - rpcArgs - ); - return new ResourceWithWaitSupport(result, this._client); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForInternal(dependency)); - } - - /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', - rpcArgs - ); - return new ResourceWithWaitSupport(result, this._client); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForStartInternal(dependency: IResource): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', - rpcArgs - ); - return new ResourceWithWaitSupport(result, this._client); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForStartInternal(dependency)); - } - - /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IResource, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', - rpcArgs - ); - return new ResourceWithWaitSupport(result, this._client); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); - } - - /** @internal */ - private async _waitForCompletionInternal(dependency: IResource, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', - rpcArgs - ); - return new ResourceWithWaitSupport(result, this._client); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { - const exitCode = options?.exitCode; - return new ResourceWithWaitSupportPromise(this._waitForCompletionInternal(dependency, exitCode)); - } - -} - -/** - * Thenable wrapper for ResourceWithWaitSupport that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithWaitSupportPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithWaitSupport) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Waits for another resource to be ready */ - waitFor(dependency: IResource): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitFor(dependency))); - } - - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); - } - - /** Waits for another resource to start */ - waitForStart(dependency: IResource): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStart(dependency))); - } - - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IResource, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); - } - - /** Waits for resource completion */ - waitForCompletion(dependency: IResource, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); - } - -} - -// ============================================================================ -// Connection Helper -// ============================================================================ - -/** - * Creates and connects to the Aspire AppHost. - * Reads connection info from environment variables set by `aspire run`. - */ -export async function connect(): Promise { - const socketPath = process.env.REMOTE_APP_HOST_SOCKET_PATH; - if (!socketPath) { - throw new Error( - 'REMOTE_APP_HOST_SOCKET_PATH environment variable not set. ' + - 'Run this application using `aspire run`.' - ); - } - - const client = new AspireClientRpc(socketPath); - await client.connect(); - - // Exit the process if the server connection is lost - client.onDisconnect(() => { - console.error('Connection to AppHost lost. Exiting...'); - process.exit(1); - }); - - return client; -} - -/** - * Creates a new distributed application builder. - * This is the entry point for building Aspire applications. - * - * @param options - Optional configuration options for the builder - * @returns A DistributedApplicationBuilder instance - * - * @example - * const builder = await createBuilder(); - * builder.addRedis("cache"); - * builder.addContainer("api", "mcr.microsoft.com/dotnet/samples:aspnetapp"); - * const app = await builder.build(); - * await app.run(); - */ -export async function createBuilder(options?: CreateBuilderOptions): Promise { - const client = await connect(); - - // Default args, projectDirectory, and appHostFilePath if not provided - // ASPIRE_APPHOST_FILEPATH is set by the CLI for consistent socket hash computation - const effectiveOptions: CreateBuilderOptions = { - ...options, - args: options?.args ?? process.argv.slice(2), - projectDirectory: options?.projectDirectory ?? process.env.ASPIRE_PROJECT_DIRECTORY ?? process.cwd(), - appHostFilePath: options?.appHostFilePath ?? process.env.ASPIRE_APPHOST_FILEPATH - }; - - const handle = await client.invokeCapability( - 'Aspire.Hosting/createBuilderWithOptions', - { options: effectiveOptions } - ); - return new DistributedApplicationBuilder(handle, client); -} - -// Re-export commonly used types -export { Handle, AppHostUsageError, CancellationToken, CapabilityError, registerCallback } from './transport.js'; -export { refExpr, ReferenceExpression } from './base.js'; -export type { ICancellationToken, IReferenceExpression } from './base.js'; - -// ============================================================================ -// Global Error Handling -// ============================================================================ - -/** - * Set up global error handlers to ensure the process exits properly on errors. - * Node.js doesn't exit on unhandled rejections by default, so we need to handle them. - */ -process.on('unhandledRejection', (reason: unknown) => { - const error = reason instanceof Error ? reason : new Error(String(reason)); - - if (reason instanceof AppHostUsageError) { - console.error(`\n❌ AppHost Error: ${error.message}`); - } else if (reason instanceof CapabilityError) { - console.error(`\n❌ Capability Error: ${error.message}`); - console.error(` Code: ${(reason as CapabilityError).code}`); - if ((reason as CapabilityError).capability) { - console.error(` Capability: ${(reason as CapabilityError).capability}`); - } - } else { - console.error(`\n❌ Unhandled Error: ${error.message}`); - if (error.stack) { - console.error(error.stack); - } - } - - process.exit(1); -}); - -process.on('uncaughtException', (error: Error) => { - if (error instanceof AppHostUsageError) { - console.error(`\n❌ AppHost Error: ${error.message}`); - } else { - console.error(`\n❌ Uncaught Exception: ${error.message}`); - } - if (!(error instanceof AppHostUsageError) && error.stack) { - console.error(error.stack); - } - process.exit(1); -}); - -// ============================================================================ -// Handle Wrapper Registrations -// ============================================================================ - -// 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/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/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/Aspire.Hosting.ConnectionStringResource', (handle, client) => new ConnectionStringResource(handle as ConnectionStringResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource', (handle, client) => new ContainerRegistryResource(handle as ContainerRegistryResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource', (handle, client) => new ContainerResource(handle as ContainerResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource', (handle, client) => new CSharpAppResource(handle as CSharpAppResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource', (handle, client) => new DotnetToolResource(handle as DotnetToolResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource', (handle, client) => new ExecutableResource(handle as ExecutableResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ExternalServiceResource', (handle, client) => new ExternalServiceResource(handle as ExternalServiceResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource', (handle, client) => new ParameterResource(handle as ParameterResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource', (handle, client) => new ProjectResource(handle as ProjectResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerDatabaseResource', (handle, client) => new SqlServerDatabaseResource(handle as SqlServerDatabaseResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerServerResource', (handle, client) => new SqlServerServerResource(handle as SqlServerServerResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource', (handle, client) => new ComputeResource(handle as IComputeResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource', (handle, client) => new ContainerFilesDestinationResource(handle as IContainerFilesDestinationResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new Resource(handle as IResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs', (handle, client) => new ResourceWithArgs(handle as IResourceWithArgsHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionString(handle as IResourceWithConnectionStringHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); - diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts deleted file mode 100644 index bbfc7cb1a51..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/base.ts +++ /dev/null @@ -1,586 +0,0 @@ -// base.ts - Core Aspire types: base classes, ReferenceExpression -import type { ICancellationToken } from './transport.js'; -import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; - -// Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, CancellationToken, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; -export type { ICancellationToken, MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; -export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './transport.js'; - -// ============================================================================ -// Reference Expression -// ============================================================================ - -/** - * Represents a reference expression that can be passed to capabilities. - * - * Reference expressions are serialized in the protocol as: - * ```json - * { - * "$expr": { - * "format": "redis://{0}:{1}", - * "valueProviders": [ - * { "$handle": "Aspire.Hosting.ApplicationModel/EndpointReference:1" }, - * { "$handle": "Aspire.Hosting.ApplicationModel/EndpointReference:2" } - * ] - * } - * } - * ``` - * - * @example - * ```typescript - * const redis = await builder.addRedis("cache"); - * const endpoint = await redis.getEndpoint("tcp"); - * - * // Create a reference expression - * const expr = refExpr`redis://${endpoint}:6379`; - * - * // Use it in an environment variable - * await api.withEnvironment("REDIS_URL", expr); - * ``` - */ -export interface IReferenceExpression { - readonly isConditional: boolean; - toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle; - getValue(cancellationToken?: AbortSignal | ICancellationToken): Promise; - toString(): string; -} - -export class ReferenceExpression implements IReferenceExpression { - // Expression mode fields - private readonly _format?: string; - private readonly _valueProviders?: unknown[]; - - // Conditional mode fields - private readonly _condition?: unknown; - private readonly _whenTrue?: IReferenceExpression; - private readonly _whenFalse?: IReferenceExpression; - private readonly _matchValue?: string; - - // Handle mode fields (when wrapping a server-returned handle) - private readonly _handle?: Handle; - private readonly _client?: AspireClient; - - constructor(format: string, valueProviders: unknown[]); - constructor(handle: Handle, client: AspireClient); - constructor(condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression); - constructor( - handleOrFormatOrCondition: Handle | string | unknown, - clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, - whenTrueOrWhenFalse?: IReferenceExpression, - whenFalse?: IReferenceExpression - ) { - if (typeof handleOrFormatOrCondition === 'string') { - this._format = handleOrFormatOrCondition; - this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; - } else if (handleOrFormatOrCondition instanceof Handle) { - this._handle = handleOrFormatOrCondition; - this._client = clientOrValueProvidersOrMatchValue as AspireClient; - } else { - this._condition = handleOrFormatOrCondition; - this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; - this._whenTrue = whenTrueOrWhenFalse; - this._whenFalse = whenFalse; - } - } - - /** - * Gets whether this reference expression is conditional. - */ - get isConditional(): boolean { - return this._condition !== undefined; - } - - /** - * Creates a reference expression from a tagged template literal. - * - * @param strings - The template literal string parts - * @param values - The interpolated values (handles to value providers) - * @returns A ReferenceExpression instance - */ - static create(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { - // Build the format string with {0}, {1}, etc. placeholders - let format = ''; - for (let i = 0; i < strings.length; i++) { - format += strings[i]; - if (i < values.length) { - format += `{${i}}`; - } - } - - // Extract handles from values - const valueProviders = values.map(extractHandleForExpr); - - return new ReferenceExpression(format, valueProviders); - } - - /** - * Creates a conditional reference expression from its constituent parts. - * - * @param condition - A value provider whose result is compared to matchValue - * @param whenTrue - The expression to use when the condition matches - * @param whenFalse - The expression to use when the condition does not match - * @param matchValue - The value to compare the condition against (defaults to "True") - * @returns A ReferenceExpression instance in conditional mode - */ - static createConditional( - condition: unknown, - matchValue: string, - whenTrue: IReferenceExpression, - whenFalse: IReferenceExpression - ): IReferenceExpression { - return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); - } - - /** - * Serializes the reference expression for JSON-RPC transport. - * In expression mode, uses the $expr format with format + valueProviders. - * In conditional mode, uses the $expr format with condition + whenTrue + whenFalse. - * In handle mode, delegates to the handle's serialization. - */ - toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { - if (this._handle) { - return this._handle.toJSON(); - } - - if (this.isConditional) { - return { - $expr: { - condition: extractHandleForExpr(this._condition), - whenTrue: this._whenTrue!.toJSON(), - whenFalse: this._whenFalse!.toJSON(), - matchValue: this._matchValue! - } - }; - } - - return { - $expr: { - format: this._format!, - valueProviders: this._valueProviders && this._valueProviders.length > 0 ? this._valueProviders : undefined - } - }; - } - - /** - * 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 | ICancellationToken): 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. - */ - toString(): string { - if (this._handle) { - return `ReferenceExpression(handle)`; - } - if (this.isConditional) { - return `ReferenceExpression(conditional)`; - } - return `ReferenceExpression(${this._format})`; - } -} - -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. - * @internal - */ -function extractHandleForExpr(value: unknown): unknown { - if (value === null || value === undefined) { - throw new Error('Cannot use null or undefined in reference expression'); - } - - // String literals - include directly in the expression - if (typeof value === 'string') { - return value; - } - - // Number literals - convert to string - if (typeof value === 'number') { - return String(value); - } - - // Handle objects - get their JSON representation - if (value instanceof Handle) { - return value.toJSON(); - } - - // 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 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 || '$expr' in json)) { - return json; - } - } - - throw new Error( - `Cannot use value of type ${typeof value} in reference expression. ` + - `Expected a Handle, string, or number.` - ); -} - -/** - * Tagged template function for creating reference expressions. - * - * Use this to create dynamic expressions that reference endpoints, parameters, and other - * value providers. The expression is evaluated at runtime by Aspire. - * - * @example - * ```typescript - * const redis = await builder.addRedis("cache"); - * const endpoint = await redis.getEndpoint("tcp"); - * - * // Create a reference expression using the tagged template - * const expr = refExpr`redis://${endpoint}:6379`; - * - * // Use it in an environment variable - * await api.withEnvironment("REDIS_URL", expr); - * ``` - */ -export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { - return ReferenceExpression.create(strings, ...values); -} - -// ============================================================================ -// ResourceBuilderBase -// ============================================================================ - -/** - * Base class for resource builders (e.g., RedisBuilder, ContainerBuilder). - * Provides handle management and JSON serialization. - */ -export class ResourceBuilderBase { - constructor(protected _handle: THandle, protected _client: AspireClient) {} - - toJSON(): MarshalledHandle { return this._handle.toJSON(); } -} - -// ============================================================================ -// AspireList - Mutable List Wrapper -// ============================================================================ - -/** - * Wrapper for a mutable .NET List. - * Provides array-like methods that invoke capabilities on the underlying collection. - * - * @example - * ```typescript - * const items = await resource.getItems(); // Returns AspireList - * const count = await items.count(); - * const first = await items.get(0); - * await items.add(newItem); - * ``` - */ -export class AspireList { - private _resolvedHandle?: Handle; - private _resolvePromise?: Promise; - - constructor( - private readonly _handleOrContext: Handle, - private readonly _client: AspireClient, - private readonly _typeId: string, - private readonly _getterCapabilityId?: string - ) { - // If no getter capability, the handle is already the list handle - if (!_getterCapabilityId) { - this._resolvedHandle = _handleOrContext; - } - } - - /** - * Ensures we have the actual list handle by calling the getter if needed. - */ - private async _ensureHandle(): Promise { - if (this._resolvedHandle) { - return this._resolvedHandle; - } - if (this._resolvePromise) { - return this._resolvePromise; - } - // Call the getter capability to get the actual list handle - this._resolvePromise = (async () => { - const result = await this._client.invokeCapability(this._getterCapabilityId!, { - context: this._handleOrContext - }); - this._resolvedHandle = result as Handle; - return this._resolvedHandle; - })(); - return this._resolvePromise; - } - - /** - * Gets the number of elements in the list. - */ - async count(): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/List.length', { - list: handle - }) as number; - } - - /** - * Gets the element at the specified index. - */ - async get(index: number): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/List.get', { - list: handle, - index - }) as T; - } - - /** - * Adds an element to the end of the list. - */ - async add(item: T): Promise { - const handle = await this._ensureHandle(); - await this._client.invokeCapability('Aspire.Hosting/List.add', { - list: handle, - item - }); - } - - /** - * Removes the element at the specified index. - */ - async removeAt(index: number): Promise { - const handle = await this._ensureHandle(); - await this._client.invokeCapability('Aspire.Hosting/List.removeAt', { - list: handle, - index - }); - } - - /** - * Clears all elements from the list. - */ - async clear(): Promise { - const handle = await this._ensureHandle(); - await this._client.invokeCapability('Aspire.Hosting/List.clear', { - list: handle - }); - } - - /** - * Converts the list to an array (creates a copy). - */ - async toArray(): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/List.toArray', { - list: handle - }) as T[]; - } - - 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._resolvedHandle.toJSON(); - } -} - -// ============================================================================ -// AspireDict - Mutable Dictionary Wrapper -// ============================================================================ - -/** - * Wrapper for a mutable .NET Dictionary. - * Provides object-like methods that invoke capabilities on the underlying collection. - * - * @example - * ```typescript - * const config = await resource.getConfig(); // Returns AspireDict - * const value = await config.get("key"); - * await config.set("key", "value"); - * const hasKey = await config.containsKey("key"); - * ``` - */ -export class AspireDict { - private _resolvedHandle?: Handle; - private _resolvePromise?: Promise; - - constructor( - private readonly _handleOrContext: Handle, - private readonly _client: AspireClient, - private readonly _typeId: string, - private readonly _getterCapabilityId?: string - ) { - // If no getter capability, the handle is already the dictionary handle - if (!_getterCapabilityId) { - this._resolvedHandle = _handleOrContext; - } - } - - /** - * Ensures we have the actual dictionary handle by calling the getter if needed. - */ - private async _ensureHandle(): Promise { - if (this._resolvedHandle) { - return this._resolvedHandle; - } - if (this._resolvePromise) { - return this._resolvePromise; - } - // Call the getter capability to get the actual dictionary handle - this._resolvePromise = (async () => { - const result = await this._client.invokeCapability(this._getterCapabilityId!, { - context: this._handleOrContext - }); - this._resolvedHandle = result as Handle; - return this._resolvedHandle; - })(); - return this._resolvePromise; - } - - /** - * Gets the number of key-value pairs in the dictionary. - */ - async count(): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/Dict.count', { - dict: handle - }) as number; - } - - /** - * Gets the value associated with the specified key. - * @throws If the key is not found. - */ - async get(key: K): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/Dict.get', { - dict: handle, - key - }) as V; - } - - /** - * Sets the value for the specified key. - */ - async set(key: K, value: V): Promise { - const handle = await this._ensureHandle(); - await this._client.invokeCapability('Aspire.Hosting/Dict.set', { - dict: handle, - key, - value - }); - } - - /** - * Determines whether the dictionary contains the specified key. - */ - async containsKey(key: K): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/Dict.has', { - dict: handle, - key - }) as boolean; - } - - /** - * Removes the value with the specified key. - * @returns True if the element was removed; false if the key was not found. - */ - async remove(key: K): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/Dict.remove', { - dict: handle, - key - }) as boolean; - } - - /** - * Clears all key-value pairs from the dictionary. - */ - async clear(): Promise { - const handle = await this._ensureHandle(); - await this._client.invokeCapability('Aspire.Hosting/Dict.clear', { - dict: handle - }); - } - - /** - * Gets all keys in the dictionary. - */ - async keys(): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/Dict.keys', { - dict: handle - }) as K[]; - } - - /** - * Gets all values in the dictionary. - */ - async values(): Promise { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/Dict.values', { - dict: handle - }) as V[]; - } - - /** - * Converts the dictionary to a plain object (creates a copy). - * Only works when K is string. - */ - async toObject(): Promise> { - const handle = await this._ensureHandle(); - return await this._client.invokeCapability('Aspire.Hosting/Dict.toObject', { - dict: handle - }) as Record; - } - - 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/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts deleted file mode 100644 index 3098979921f..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/.modules/transport.ts +++ /dev/null @@ -1,1019 +0,0 @@ -// transport.ts - ATS transport layer: RPC, Handle, errors, callbacks -import * as net from 'net'; -import * as rpc from 'vscode-jsonrpc/node.js'; - -// ============================================================================ -// Base Types -// ============================================================================ - -/** - * Type for callback functions that can be registered and invoked from .NET. - * Internal: receives args and client for handle wrapping. - */ -export type CallbackFunction = (args: unknown, client: AspireClient) => unknown | Promise; - -/** - * Represents a handle to a .NET object in the ATS system. - * Handles are typed references that can be passed between capabilities. - */ -export interface MarshalledHandle { - /** The handle ID (instance number) */ - $handle: string; - /** The ATS type ID */ - $type: string; -} - -/** - * Error details for ATS errors. - */ -export interface AtsErrorDetails { - /** The parameter that caused the error */ - parameter?: string; - /** The expected type or value */ - expected?: string; - /** The actual type or value */ - actual?: string; -} - -/** - * Structured error from ATS capability invocation. - */ -export interface AtsError { - /** Machine-readable error code */ - code: string; - /** Human-readable error message */ - message: string; - /** The capability that failed (if applicable) */ - capability?: string; - /** Additional error details */ - details?: AtsErrorDetails; -} - -/** - * ATS error codes returned by the server. - */ -export const AtsErrorCodes = { - /** Unknown capability ID */ - CapabilityNotFound: 'CAPABILITY_NOT_FOUND', - /** Handle ID doesn't exist or was disposed */ - HandleNotFound: 'HANDLE_NOT_FOUND', - /** Handle type doesn't satisfy capability's type constraint */ - TypeMismatch: 'TYPE_MISMATCH', - /** Missing required argument or wrong type */ - InvalidArgument: 'INVALID_ARGUMENT', - /** Argument value outside valid range */ - ArgumentOutOfRange: 'ARGUMENT_OUT_OF_RANGE', - /** Error occurred during callback invocation */ - CallbackError: 'CALLBACK_ERROR', - /** Unexpected error in capability execution */ - InternalError: 'INTERNAL_ERROR', -} as const; - -/** - * Type guard to check if a value is an ATS error response. - */ -export function isAtsError(value: unknown): value is { $error: AtsError } { - return ( - value !== null && - typeof value === 'object' && - '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' && - (value as { $error: unknown }).$error !== null - ); -} - -/** - * Type guard to check if a value is a marshalled handle. - */ -export function isMarshalledHandle(value: unknown): value is MarshalledHandle { - return ( - value !== null && - typeof value === 'object' && - '$handle' in value && - '$type' in value - ); -} - -function isAbortSignal(value: unknown): value is AbortSignal { - return ( - value !== null && - typeof value === 'object' && - 'aborted' in value && - 'addEventListener' in value && - 'removeEventListener' in value - ); -} - -function isCancellationTokenLike(value: unknown): value is ICancellationToken { - return ( - value !== null && - typeof value === 'object' && - 'register' in value && - typeof (value as { register?: unknown }).register === 'function' && - 'toJSON' in value && - typeof (value as { toJSON?: unknown }).toJSON === 'function' - ); -} - -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 -// ============================================================================ - -/** - * A typed handle to a .NET object in the ATS system. - * Handles are opaque references that can be passed to capabilities. - * - * @typeParam T - The ATS type ID (e.g., "Aspire.Hosting/IDistributedApplicationBuilder") - */ -export class Handle { - private readonly _handleId: string; - private readonly _typeId: T; - - constructor(marshalled: MarshalledHandle) { - this._handleId = marshalled.$handle; - this._typeId = marshalled.$type as T; - } - - /** The handle ID (instance number) */ - get $handle(): string { - return this._handleId; - } - - /** The ATS type ID */ - get $type(): T { - return this._typeId; - } - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { - return { - $handle: this._handleId, - $type: this._typeId - }; - } - - /** String representation for debugging */ - toString(): string { - return `Handle<${this._typeId}>(${this._handleId})`; - } -} - -// ============================================================================ -// 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 interface ICancellationToken { - toJSON(): string | undefined; - register(client?: AspireClient): string | undefined; -} - -export class CancellationToken implements ICancellationToken { - 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): ICancellationToken { - if (isCancellationTokenLike(value)) { - 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 -// ============================================================================ - -/** - * Factory function for creating typed wrapper instances from handles. - */ -export type HandleWrapperFactory = (handle: Handle, client: AspireClient) => unknown; - -/** - * Registry of handle wrapper factories by type ID. - * Generated code registers wrapper classes here so callback handles can be properly typed. - */ -const handleWrapperRegistry = new Map(); - -/** - * Register a wrapper factory for a type ID. - * Called by generated code to register wrapper classes. - */ -export function registerHandleWrapper(typeId: string, factory: HandleWrapperFactory): void { - handleWrapperRegistry.set(typeId, factory); -} - -/** - * Checks if a value is a marshalled handle and wraps it appropriately. - * Uses the wrapper registry to create typed wrapper instances when available. - * - * @param value - The value to potentially wrap - * @param client - Optional client for creating typed wrapper instances - */ -export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - 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; - } - - 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; -} - -// ============================================================================ -// Capability Error -// ============================================================================ - -/** - * Error thrown when an ATS capability invocation fails. - */ -export class CapabilityError extends Error { - constructor( - /** The structured error from the server */ - public readonly error: AtsError - ) { - super(error.message); - this.name = 'CapabilityError'; - } - - /** Machine-readable error code */ - get code(): string { - return this.error.code; - } - - /** The capability that failed (if applicable) */ - get capability(): string | undefined { - return this.error.capability; - } -} - -/** - * Error thrown when the AppHost script uses the generated SDK incorrectly. - */ -export class AppHostUsageError extends Error { - constructor(message: string) { - super(message); - this.name = 'AppHostUsageError'; - } -} - -function isPromiseLike(value: unknown): value is PromiseLike { - return ( - value !== null && - (typeof value === 'object' || typeof value === 'function') && - 'then' in value && - typeof (value as { then?: unknown }).then === 'function' - ); -} - -function validateCapabilityArgs( - capabilityId: string, - args?: Record -): void { - if (!args) { - return; - } - - const validateValue = (value: unknown, path: string, ancestors: Set): void => { - if (value === null || value === undefined) { - return; - } - - if (isPromiseLike(value)) { - throw new AppHostUsageError( - `Argument '${path}' passed to capability '${capabilityId}' is a Promise-like value. ` + - `This usually means an async builder call was not awaited. ` + - `Did you forget 'await' on a call like builder.addPostgres(...) or resource.addDatabase(...)?` - ); - } - - if (typeof value !== 'object') { - return; - } - - if (ancestors.has(value)) { - throw createCircularReferenceError(capabilityId, path); - } - - ancestors.add(value); - try { - if (Array.isArray(value)) { - for (let i = 0; i < value.length; i++) { - validateValue(value[i], `${path}[${i}]`, ancestors); - } - return; - } - - 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, new Set()); - } -} - -// ============================================================================ -// Callback Registry -// ============================================================================ - -const callbackRegistry = new Map(); -let callbackIdCounter = 0; - -/** - * Register a callback function that can be invoked from the .NET side. - * Returns a callback ID that should be passed to methods accepting callbacks. - * - * .NET passes arguments as an object with positional keys: `{ p0: value0, p1: value1, ... }` - * This function automatically extracts positional parameters and wraps handles. - * - * @example - * // Single parameter callback - * const id = registerCallback((ctx) => console.log(ctx)); - * // .NET sends: { p0: { $handle: "...", $type: "..." } } - * // Callback receives: Handle instance - * - * @example - * // Multi-parameter callback - * const id = registerCallback((a, b) => console.log(a, b)); - * // .NET sends: { p0: "hello", p1: 42 } - * // Callback receives: "hello", 42 - */ -export function registerCallback( - callback: (...args: any[]) => TResult | Promise -): string { - const callbackId = `callback_${++callbackIdCounter}_${Date.now()}`; - - // Wrap the callback to handle .NET's positional argument format - const wrapper: CallbackFunction = async (args: unknown, client: AspireClient) => { - // .NET sends args as object { p0: value0, p1: value1, ... } - if (args && typeof args === 'object' && !Array.isArray(args)) { - const argObj = args as Record; - const argArray: unknown[] = []; - - // Extract positional parameters (p0, p1, p2, ...) - for (let i = 0; ; i++) { - const key = `p${i}`; - if (key in argObj) { - argArray.push(wrapIfHandle(argObj[key], client)); - } else { - break; - } - } - - if (argArray.length > 0) { - // Spread positional arguments to callback - const result = await callback(...argArray); - // DTO writeback protocol: when a void callback returns undefined, we - // return the original args object so the .NET host can detect property - // mutations made by the callback and apply them back to the original - // C# DTO objects. DTO args are plain JS objects (not Handle wrappers), - // so any property changes the callback made are reflected in args. - // - // Non-void callbacks (result !== undefined) return their actual result. - // The .NET side only activates writeback for void delegates whose - // parameters include [AspireDto] types — all other cases discard the - // returned args object, so the extra wire payload is harmless. - // - // IMPORTANT: callbacks that intentionally return undefined will also - // trigger this path. For non-void delegate types, the C# proxy uses - // a result-unmarshalling path (not writeback), so returning args will - // cause an unmarshal error. Void callbacks should never return a - // meaningful value; non-void callbacks should always return one. - return result !== undefined ? result : args; - } - - // No positional params found — nothing to write back - return await callback(); - } - - // Null/undefined - call with no args - if (args === null || args === undefined) { - return await callback(); - } - - // Primitive value - pass as single arg (shouldn't happen with current protocol) - return await callback(wrapIfHandle(args, client)); - }; - - callbackRegistry.set(callbackId, wrapper); - return callbackId; -} - -/** - * Unregister a callback by its ID. - */ -export function unregisterCallback(callbackId: string): boolean { - return callbackRegistry.delete(callbackId); -} - -/** - * Get the number of registered callbacks. - */ -export function getCallbackCount(): number { - return callbackRegistry.size; -} - -// ============================================================================ -// Cancellation Token Registry -// ============================================================================ - -/** - * Registry for cancellation tokens. - * Maps cancellation IDs to cleanup functions. - */ -const cancellationRegistry = new Map void>(); -let cancellationIdCounter = 0; -const connectedClients = new Set(); - -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.' - ); -} - -/** - * 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 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 | ICancellationToken): 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(); - * const id = registerCancellation(controller.signal); - * // Pass id to capability invocation - * // Later: controller.abort() will cancel the operation - */ -export function registerCancellation(signalOrToken?: AbortSignal | ICancellationToken): string | undefined; -export function registerCancellation( - clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, - maybeSignalOrToken?: AbortSignal | ICancellationToken -): string | undefined { - const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; - const signalOrToken = client - ? maybeSignalOrToken - : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; - - if (!signalOrToken) { - return undefined; - } - - if (isCancellationTokenLike(signalOrToken)) { - return signalOrToken.register(client); - } - - const signal = signalOrToken; - const cancellationClient = resolveCancellationClient(client); - - if (signal.aborted) { - throw createAbortError('The operation was aborted before it was sent to the AppHost.'); - } - - const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; - - // Set up the abort listener - const onAbort = () => { - // Send cancel request to host - if (cancellationClient.connected) { - cancellationClient.cancelToken(cancellationId).catch(() => { - // Ignore errors - the operation may have already completed - }); - } - // Clean up the listener - cancellationRegistry.delete(cancellationId); - }; - - // Listen for abort - signal.addEventListener('abort', onAbort, { once: true }); - - // Store cleanup function - cancellationRegistry.set(cancellationId, () => { - signal.removeEventListener('abort', onAbort); - }); - - 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 (isCancellationTokenLike(value)) { - 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. - * - * @param cancellationId - The cancellation ID to unregister - */ -export function unregisterCancellation(cancellationId: string | undefined): void { - if (!cancellationId) { - return; - } - - const cleanup = cancellationRegistry.get(cancellationId); - if (cleanup) { - cleanup(); - cancellationRegistry.delete(cancellationId); - } -} - -// ============================================================================ -// AspireClient (JSON-RPC Connection) -// ============================================================================ - -/** - * Client for connecting to the Aspire AppHost via socket/named pipe. - */ -export class AspireClient { - private connection: rpc.MessageConnection | null = null; - private socket: net.Socket | null = null; - private disconnectCallbacks: (() => void)[] = []; - private _pendingCalls = 0; - private _connectPromise: Promise | null = null; - private _disconnectNotified = false; - - constructor(private socketPath: string) { } - - /** - * Register a callback to be called when the connection is lost - */ - onDisconnect(callback: () => void): void { - this.disconnectCallbacks.push(callback); - } - - private notifyDisconnect(): void { - if (this._disconnectNotified) { - return; - } - - this._disconnectNotified = true; - - for (const callback of this.disconnectCallbacks) { - try { - callback(); - } catch { - // Ignore callback errors - } - } - } - - connect(timeoutMs: number = 5000): Promise { - if (this.connected) { - return Promise.resolve(); - } - - 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._connectPromise = new Promise((resolve, reject) => { - const socket = net.createConnection(pipePath); - this.socket = socket; - - 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; - } - - clearTimeout(timeout); - cleanupPendingListeners(); - - try { - 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.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); - - // Handle callback invocations from the .NET side - this.connection.onRequest('invokeCallback', async (callbackId: string, args: unknown) => { - const callback = callbackRegistry.get(callbackId); - if (!callback) { - throw new Error(`Callback not found: ${callbackId}`); - } - try { - // The registered wrapper handles arg unpacking and handle wrapping - // Pass this client so handles can be wrapped with typed wrapper classes - return await Promise.resolve(callback(args, this)); - } catch (error) { - const message = error instanceof Error ? error.message : String(error); - throw new Error(`Callback execution failed: ${message}`); - } - }); - - 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.'); - } - - connectedClients.add(this); - this._connectPromise = null; - settled = true; - - resolve(); - } catch (error) { - failConnect(error instanceof Error ? error : new Error(String(error))); - } - }; - - 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 { - if (!this.connection) return Promise.reject(new Error('Not connected to AppHost')); - return this.connection.sendRequest('ping'); - } - - /** - * Cancel a CancellationToken by its ID. - * Called when an AbortSignal is aborted. - * - * @param tokenId - The token ID to cancel - * @returns True if the token was found and cancelled, false otherwise - */ - cancelToken(tokenId: string): Promise { - if (!this.connection) return Promise.reject(new Error('Not connected to AppHost')); - return this.connection.sendRequest('cancelToken', tokenId); - } - - /** - * Invoke an ATS capability by ID. - * - * Capabilities are operations exposed by [AspireExport] attributes. - * Results are automatically wrapped in Handle objects when applicable. - * - * @param capabilityId - The capability ID (e.g., "Aspire.Hosting/createBuilder") - * @param args - Arguments to pass to the capability - * @returns The capability result, wrapped as Handle if it's a handle type - * @throws CapabilityError if the capability fails - */ - async invokeCapability( - capabilityId: string, - args?: Record - ): Promise { - if (!this.connection) { - throw new Error('Not connected to AppHost'); - } - - validateCapabilityArgs(capabilityId, args); - const cancellationIds: string[] = []; - - try { - const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - - // 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; - } finally { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); - } - } - } finally { - for (const cancellationId of cancellationIds) { - unregisterCancellation(cancellationId); - } - } - } - - disconnect(): void { - 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 { - return this.connection !== null && this.socket !== null; - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json deleted file mode 100644 index 2815369b08c..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:55686;http://localhost:57768", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:51980", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:28684" - } - } - }, - "packages": { - "Aspire.Hosting.SqlServer": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json deleted file mode 100644 index 30f9b9f1e7e..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Valkey/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Valkey": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json deleted file mode 100644 index f584976ed4b..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Yarp/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29550;http://localhost:28731", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" - } - } - }, - "packages": { - "Aspire.Hosting.Yarp": "" - } -} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json deleted file mode 100644 index 83102f6682b..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "appHost": { - "path": "apphost.ts", - "language": "typescript/nodejs" - }, - "profiles": { - "https": { - "applicationUrl": "https://localhost:29750;http://localhost:28931", - "environmentVariables": { - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10975", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13319" - } - } - }, - "packages": { - "Aspire.Hosting": "", - "Aspire.Hosting.Testing": "", - "Aspire.Hosting.Yarp": "", - "Aspire.Hosting.Redis": "" - } -} \ No newline at end of file diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs index c02a2d1b111..1fecdc678c1 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs @@ -122,15 +122,19 @@ public sealed class AtsTypeScriptCodeGenerator : ICodeGenerator // Mapping of enum type IDs to TypeScript enum names private readonly Dictionary _enumTypeNames = new(StringComparer.Ordinal); - private static string GetInterfaceName(string className) => $"I{className}"; + private static string GetInterfaceName(string className) => className; - private static string GetPromiseInterfaceName(string className) => $"I{className}Promise"; + private static string GetPromiseInterfaceName(string className) => $"{className}Promise"; - private static string GetReferenceExpressionInterfaceName() => "IReferenceExpression"; + private static string GetImplementationClassName(string className) => $"{className}Impl"; - private static string GetCancellationTokenInterfaceName() => "ICancellationToken"; + private static string GetImplementationPromiseClassName(string className) => $"{className}PromiseImpl"; - private static string GetHandleReferenceInterfaceName() => "IHandleReference"; + private static string GetReferenceExpressionInterfaceName() => "ReferenceExpression"; + + private static string GetCancellationTokenInterfaceName() => "CancellationToken"; + + private static string GetHandleReferenceInterfaceName() => "HandleReference"; private string GetConcreteClassName(string typeId) => _wrapperClassNames.GetValueOrDefault(typeId) ?? DeriveClassName(typeId); @@ -410,11 +414,7 @@ private string GenerateAspireSdk(AtsContext context) registerHandleWrapper } from './transport.js'; - import type { - ICancellationToken, - IHandleReference, - IReferenceExpression - } from './base.js'; + import type { HandleReference } from './base.js'; import { ResourceBuilderBase, @@ -1175,15 +1175,17 @@ private void GenerateBuilderClass(BuilderModel builder) GenerateBuilderInterface(builder); GenerateBuilderPromiseInterface(builder); + var implementationClassName = GetImplementationClassName(builder.BuilderClassName); + WriteLine("// ============================================================================"); - WriteLine($"// {builder.BuilderClassName}"); + WriteLine($"// {implementationClassName}"); WriteLine("// ============================================================================"); WriteLine(); var handleType = GetHandleTypeName(builder.TypeId); // Generate builder class extending ResourceBuilderBase - WriteLine($"export class {builder.BuilderClassName} extends ResourceBuilderBase<{handleType}> {{"); + WriteLine($"class {implementationClassName} extends ResourceBuilderBase<{handleType}> implements {builder.BuilderClassName} {{"); // Constructor WriteLine($" constructor(handle: {handleType}, client: AspireClientRpc) {{"); @@ -1276,6 +1278,7 @@ private void GenerateBuilderMethod(BuilderModel builder, AtsCapabilityInfo capab ? GetHandleTypeName(returnTypeId) : "void"; var returnsBuilder = capability.ReturnsBuilder; + var returnImplementationClassName = GetImplementationClassName(returnClassName); // Check if this method returns a non-builder, non-void type (e.g., getEndpoint returns EndpointReference) var hasNonBuilderReturn = !returnsBuilder && capability.ReturnType != null; @@ -1351,7 +1354,7 @@ private void GenerateBuilderMethod(BuilderModel builder, AtsCapabilityInfo capab WriteLine($" '{capability.CapabilityId}',"); WriteLine($" rpcArgs"); WriteLine(" );"); - WriteLine($" return new {returnClassName}(result, this._client);"); + WriteLine($" return new {returnImplementationClassName}(result, this._client);"); } else { @@ -1370,6 +1373,7 @@ private void GenerateBuilderMethod(BuilderModel builder, AtsCapabilityInfo capab WriteLine($" /** {capability.Description} */"); } var promiseClass = $"{returnClassName}Promise"; + var promiseImplementationClass = GetImplementationPromiseClassName(returnClassName); Write($" {methodName}("); Write(publicParamsString); Write($"): {promiseClass} {{"); @@ -1383,7 +1387,7 @@ private void GenerateBuilderMethod(BuilderModel builder, AtsCapabilityInfo capab // Forward all params to internal method var allParamNames = capability.Parameters.Select(p => p.Name); - Write($" return new {promiseClass}(this.{internalMethodName}("); + Write($" return new {promiseImplementationClass}(this.{internalMethodName}("); Write(string.Join(", ", allParamNames)); WriteLine("));"); WriteLine(" }"); @@ -1417,14 +1421,24 @@ private void GenerateArgsObjectWithConditionals( private void GenerateThenableClass(BuilderModel builder) { + var capabilities = builder.Capabilities.Where(c => + c.CapabilityKind != AtsCapabilityKind.PropertyGetter && + c.CapabilityKind != AtsCapabilityKind.PropertySetter).ToList(); + + if (capabilities.Count == 0) + { + return; + } + var promiseClass = $"{builder.BuilderClassName}Promise"; + var promiseImplementationClass = GetImplementationPromiseClassName(builder.BuilderClassName); WriteLine($"/**"); WriteLine($" * Thenable wrapper for {builder.BuilderClassName} that enables fluent chaining."); WriteLine($" * @example"); WriteLine($" * await builder.addSomething().withX().withY();"); WriteLine($" */"); - WriteLine($"export class {promiseClass} implements PromiseLike<{builder.BuilderClassName}> {{"); + WriteLine($"class {promiseImplementationClass} implements {promiseClass} {{"); WriteLine($" constructor(private _promise: Promise<{builder.BuilderClassName}>) {{}}"); WriteLine(); @@ -1440,9 +1454,7 @@ private void GenerateThenableClass(BuilderModel builder) // Generate fluent methods that chain via .then() // Capabilities are already flattened - no need to collect from parents // Filter out property getters and setters - they are not methods - foreach (var capability in builder.Capabilities.Where(c => - c.CapabilityKind != AtsCapabilityKind.PropertyGetter && - c.CapabilityKind != AtsCapabilityKind.PropertySetter)) + foreach (var capability in capabilities) { var methodName = capability.MethodName; @@ -1501,6 +1513,7 @@ private void GenerateThenableClass(BuilderModel builder) // For fluent builder methods, determine the correct promise class. // Factory methods returning a different builder type use the return type's promise class. var methodPromiseClass = promiseClass; + var methodPromiseImplementationClass = promiseImplementationClass; if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && !string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && !string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) @@ -1508,6 +1521,7 @@ private void GenerateThenableClass(BuilderModel builder) var returnClass = _wrapperClassNames.GetValueOrDefault(capability.ReturnType.TypeId) ?? DeriveClassName(capability.ReturnType.TypeId); methodPromiseClass = $"{returnClass}Promise"; + methodPromiseImplementationClass = GetImplementationPromiseClassName(returnClass); } Write($" {methodName}("); @@ -1515,7 +1529,7 @@ private void GenerateThenableClass(BuilderModel builder) Write($"): {methodPromiseClass} {{"); WriteLine(); // Forward to the public method on the underlying object, wrapping result in promise class - Write($" return new {methodPromiseClass}(this._promise.then(obj => obj.{methodName}("); + Write($" return new {methodPromiseImplementationClass}(this._promise.then(obj => obj.{methodName}("); Write(argsString); WriteLine(")));"); WriteLine(" }"); @@ -1580,6 +1594,8 @@ private void GenerateEntryPointFunction(AtsCapabilityInfo capability) // Return type has Promise wrapper - generate fluent function var returnWrapperClass = _wrapperClassNames.GetValueOrDefault(capReturnTypeId) ?? DeriveClassName(capReturnTypeId); + var returnWrapperImplementationClass = GetImplementationClassName(returnWrapperClass); + var returnPromiseImplementationClass = GetImplementationPromiseClassName(returnWrapperClass); var handleType = GetHandleTypeName(capReturnTypeId); Write($"export function {methodName}("); @@ -1596,8 +1612,8 @@ private void GenerateEntryPointFunction(AtsCapabilityInfo capability) WriteLine($" const promise = client.invokeCapability<{handleType}>("); WriteLine($" '{capability.CapabilityId}',"); WriteLine(" rpcArgs"); - WriteLine($" ).then(handle => new {returnWrapperClass}(handle, client));"); - WriteLine($" return new {returnPromiseWrapper}(promise);"); + WriteLine($" ).then(handle => new {returnWrapperImplementationClass}(handle, client));"); + WriteLine($" return new {returnPromiseImplementationClass}(promise);"); WriteLine("}"); } else @@ -1747,7 +1763,7 @@ private void GenerateCallbackBody(AtsParameterInfo callbackParam, IReadOnlyList< // For types with wrapper classes, create an instance of the wrapper var handleType = GetHandleTypeName(cbTypeId); WriteLine($" const {cbParam.Name}Handle = wrapIfHandle({cbParam.Name}Data) as {handleType};"); - WriteLine($" const {cbParam.Name} = new {wrapperClassName}({cbParam.Name}Handle, this._client);"); + WriteLine($" const {cbParam.Name} = new {GetImplementationClassName(wrapperClassName)}({cbParam.Name}Handle, this._client);"); } else { @@ -1776,7 +1792,7 @@ private void GenerateCallbackBody(AtsParameterInfo callbackParam, IReadOnlyList< // For types with wrapper classes, create an instance of the wrapper var handleType = GetHandleTypeName(cbTypeId); WriteLine($" const {cbParam.Name}Handle = wrapIfHandle({callbackArgName}) as {handleType};"); - WriteLine($" const {cbParam.Name} = new {wrapperClassName}({cbParam.Name}Handle, this._client);"); + WriteLine($" const {cbParam.Name} = new {GetImplementationClassName(wrapperClassName)}({cbParam.Name}Handle, this._client);"); } else { @@ -1854,13 +1870,13 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise typeClasses, { var className = _wrapperClassNames.GetValueOrDefault(typeClass.TypeId) ?? DeriveClassName(typeClass.TypeId); var handleType = GetHandleTypeName(typeClass.TypeId); - WriteLine($"registerHandleWrapper('{typeClass.TypeId}', (handle, client) => new {className}(handle as {handleType}, client));"); + WriteLine($"registerHandleWrapper('{typeClass.TypeId}', (handle, client) => new {GetImplementationClassName(className)}(handle as {handleType}, client));"); } // Register resource builder classes @@ -1937,7 +1953,7 @@ private void GenerateHandleWrapperRegistrations(List typeClasses, { var className = _wrapperClassNames.GetValueOrDefault(builder.TypeId) ?? DeriveClassName(builder.TypeId); var handleType = GetHandleTypeName(builder.TypeId); - WriteLine($"registerHandleWrapper('{builder.TypeId}', (handle, client) => new {className}(handle as {handleType}, client));"); + WriteLine($"registerHandleWrapper('{builder.TypeId}', (handle, client) => new {GetImplementationClassName(className)}(handle as {handleType}, client));"); } WriteLine(); @@ -1952,12 +1968,13 @@ private void GenerateTypeClass(BuilderModel model) { var handleType = GetHandleTypeName(model.TypeId); var className = DeriveClassName(model.TypeId); + var implementationClassName = GetImplementationClassName(className); var hasMethods = HasChainableMethods(model); GenerateTypeClassInterface(model); WriteLine("// ============================================================================"); - WriteLine($"// {className}"); + WriteLine($"// {implementationClassName}"); WriteLine("// ============================================================================"); WriteLine(); @@ -1973,7 +1990,7 @@ private void GenerateTypeClass(BuilderModel model) WriteLine($"/**"); WriteLine($" * Type class for {className}."); WriteLine($" */"); - WriteLine($"export class {className} {{"); + WriteLine($"class {implementationClassName} implements {className} {{"); WriteLine($" constructor(private _handle: {handleType}, private _client: AspireClientRpc) {{}}"); WriteLine(); WriteLine($" /** Serialize for JSON-RPC transport */"); @@ -2171,6 +2188,7 @@ private void GeneratePropertyLikeObject(string propertyName, AtsCapabilityInfo? private void GenerateWrapperPropertyObject(string propertyName, AtsCapabilityInfo getter, AtsCapabilityInfo? setter, string wrapperClassName) { var handleType = GetHandleTypeName(getter.ReturnType!.TypeId); + var wrapperImplementationClassName = GetImplementationClassName(wrapperClassName); if (!string.IsNullOrEmpty(getter.Description)) { @@ -2183,7 +2201,7 @@ private void GenerateWrapperPropertyObject(string propertyName, AtsCapabilityInf WriteLine($" '{getter.CapabilityId}',"); WriteLine($" {{ context: this._handle }}"); WriteLine(" );"); - WriteLine($" return new {wrapperClassName}(handle, this._client);"); + WriteLine($" return new {wrapperImplementationClassName}(handle, this._client);"); WriteLine(" },"); if (setter != null) @@ -2482,6 +2500,7 @@ private void GenerateTypeClassMethod(BuilderModel model, AtsCapabilityInfo capab { var className = DeriveClassName(model.TypeId); var promiseClass = $"{className}Promise"; + var promiseImplementationClass = GetImplementationPromiseClassName(className); // Use OwningTypeName if available to extract method name, otherwise parse from MethodName var methodName = !string.IsNullOrEmpty(capability.OwningTypeName) && capability.MethodName.Contains('.') @@ -2538,6 +2557,8 @@ private void GenerateTypeClassMethod(BuilderModel model, AtsCapabilityInfo capab { var returnWrapperClass = _wrapperClassNames.GetValueOrDefault(capability.ReturnType!.TypeId) ?? DeriveClassName(capability.ReturnType.TypeId); + var returnWrapperImplementationClass = GetImplementationClassName(returnWrapperClass); + var returnPromiseImplementationClass = GetImplementationPromiseClassName(returnWrapperClass); var returnHandleType = GetHandleTypeName(capability.ReturnType.TypeId); // Generate internal async method @@ -2560,7 +2581,7 @@ private void GenerateTypeClassMethod(BuilderModel model, AtsCapabilityInfo capab WriteLine($" '{capability.CapabilityId}',"); WriteLine($" rpcArgs"); WriteLine(" );"); - WriteLine($" return new {returnWrapperClass}(result, this._client);"); + WriteLine($" return new {returnWrapperImplementationClass}(result, this._client);"); WriteLine(" }"); WriteLine(); @@ -2575,7 +2596,7 @@ private void GenerateTypeClassMethod(BuilderModel model, AtsCapabilityInfo capab WriteLine($" const {param.Name} = options?.{param.Name};"); } - Write($" return new {returnPromiseWrapper}(this.{internalMethodName}("); + Write($" return new {returnPromiseImplementationClass}(this.{internalMethodName}("); Write(string.Join(", ", userParams.Select(p => p.Name))); WriteLine("));"); WriteLine(" }"); @@ -2618,7 +2639,7 @@ private void GenerateTypeClassMethod(BuilderModel model, AtsCapabilityInfo capab WriteLine($" const {param.Name} = options?.{param.Name};"); } - Write($" return new {promiseClass}(this.{internalMethodName}("); + Write($" return new {promiseImplementationClass}(this.{internalMethodName}("); Write(string.Join(", ", userParams.Select(p => p.Name))); WriteLine("));"); WriteLine(" }"); @@ -2673,11 +2694,12 @@ private void GenerateTypeClassThenableWrapper(BuilderModel model, List {{"); + WriteLine($"class {promiseImplementationClass} implements {promiseClass} {{"); WriteLine($" constructor(private _promise: Promise<{className}>) {{}}"); WriteLine(); @@ -2742,11 +2764,14 @@ private void GenerateTypeClassThenableWrapper(BuilderModel model, List obj.{methodName}("); + Write($" return new {returnPromiseImplementationClass}(this._promise.then(obj => obj.{methodName}("); Write(argsString); WriteLine(")));"); WriteLine(" }"); @@ -2757,7 +2782,7 @@ private void GenerateTypeClassThenableWrapper(BuilderModel model, List obj.{methodName}("); + Write($" return new {promiseImplementationClass}(this._promise.then(obj => obj.{methodName}("); Write(argsString); WriteLine(")));"); WriteLine(" }"); diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts index 6eba4421328..79029117e8c 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts @@ -1,10 +1,9 @@ // base.ts - Core Aspire types: base classes, ReferenceExpression -import type { ICancellationToken } from './transport.js'; import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience export { Handle, AspireClient, CapabilityError, CancellationToken, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; -export type { ICancellationToken, MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; +export type { MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './transport.js'; // ============================================================================ @@ -39,22 +38,22 @@ export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './t * await api.withEnvironment("REDIS_URL", expr); * ``` */ -export interface IReferenceExpression { +export interface ReferenceExpression { readonly isConditional: boolean; toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle; - getValue(cancellationToken?: AbortSignal | ICancellationToken): Promise; + getValue(cancellationToken?: AbortSignal | CancellationToken): Promise; toString(): string; } -export class ReferenceExpression implements IReferenceExpression { +class ReferenceExpressionImpl implements ReferenceExpression { // Expression mode fields private readonly _format?: string; private readonly _valueProviders?: unknown[]; // Conditional mode fields private readonly _condition?: unknown; - private readonly _whenTrue?: IReferenceExpression; - private readonly _whenFalse?: IReferenceExpression; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; private readonly _matchValue?: string; // Handle mode fields (when wrapping a server-returned handle) @@ -63,12 +62,12 @@ export class ReferenceExpression implements IReferenceExpression { constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression); + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); constructor( handleOrFormatOrCondition: Handle | string | unknown, clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, - whenTrueOrWhenFalse?: IReferenceExpression, - whenFalse?: IReferenceExpression + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression ) { if (typeof handleOrFormatOrCondition === 'string') { this._format = handleOrFormatOrCondition; @@ -98,55 +97,6 @@ export class ReferenceExpression implements IReferenceExpression { * @param values - The interpolated values (handles to value providers) * @returns A ReferenceExpression instance */ - static create(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { - // Build the format string with {0}, {1}, etc. placeholders - let format = ''; - for (let i = 0; i < strings.length; i++) { - format += strings[i]; - if (i < values.length) { - format += `{${i}}`; - } - } - - // Extract handles from values - const valueProviders = values.map(extractHandleForExpr); - - return new ReferenceExpression(format, valueProviders); - } - - /** - * Creates a conditional reference expression from its constituent parts. - * - * @param condition - A value provider whose result is compared to matchValue - * @param whenTrue - The expression to use when the condition matches - * @param whenFalse - The expression to use when the condition does not match - * @param matchValue - The value to compare the condition against (defaults to "True") - * @returns A ReferenceExpression instance in conditional mode - */ - static createConditional( - condition: unknown, - whenTrue: IReferenceExpression, - whenFalse: IReferenceExpression - ): IReferenceExpression; - static createConditional( - condition: unknown, - matchValue: string, - whenTrue: IReferenceExpression, - whenFalse: IReferenceExpression - ): IReferenceExpression; - static createConditional( - condition: unknown, - matchValueOrWhenTrue: string | IReferenceExpression, - whenTrueOrWhenFalse: IReferenceExpression, - whenFalse?: IReferenceExpression - ): IReferenceExpression { - if (typeof matchValueOrWhenTrue === 'string') { - return new ReferenceExpression(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); - } - - return new ReferenceExpression(condition, 'True', matchValueOrWhenTrue, whenTrueOrWhenFalse); - } - /** * Serializes the reference expression for JSON-RPC transport. * In expression mode, uses the $expr format with format + valueProviders. @@ -184,7 +134,7 @@ export class ReferenceExpression implements IReferenceExpression { * @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 | ICancellationToken): Promise { + async getValue(cancellationToken?: AbortSignal | CancellationToken): Promise { if (!this._handle || !this._client) { throw new Error('getValue is only available on server-returned ReferenceExpression instances'); } @@ -215,8 +165,51 @@ export class ReferenceExpression implements IReferenceExpression { } } +function createReferenceExpression(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { + let format = ''; + for (let i = 0; i < strings.length; i++) { + format += strings[i]; + if (i < values.length) { + format += `{${i}}`; + } + } + + const valueProviders = values.map(extractHandleForExpr); + + return new ReferenceExpressionImpl(format, valueProviders); +} + +function createConditionalReferenceExpression( + condition: unknown, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression +): ReferenceExpression; +function createConditionalReferenceExpression( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression +): ReferenceExpression; +function createConditionalReferenceExpression( + condition: unknown, + matchValueOrWhenTrue: string | ReferenceExpression, + whenTrueOrWhenFalse: ReferenceExpression, + whenFalse?: ReferenceExpression +): ReferenceExpression { + if (typeof matchValueOrWhenTrue === 'string') { + return new ReferenceExpressionImpl(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); + } + + return new ReferenceExpressionImpl(condition, 'True', matchValueOrWhenTrue, whenTrueOrWhenFalse); +} + +export const ReferenceExpression = { + create: createReferenceExpression, + createConditional: createConditionalReferenceExpression +}; + registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression', (handle, client) => - new ReferenceExpression(handle, client) + new ReferenceExpressionImpl(handle, client) ); /** @@ -281,7 +274,7 @@ function extractHandleForExpr(value: unknown): unknown { * await api.withEnvironment("REDIS_URL", expr); * ``` */ -export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { +export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { return ReferenceExpression.create(strings, ...values); } @@ -289,7 +282,7 @@ export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IR // ResourceBuilderBase // ============================================================================ -export interface IHandleReference { +export interface HandleReference { toJSON(): MarshalledHandle; } @@ -297,7 +290,7 @@ export interface IHandleReference { * Base class for resource builders (e.g., RedisBuilder, ContainerBuilder). * Provides handle management and JSON serialization. */ -export class ResourceBuilderBase implements IHandleReference { +export class ResourceBuilderBase implements HandleReference { constructor(protected _handle: THandle, protected _client: AspireClient) {} toJSON(): MarshalledHandle { return this._handle.toJSON(); } diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts index 7ee687fa852..a7089200192 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts @@ -104,7 +104,7 @@ function isAbortSignal(value: unknown): value is AbortSignal { ); } -function isCancellationTokenLike(value: unknown): value is ICancellationToken { +function isCancellationTokenLike(value: unknown): value is CancellationToken { return ( value !== null && typeof value === 'object' && @@ -216,12 +216,12 @@ export class Handle { * const connectionString = await connectionStringExpression.getValue(cancellationToken); * ``` */ -export interface ICancellationToken { +export interface CancellationToken { toJSON(): string | undefined; register(client?: AspireClient): string | undefined; } -export class CancellationToken implements ICancellationToken { +class CancellationTokenImpl implements CancellationToken { private readonly _signal?: AbortSignal; private readonly _remoteTokenId?: string; @@ -238,47 +238,49 @@ export class CancellationToken implements ICancellationToken { /** * Creates a cancellation token from a local {@link AbortSignal}. */ - static from(signal?: AbortSignal): CancellationToken { - return new CancellationToken(signal); + 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); + } +} + +/** + * Creates transport-safe cancellation token values for the generated SDK. + */ +export const CancellationToken = { + from(signal?: AbortSignal): CancellationToken { + return new CancellationTokenImpl(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): ICancellationToken { + fromValue(value: unknown): CancellationToken { if (isCancellationTokenLike(value)) { return value; } if (typeof value === 'string') { - return new CancellationToken(value); + return new CancellationTokenImpl(value); } if (isAbortSignal(value)) { - return new CancellationToken(value); + return new CancellationTokenImpl(value); } - return new CancellationToken(); + return new CancellationTokenImpl(); } - - /** - * 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 @@ -601,7 +603,7 @@ function isAspireClientLike(value: unknown): value is 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 */ -export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | ICancellationToken): string | undefined; +export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | CancellationToken): string | undefined; /** * Registers cancellation support using the single connected AspireClient. * @@ -618,15 +620,15 @@ export function registerCancellation(client: AspireClient, signalOrToken?: Abort * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signalOrToken?: AbortSignal | ICancellationToken): string | undefined; +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; export function registerCancellation( - clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, - maybeSignalOrToken?: AbortSignal | ICancellationToken + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken ): string | undefined { const client = isAspireClientLike(clientOrSignalOrToken) ? clientOrSignalOrToken : undefined; const signalOrToken = client ? maybeSignalOrToken - : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; if (!signalOrToken) { return undefined; diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs index dba9e709135..97d304a27f6 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs @@ -339,7 +339,7 @@ public void FactoryMethod_ReturnsChildResourceType_NotParentType() // Verify the thenable class also uses the child type's promise class. // In TestRedisResourcePromise, addTestChildDatabase should return TestDatabaseResourcePromise. - Assert.Contains("new TestDatabaseResourcePromise(this._promise.then(obj => obj.addTestChildDatabase(", aspireTs); + Assert.Contains("new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.addTestChildDatabase(", aspireTs); } [Fact] @@ -590,8 +590,8 @@ public void Pattern4_InterfaceParameterType_GeneratesUnionType() var files = _generator.GenerateDistributedApplication(atsContext); var aspireTs = files["aspire.ts"]; - Assert.Contains("export type { ICancellationToken, IHandleReference, IReferenceExpression } from './base.js';", aspireTs); - Assert.Contains("withDependency(dependency: IHandleReference)", aspireTs); + Assert.Contains("export type { HandleReference } from './base.js';", aspireTs); + Assert.Contains("withDependency(dependency: HandleReference)", aspireTs); Assert.DoesNotContain("withDependency(dependency: ResourceBuilderBase)", aspireTs); } @@ -1060,8 +1060,8 @@ public void Generate_TypeWithMethods_CreatesThenableWrapper() var code = GenerateTwoPassCode(); // TestResourceContext has ExposeMethods=true - gets Promise wrapper - Assert.Contains("export class TestResourceContextPromise", code); - Assert.Contains("implements PromiseLike", code); + Assert.Contains("class TestResourceContextPromiseImpl implements TestResourceContextPromise", code); + Assert.Contains("implements TestResourceContextPromise", code); } [Fact] @@ -1136,9 +1136,9 @@ public void Generate_MethodWithCancellationToken_GeneratesCancellationTokenParam // while callbacks and returned values use the structural SDK cancellation token interface. var code = GenerateTwoPassCode(); - Assert.Contains("cancellationToken?: AbortSignal | ICancellationToken;", code); - Assert.Contains("set: async (value: AbortSignal | ICancellationToken): Promise => {", code); - Assert.Contains("withCancellableOperation(operation: (arg: ICancellationToken) => Promise)", code); + Assert.Contains("cancellationToken?: AbortSignal | CancellationToken;", code); + Assert.Contains("set: async (value: AbortSignal | CancellationToken): Promise => {", code); + Assert.Contains("withCancellableOperation(operation: (arg: CancellationToken) => Promise)", code); } [Fact] @@ -1348,12 +1348,12 @@ public void Generate_ConcreteAndInterfaceWithSameClassName_NoDuplicateClasses() var files = _generator.GenerateDistributedApplication(atsContext); var code = files["aspire.ts"]; - // Count occurrences of the class definition - var classCount = CountOccurrences(code, "export class TestVaultResource "); + // Count occurrences of the public interface definition. + var classCount = CountOccurrences(code, "export interface TestVaultResource "); Assert.Equal(1, classCount); - // Also verify the Promise wrapper is not duplicated - var promiseCount = CountOccurrences(code, "export class TestVaultResourcePromise "); + // Also verify the Promise wrapper interface is not duplicated. + var promiseCount = CountOccurrences(code, "export interface TestVaultResourcePromise "); Assert.Equal(1, promiseCount); } diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts index b7597580326..8f9a1519a7a 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts @@ -16,11 +16,7 @@ import { registerHandleWrapper } from './transport.js'; -import type { - ICancellationToken, - IHandleReference, - IReferenceExpression -} from './base.js'; +import type { HandleReference } from './base.js'; import { ResourceBuilderBase, @@ -131,11 +127,11 @@ export interface AddTestRedisOptions { } export interface GetStatusAsyncOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface WaitForReadyAsyncOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface WithDataVolumeOptions { @@ -154,7 +150,7 @@ export interface WithMergeLoggingPathOptions { } export interface WithOptionalCallbackOptions { - callback?: (arg: ITestCallbackContext) => Promise; + callback?: (arg: TestCallbackContext) => Promise; } export interface WithOptionalStringOptions { @@ -167,10 +163,10 @@ export interface WithPersistenceOptions { } // ============================================================================ -// ITestCallbackContext +// TestCallbackContext // ============================================================================ -export interface ITestCallbackContext { +export interface TestCallbackContext { toJSON(): MarshalledHandle; name: { get: () => Promise; @@ -181,19 +177,19 @@ export interface ITestCallbackContext { set: (value: number) => Promise; }; cancellationToken: { - get: () => Promise; - set: (value: AbortSignal | ICancellationToken) => Promise; + get: () => Promise; + set: (value: AbortSignal | CancellationToken) => Promise; }; } // ============================================================================ -// TestCallbackContext +// TestCallbackContextImpl // ============================================================================ /** * Type class for TestCallbackContext. */ -export class TestCallbackContext { +class TestCallbackContextImpl implements TestCallbackContext { constructor(private _handle: TestCallbackContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -233,14 +229,14 @@ export class TestCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.cancellationToken', { context: this._handle } ); return CancellationToken.fromValue(result); }, - set: async (value: AbortSignal | ICancellationToken): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -251,23 +247,23 @@ export class TestCallbackContext { } // ============================================================================ -// ITestCollectionContext +// TestCollectionContext // ============================================================================ -export interface ITestCollectionContext { +export interface TestCollectionContext { toJSON(): MarshalledHandle; readonly items: AspireList; readonly metadata: AspireDict; } // ============================================================================ -// TestCollectionContext +// TestCollectionContextImpl // ============================================================================ /** * Type class for TestCollectionContext. */ -export class TestCollectionContext { +class TestCollectionContextImpl implements TestCollectionContext { constructor(private _handle: TestCollectionContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -304,10 +300,10 @@ export class TestCollectionContext { } // ============================================================================ -// ITestEnvironmentContext +// TestEnvironmentContext // ============================================================================ -export interface ITestEnvironmentContext { +export interface TestEnvironmentContext { toJSON(): MarshalledHandle; name: { get: () => Promise; @@ -324,13 +320,13 @@ export interface ITestEnvironmentContext { } // ============================================================================ -// TestEnvironmentContext +// TestEnvironmentContextImpl // ============================================================================ /** * Type class for TestEnvironmentContext. */ -export class TestEnvironmentContext { +class TestEnvironmentContextImpl implements TestEnvironmentContext { constructor(private _handle: TestEnvironmentContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -387,10 +383,10 @@ export class TestEnvironmentContext { } // ============================================================================ -// ITestResourceContext +// TestResourceContext // ============================================================================ -export interface ITestResourceContext { +export interface TestResourceContext { toJSON(): MarshalledHandle; name: { get: () => Promise; @@ -401,24 +397,24 @@ export interface ITestResourceContext { set: (value: number) => Promise; }; getValueAsync(): Promise; - setValueAsync(value: string): ITestResourceContextPromise; + setValueAsync(value: string): TestResourceContextPromise; validateAsync(): Promise; } -export interface ITestResourceContextPromise extends PromiseLike { +export interface TestResourceContextPromise extends PromiseLike { getValueAsync(): Promise; - setValueAsync(value: string): ITestResourceContextPromise; + setValueAsync(value: string): TestResourceContextPromise; validateAsync(): Promise; } // ============================================================================ -// TestResourceContext +// TestResourceContextImpl // ============================================================================ /** * Type class for TestResourceContext. */ -export class TestResourceContext { +class TestResourceContextImpl implements TestResourceContext { constructor(private _handle: TestResourceContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -477,7 +473,7 @@ export class TestResourceContext { } setValueAsync(value: string): TestResourceContextPromise { - return new TestResourceContextPromise(this._setValueAsyncInternal(value)); + return new TestResourceContextPromiseImpl(this._setValueAsyncInternal(value)); } /** Invokes the ValidateAsync method */ @@ -494,7 +490,7 @@ export class TestResourceContext { /** * Thenable wrapper for TestResourceContext that enables fluent chaining. */ -export class TestResourceContextPromise implements PromiseLike { +class TestResourceContextPromiseImpl implements TestResourceContextPromise { constructor(private _promise: Promise) {} then( @@ -511,7 +507,7 @@ export class TestResourceContextPromise implements PromiseLike obj.setValueAsync(value))); + return new TestResourceContextPromiseImpl(this._promise.then(obj => obj.setValueAsync(value))); } /** Invokes the ValidateAsync method */ @@ -522,28 +518,28 @@ export class TestResourceContextPromise implements PromiseLike { - addTestRedis(name: string, options?: AddTestRedisOptions): ITestRedisResourcePromise; - addTestVault(name: string): ITestVaultResourcePromise; +export interface DistributedApplicationBuilderPromise extends PromiseLike { + addTestRedis(name: string, options?: AddTestRedisOptions): TestRedisResourcePromise; + addTestVault(name: string): TestVaultResourcePromise; } // ============================================================================ -// DistributedApplicationBuilder +// DistributedApplicationBuilderImpl // ============================================================================ /** * Type class for DistributedApplicationBuilder. */ -export class DistributedApplicationBuilder { +class DistributedApplicationBuilderImpl implements DistributedApplicationBuilder { constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -558,12 +554,12 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/addTestRedis', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } addTestRedis(name: string, options?: AddTestRedisOptions): TestRedisResourcePromise { const port = options?.port; - return new TestRedisResourcePromise(this._addTestRedisInternal(name, port)); + return new TestRedisResourcePromiseImpl(this._addTestRedisInternal(name, port)); } /** Adds a test vault resource */ @@ -574,11 +570,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/addTestVault', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } addTestVault(name: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._addTestVaultInternal(name)); + return new TestVaultResourcePromiseImpl(this._addTestVaultInternal(name)); } } @@ -586,7 +582,7 @@ export class DistributedApplicationBuilder { /** * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { +class DistributedApplicationBuilderPromiseImpl implements DistributedApplicationBuilderPromise { constructor(private _promise: Promise) {} then( @@ -598,64 +594,80 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addTestRedis(name, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.addTestRedis(name, options))); } /** Adds a test vault resource */ addTestVault(name: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.addTestVault(name))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.addTestVault(name))); } } // ============================================================================ -// ITestDatabaseResource +// TestDatabaseResource // ============================================================================ -export interface ITestDatabaseResource { +export interface TestDatabaseResource { toJSON(): MarshalledHandle; - withOptionalString(options?: WithOptionalStringOptions): ITestDatabaseResourcePromise; - withConfig(config: TestConfigDto): ITestDatabaseResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestDatabaseResourcePromise; - withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; - withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; - withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; - withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; - withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; - testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; - withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; - withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; - withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ITestDatabaseResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestDatabaseResourcePromise; + withConfig(config: TestConfigDto): TestDatabaseResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise; + withCreatedAt(createdAt: string): TestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): TestDatabaseResourcePromise; + withCorrelationId(correlationId: string): TestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): TestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise; + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise; + withDependency(dependency: HandleReference): TestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): TestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): TestDatabaseResourcePromise; + withMergeLabel(label: string): TestDatabaseResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise; } -export interface ITestDatabaseResourcePromise extends PromiseLike { - withOptionalString(options?: WithOptionalStringOptions): ITestDatabaseResourcePromise; - withConfig(config: TestConfigDto): ITestDatabaseResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestDatabaseResourcePromise; - withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; - withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; - withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; - withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; - withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; - testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; - withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; - withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; - withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ITestDatabaseResourcePromise; +export interface TestDatabaseResourcePromise extends PromiseLike { + withOptionalString(options?: WithOptionalStringOptions): TestDatabaseResourcePromise; + withConfig(config: TestConfigDto): TestDatabaseResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise; + withCreatedAt(createdAt: string): TestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): TestDatabaseResourcePromise; + withCorrelationId(correlationId: string): TestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): TestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise; + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise; + withDependency(dependency: HandleReference): TestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): TestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): TestDatabaseResourcePromise; + withMergeLabel(label: string): TestDatabaseResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise; } // ============================================================================ -// TestDatabaseResource +// TestDatabaseResourceImpl // ============================================================================ -export class TestDatabaseResource extends ResourceBuilderBase { +class TestDatabaseResourceImpl extends ResourceBuilderBase implements TestDatabaseResource { constructor(handle: TestDatabaseResourceHandle, client: AspireClientRpc) { super(handle, client); } @@ -669,14 +681,14 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -706,12 +718,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -721,12 +733,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -772,13 +784,13 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -823,42 +835,42 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -868,12 +880,12 @@ export class TestDatabaseResource extends ResourceBuilderBase): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentVariablesInternal(variables)); + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -902,12 +914,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } /** @internal */ @@ -918,13 +930,13 @@ export class TestDatabaseResource extends ResourceBuilderBase { +class TestDatabaseResourcePromiseImpl implements TestDatabaseResourcePromise { constructor(private _promise: Promise) {} then( @@ -1074,196 +1086,212 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withOptionalString(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } /** Adds a data volume */ withDataVolume(options?: WithDataVolumeOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDataVolume(options))); } /** Adds a label to the resource */ withMergeLabel(label: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); } /** Adds a categorized label to the resource */ withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); } /** Configures a named endpoint */ withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); } /** Configures a named endpoint with scheme */ withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); } /** Configures resource logging */ withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); } /** Configures resource logging with file path */ withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); } /** Configures a route */ withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); } /** Configures a route with middleware */ withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// ITestRedisResource +// TestRedisResource // ============================================================================ -export interface ITestRedisResource { +export interface TestRedisResource { toJSON(): MarshalledHandle; - addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): ITestDatabaseResourcePromise; - withPersistence(options?: WithPersistenceOptions): ITestRedisResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestRedisResourcePromise; - withConfig(config: TestConfigDto): ITestRedisResourcePromise; + addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): TestDatabaseResourcePromise; + withPersistence(options?: WithPersistenceOptions): TestRedisResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestRedisResourcePromise; + withConfig(config: TestConfigDto): TestRedisResourcePromise; getTags(): Promise>; getMetadata(): Promise>; - withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withCreatedAt(createdAt: string): ITestRedisResourcePromise; - withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; - withCorrelationId(correlationId: string): ITestRedisResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; - withStatus(status: TestResourceStatus): ITestRedisResourcePromise; - withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; - testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withCreatedAt(createdAt: string): TestRedisResourcePromise; + withModifiedAt(modifiedAt: string): TestRedisResourcePromise; + withCorrelationId(correlationId: string): TestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestRedisResourcePromise; + withStatus(status: TestResourceStatus): TestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): TestRedisResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise; + testWaitFor(dependency: HandleReference): TestRedisResourcePromise; getEndpoints(): Promise; - withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; - withRedisSpecific(option: string): ITestRedisResourcePromise; - withDependency(dependency: IHandleReference): ITestRedisResourcePromise; - withEndpoints(endpoints: string[]): ITestRedisResourcePromise; - withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + withConnectionStringDirect(connectionString: string): TestRedisResourcePromise; + withRedisSpecific(option: string): TestRedisResourcePromise; + withDependency(dependency: HandleReference): TestRedisResourcePromise; + withEndpoints(endpoints: string[]): TestRedisResourcePromise; + withEnvironmentVariables(variables: Record): TestRedisResourcePromise; getStatusAsync(options?: GetStatusAsyncOptions): Promise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise; waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; - withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise; + withMergeLabel(label: string): TestRedisResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise; } -export interface ITestRedisResourcePromise extends PromiseLike { - addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): ITestDatabaseResourcePromise; - withPersistence(options?: WithPersistenceOptions): ITestRedisResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestRedisResourcePromise; - withConfig(config: TestConfigDto): ITestRedisResourcePromise; +export interface TestRedisResourcePromise extends PromiseLike { + addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): TestDatabaseResourcePromise; + withPersistence(options?: WithPersistenceOptions): TestRedisResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestRedisResourcePromise; + withConfig(config: TestConfigDto): TestRedisResourcePromise; getTags(): Promise>; getMetadata(): Promise>; - withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withCreatedAt(createdAt: string): ITestRedisResourcePromise; - withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; - withCorrelationId(correlationId: string): ITestRedisResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; - withStatus(status: TestResourceStatus): ITestRedisResourcePromise; - withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; - testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withCreatedAt(createdAt: string): TestRedisResourcePromise; + withModifiedAt(modifiedAt: string): TestRedisResourcePromise; + withCorrelationId(correlationId: string): TestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestRedisResourcePromise; + withStatus(status: TestResourceStatus): TestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): TestRedisResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise; + testWaitFor(dependency: HandleReference): TestRedisResourcePromise; getEndpoints(): Promise; - withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; - withRedisSpecific(option: string): ITestRedisResourcePromise; - withDependency(dependency: IHandleReference): ITestRedisResourcePromise; - withEndpoints(endpoints: string[]): ITestRedisResourcePromise; - withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + withConnectionStringDirect(connectionString: string): TestRedisResourcePromise; + withRedisSpecific(option: string): TestRedisResourcePromise; + withDependency(dependency: HandleReference): TestRedisResourcePromise; + withEndpoints(endpoints: string[]): TestRedisResourcePromise; + withEnvironmentVariables(variables: Record): TestRedisResourcePromise; getStatusAsync(options?: GetStatusAsyncOptions): Promise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise; waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; - withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise; + withMergeLabel(label: string): TestRedisResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise; } // ============================================================================ -// TestRedisResource +// TestRedisResourceImpl // ============================================================================ -export class TestRedisResource extends ResourceBuilderBase { +class TestRedisResourceImpl extends ResourceBuilderBase implements TestRedisResource { constructor(handle: TestRedisResourceHandle, client: AspireClientRpc) { super(handle, client); } @@ -1276,13 +1304,13 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withConnectionStringInternal(connectionString: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withConnectionStringInternal(connectionString)); + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withConnectionStringInternal(connectionString)); } /** @internal */ - private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -1381,12 +1409,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -1396,12 +1424,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -1447,13 +1475,13 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -1498,27 +1526,27 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** Gets the endpoints */ @@ -1537,12 +1565,12 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -1582,12 +1610,12 @@ export class TestRedisResource extends ResourceBuilderBase): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentVariablesInternal(variables)); + return new TestRedisResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); } /** Gets the status of the resource asynchronously */ @@ -1617,7 +1645,7 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -1627,12 +1655,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } /** Waits for the resource to be ready */ @@ -1647,12 +1675,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withMultiParamHandleCallbackInternal(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (arg1Data: unknown, arg2Data: unknown) => { const arg1Handle = wrapIfHandle(arg1Data) as TestCallbackContextHandle; - const arg1 = new TestCallbackContext(arg1Handle, this._client); + const arg1 = new TestCallbackContextImpl(arg1Handle, this._client); const arg2Handle = wrapIfHandle(arg2Data) as TestEnvironmentContextHandle; - const arg2 = new TestEnvironmentContext(arg2Handle, this._client); + const arg2 = new TestEnvironmentContextImpl(arg2Handle, this._client); await callback(arg1, arg2); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -1660,12 +1688,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMultiParamHandleCallbackInternal(callback)); + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMultiParamHandleCallbackInternal(callback)); } /** @internal */ @@ -1677,14 +1705,14 @@ export class TestRedisResource extends ResourceBuilderBase { +class TestRedisResourcePromiseImpl implements TestRedisResourcePromise { constructor(private _promise: Promise) {} then( @@ -1834,22 +1862,22 @@ export class TestRedisResourcePromise implements PromiseLike /** Adds a child database to a test Redis resource */ addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.addTestChildDatabase(name, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.addTestChildDatabase(name, options))); } /** Configures the Redis resource with persistence */ withPersistence(options?: WithPersistenceOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withPersistence(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withPersistence(options))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Gets the tags for the resource */ @@ -1863,53 +1891,53 @@ export class TestRedisResourcePromise implements PromiseLike } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionString(connectionString))); + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionString(connectionString))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Gets the endpoints */ @@ -1919,27 +1947,27 @@ export class TestRedisResourcePromise implements PromiseLike /** Sets connection string using direct interface target */ withConnectionStringDirect(connectionString: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); } /** Redis-specific configuration */ withRedisSpecific(option: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withRedisSpecific(option))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withRedisSpecific(option))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Gets the status of the resource asynchronously */ @@ -1948,8 +1976,8 @@ export class TestRedisResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } /** Waits for the resource to be ready */ @@ -1958,105 +1986,121 @@ export class TestRedisResourcePromise implements PromiseLike } /** Tests multi-param callback destructuring */ - withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMultiParamHandleCallback(callback))); + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMultiParamHandleCallback(callback))); } /** Adds a data volume with persistence */ withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withDataVolume(options))); } /** Adds a label to the resource */ withMergeLabel(label: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); } /** Adds a categorized label to the resource */ withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); } /** Configures a named endpoint */ withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); } /** Configures a named endpoint with scheme */ withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); } /** Configures resource logging */ withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); } /** Configures resource logging with file path */ withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); } /** Configures a route */ withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); } /** Configures a route with middleware */ withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// ITestVaultResource +// TestVaultResource // ============================================================================ -export interface ITestVaultResource { +export interface TestVaultResource { toJSON(): MarshalledHandle; - withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; - withConfig(config: TestConfigDto): ITestVaultResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; - withCreatedAt(createdAt: string): ITestVaultResourcePromise; - withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; - withCorrelationId(correlationId: string): ITestVaultResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; - withStatus(status: TestResourceStatus): ITestVaultResourcePromise; - withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; - testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; - withDependency(dependency: IHandleReference): ITestVaultResourcePromise; - withEndpoints(endpoints: string[]): ITestVaultResourcePromise; - withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; - withVaultDirect(option: string): ITestVaultResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestVaultResourcePromise; + withConfig(config: TestConfigDto): TestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise; + withCreatedAt(createdAt: string): TestVaultResourcePromise; + withModifiedAt(modifiedAt: string): TestVaultResourcePromise; + withCorrelationId(correlationId: string): TestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestVaultResourcePromise; + withStatus(status: TestResourceStatus): TestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): TestVaultResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise; + testWaitFor(dependency: HandleReference): TestVaultResourcePromise; + withDependency(dependency: HandleReference): TestVaultResourcePromise; + withEndpoints(endpoints: string[]): TestVaultResourcePromise; + withEnvironmentVariables(variables: Record): TestVaultResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise; + withVaultDirect(option: string): TestVaultResourcePromise; + withMergeLabel(label: string): TestVaultResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise; } -export interface ITestVaultResourcePromise extends PromiseLike { - withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; - withConfig(config: TestConfigDto): ITestVaultResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; - withCreatedAt(createdAt: string): ITestVaultResourcePromise; - withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; - withCorrelationId(correlationId: string): ITestVaultResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; - withStatus(status: TestResourceStatus): ITestVaultResourcePromise; - withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; - testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; - withDependency(dependency: IHandleReference): ITestVaultResourcePromise; - withEndpoints(endpoints: string[]): ITestVaultResourcePromise; - withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; - withVaultDirect(option: string): ITestVaultResourcePromise; +export interface TestVaultResourcePromise extends PromiseLike { + withOptionalString(options?: WithOptionalStringOptions): TestVaultResourcePromise; + withConfig(config: TestConfigDto): TestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise; + withCreatedAt(createdAt: string): TestVaultResourcePromise; + withModifiedAt(modifiedAt: string): TestVaultResourcePromise; + withCorrelationId(correlationId: string): TestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestVaultResourcePromise; + withStatus(status: TestResourceStatus): TestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): TestVaultResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise; + testWaitFor(dependency: HandleReference): TestVaultResourcePromise; + withDependency(dependency: HandleReference): TestVaultResourcePromise; + withEndpoints(endpoints: string[]): TestVaultResourcePromise; + withEnvironmentVariables(variables: Record): TestVaultResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise; + withVaultDirect(option: string): TestVaultResourcePromise; + withMergeLabel(label: string): TestVaultResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise; } // ============================================================================ -// TestVaultResource +// TestVaultResourceImpl // ============================================================================ -export class TestVaultResource extends ResourceBuilderBase { +class TestVaultResourceImpl extends ResourceBuilderBase implements TestVaultResource { constructor(handle: TestVaultResourceHandle, client: AspireClientRpc) { super(handle, client); } @@ -2070,14 +2114,14 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -2107,12 +2151,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -2122,12 +2166,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -2173,13 +2217,13 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -2224,42 +2268,42 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -2269,12 +2313,12 @@ export class TestVaultResource extends ResourceBuilderBase): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentVariablesInternal(variables)); + return new TestVaultResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -2303,12 +2347,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } /** @internal */ @@ -2318,12 +2362,12 @@ export class TestVaultResource extends ResourceBuilderBase { +class TestVaultResourcePromiseImpl implements TestVaultResourcePromise { constructor(private _promise: Promise) {} then( @@ -2473,168 +2517,184 @@ export class TestVaultResourcePromise implements PromiseLike /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } /** Configures vault using direct interface target */ withVaultDirect(option: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withVaultDirect(option))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withVaultDirect(option))); } /** Adds a label to the resource */ withMergeLabel(label: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); } /** Adds a categorized label to the resource */ withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); } /** Configures a named endpoint */ withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); } /** Configures a named endpoint with scheme */ withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); } /** Configures resource logging */ withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); } /** Configures resource logging with file path */ withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); } /** Configures a route */ withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); } /** Configures a route with middleware */ withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// IResource +// Resource // ============================================================================ -export interface IResource { +export interface Resource { toJSON(): MarshalledHandle; - withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; - withConfig(config: TestConfigDto): IResourcePromise; - withCreatedAt(createdAt: string): IResourcePromise; - withModifiedAt(modifiedAt: string): IResourcePromise; - withCorrelationId(correlationId: string): IResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; - withStatus(status: TestResourceStatus): IResourcePromise; - withNestedConfig(config: TestNestedDto): IResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; - testWaitFor(dependency: IHandleReference): IResourcePromise; - withDependency(dependency: IHandleReference): IResourcePromise; - withEndpoints(endpoints: string[]): IResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ResourcePromise; + withConfig(config: TestConfigDto): ResourcePromise; + withCreatedAt(createdAt: string): ResourcePromise; + withModifiedAt(modifiedAt: string): ResourcePromise; + withCorrelationId(correlationId: string): ResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise; + withStatus(status: TestResourceStatus): ResourcePromise; + withNestedConfig(config: TestNestedDto): ResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise; + testWaitFor(dependency: HandleReference): ResourcePromise; + withDependency(dependency: HandleReference): ResourcePromise; + withEndpoints(endpoints: string[]): ResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise; + withMergeLabel(label: string): ResourcePromise; + withMergeLabelCategorized(label: string, category: string): ResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise; } -export interface IResourcePromise extends PromiseLike { - withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; - withConfig(config: TestConfigDto): IResourcePromise; - withCreatedAt(createdAt: string): IResourcePromise; - withModifiedAt(modifiedAt: string): IResourcePromise; - withCorrelationId(correlationId: string): IResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; - withStatus(status: TestResourceStatus): IResourcePromise; - withNestedConfig(config: TestNestedDto): IResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; - testWaitFor(dependency: IHandleReference): IResourcePromise; - withDependency(dependency: IHandleReference): IResourcePromise; - withEndpoints(endpoints: string[]): IResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; +export interface ResourcePromise extends PromiseLike { + withOptionalString(options?: WithOptionalStringOptions): ResourcePromise; + withConfig(config: TestConfigDto): ResourcePromise; + withCreatedAt(createdAt: string): ResourcePromise; + withModifiedAt(modifiedAt: string): ResourcePromise; + withCorrelationId(correlationId: string): ResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise; + withStatus(status: TestResourceStatus): ResourcePromise; + withNestedConfig(config: TestNestedDto): ResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise; + testWaitFor(dependency: HandleReference): ResourcePromise; + withDependency(dependency: HandleReference): ResourcePromise; + withEndpoints(endpoints: string[]): ResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise; + withMergeLabel(label: string): ResourcePromise; + withMergeLabelCategorized(label: string, category: string): ResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise; } // ============================================================================ -// Resource +// ResourceImpl // ============================================================================ -export class Resource extends ResourceBuilderBase { +class ResourceImpl extends ResourceBuilderBase implements Resource { constructor(handle: IResourceHandle, client: AspireClientRpc) { super(handle, client); } @@ -2648,14 +2708,14 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalString', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ResourcePromise { const value = options?.value; const enabled = options?.enabled; - return new ResourcePromise(this._withOptionalStringInternal(value, enabled)); + return new ResourcePromiseImpl(this._withOptionalStringInternal(value, enabled)); } /** @internal */ @@ -2665,12 +2725,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConfig', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ResourcePromise { - return new ResourcePromise(this._withConfigInternal(config)); + return new ResourcePromiseImpl(this._withConfigInternal(config)); } /** @internal */ @@ -2680,12 +2740,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCreatedAt', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ResourcePromise { - return new ResourcePromise(this._withCreatedAtInternal(createdAt)); + return new ResourcePromiseImpl(this._withCreatedAtInternal(createdAt)); } /** @internal */ @@ -2695,12 +2755,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withModifiedAt', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ResourcePromise { - return new ResourcePromise(this._withModifiedAtInternal(modifiedAt)); + return new ResourcePromiseImpl(this._withModifiedAtInternal(modifiedAt)); } /** @internal */ @@ -2710,19 +2770,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCorrelationId', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ResourcePromise { - return new ResourcePromise(this._withCorrelationIdInternal(correlationId)); + return new ResourcePromiseImpl(this._withCorrelationIdInternal(correlationId)); } /** @internal */ - private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -2731,13 +2791,13 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalCallback', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise { const callback = options?.callback; - return new ResourcePromise(this._withOptionalCallbackInternal(callback)); + return new ResourcePromiseImpl(this._withOptionalCallbackInternal(callback)); } /** @internal */ @@ -2747,12 +2807,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ResourcePromise { - return new ResourcePromise(this._withStatusInternal(status)); + return new ResourcePromiseImpl(this._withStatusInternal(status)); } /** @internal */ @@ -2762,19 +2822,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ResourcePromise { - return new ResourcePromise(this._withNestedConfigInternal(config)); + return new ResourcePromiseImpl(this._withNestedConfigInternal(config)); } /** @internal */ - private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -2782,42 +2842,42 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -2827,16 +2887,16 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ResourcePromise { - return new ResourcePromise(this._withEndpointsInternal(endpoints)); + return new ResourcePromiseImpl(this._withEndpointsInternal(endpoints)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -2846,12 +2906,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { - return new ResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } /** @internal */ @@ -2861,12 +2921,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a label to the resource */ withMergeLabel(label: string): ResourcePromise { - return new ResourcePromise(this._withMergeLabelInternal(label)); + return new ResourcePromiseImpl(this._withMergeLabelInternal(label)); } /** @internal */ @@ -2876,12 +2936,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a categorized label to the resource */ withMergeLabelCategorized(label: string, category: string): ResourcePromise { - return new ResourcePromise(this._withMergeLabelCategorizedInternal(label, category)); + return new ResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); } /** @internal */ @@ -2891,12 +2951,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures a named endpoint */ withMergeEndpoint(endpointName: string, port: number): ResourcePromise { - return new ResourcePromise(this._withMergeEndpointInternal(endpointName, port)); + return new ResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); } /** @internal */ @@ -2906,12 +2966,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures a named endpoint with scheme */ withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise { - return new ResourcePromise(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + return new ResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); } /** @internal */ @@ -2923,14 +2983,14 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures resource logging */ withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise { const enableConsole = options?.enableConsole; const maxFiles = options?.maxFiles; - return new ResourcePromise(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + return new ResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); } /** @internal */ @@ -2942,14 +3002,14 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures resource logging with file path */ withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise { const enableConsole = options?.enableConsole; const maxFiles = options?.maxFiles; - return new ResourcePromise(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + return new ResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); } /** @internal */ @@ -2959,12 +3019,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures a route */ withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise { - return new ResourcePromise(this._withMergeRouteInternal(path, method, handler, priority)); + return new ResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); } /** @internal */ @@ -2974,12 +3034,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures a route with middleware */ withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise { - return new ResourcePromise(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); + return new ResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -2989,7 +3049,7 @@ export class Resource extends ResourceBuilderBase { * @example * await builder.addSomething().withX().withY(); */ -export class ResourcePromise implements PromiseLike { +class ResourcePromiseImpl implements ResourcePromise { constructor(private _promise: Promise) {} then( @@ -3001,148 +3061,148 @@ export class ResourcePromise implements PromiseLike { /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } /** Adds a label to the resource */ withMergeLabel(label: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLabel(label))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); } /** Adds a categorized label to the resource */ withMergeLabelCategorized(label: string, category: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); } /** Configures a named endpoint */ withMergeEndpoint(endpointName: string, port: number): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); } /** Configures a named endpoint with scheme */ withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); } /** Configures resource logging */ withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); } /** Configures resource logging with file path */ withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); } /** Configures a route */ withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); } /** Configures a route with middleware */ withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// IResourceWithConnectionString +// ResourceWithConnectionString // ============================================================================ -export interface IResourceWithConnectionString { +export interface ResourceWithConnectionString { toJSON(): MarshalledHandle; - withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): ResourceWithConnectionStringPromise; } -export interface IResourceWithConnectionStringPromise extends PromiseLike { - withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; +export interface ResourceWithConnectionStringPromise extends PromiseLike { + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): ResourceWithConnectionStringPromise; } // ============================================================================ -// ResourceWithConnectionString +// ResourceWithConnectionStringImpl // ============================================================================ -export class ResourceWithConnectionString extends ResourceBuilderBase { +class ResourceWithConnectionStringImpl extends ResourceBuilderBase implements ResourceWithConnectionString { constructor(handle: IResourceWithConnectionStringHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withConnectionStringInternal(connectionString: IReferenceExpression): Promise { + private async _withConnectionStringInternal(connectionString: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', rpcArgs ); - return new ResourceWithConnectionString(result, this._client); + return new ResourceWithConnectionStringImpl(result, this._client); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._withConnectionStringInternal(connectionString)); + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._withConnectionStringInternal(connectionString)); } /** @internal */ @@ -3152,12 +3212,12 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { +class ResourceWithConnectionStringPromiseImpl implements ResourceWithConnectionStringPromise { constructor(private _promise: Promise) {} then( @@ -3178,46 +3238,46 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionString(connectionString))); + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.withConnectionString(connectionString))); } /** Sets connection string using direct interface target */ withConnectionStringDirect(connectionString: string): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); } } // ============================================================================ -// IResourceWithEnvironment +// ResourceWithEnvironment // ============================================================================ -export interface IResourceWithEnvironment { +export interface ResourceWithEnvironment { toJSON(): MarshalledHandle; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): ResourceWithEnvironmentPromise; } -export interface IResourceWithEnvironmentPromise extends PromiseLike { - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; +export interface ResourceWithEnvironmentPromise extends PromiseLike { + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): ResourceWithEnvironmentPromise; } // ============================================================================ -// ResourceWithEnvironment +// ResourceWithEnvironmentImpl // ============================================================================ -export class ResourceWithEnvironment extends ResourceBuilderBase { +class ResourceWithEnvironmentImpl extends ResourceBuilderBase implements ResourceWithEnvironment { constructor(handle: IResourceWithEnvironmentHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -3225,12 +3285,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -3240,12 +3300,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentVariablesInternal(variables)); + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentVariablesInternal(variables)); } } @@ -3255,7 +3315,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { +class ResourceWithEnvironmentPromiseImpl implements ResourceWithEnvironmentPromise { constructor(private _promise: Promise) {} then( @@ -3266,13 +3326,13 @@ export class ResourceWithEnvironmentPromise implements PromiseLike Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } } @@ -3336,13 +3396,13 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCallbackContext', (handle, client) => new TestCallbackContext(handle as TestCallbackContextHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCollectionContext', (handle, client) => new TestCollectionContext(handle as TestCollectionContextHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestEnvironmentContext', (handle, client) => new TestEnvironmentContext(handle as TestEnvironmentContextHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestResourceContext', (handle, client) => new TestResourceContext(handle as TestResourceContextHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestDatabaseResource', (handle, client) => new TestDatabaseResource(handle as TestDatabaseResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestRedisResource', (handle, client) => new TestRedisResource(handle as TestRedisResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestVaultResource', (handle, client) => new TestVaultResource(handle as TestVaultResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new Resource(handle as IResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionString(handle as IResourceWithConnectionStringHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCallbackContext', (handle, client) => new TestCallbackContextImpl(handle as TestCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCollectionContext', (handle, client) => new TestCollectionContextImpl(handle as TestCollectionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestEnvironmentContext', (handle, client) => new TestEnvironmentContextImpl(handle as TestEnvironmentContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestResourceContext', (handle, client) => new TestResourceContextImpl(handle as TestResourceContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilderImpl(handle as IDistributedApplicationBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestDatabaseResource', (handle, client) => new TestDatabaseResourceImpl(handle as TestDatabaseResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestRedisResource', (handle, client) => new TestRedisResourceImpl(handle as TestRedisResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestVaultResource', (handle, client) => new TestVaultResourceImpl(handle as TestVaultResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new ResourceImpl(handle as IResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionStringImpl(handle as IResourceWithConnectionStringHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironmentImpl(handle as IResourceWithEnvironmentHandle, client)); diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts index 7ea68fe7bfc..831c140b8c3 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts @@ -1,4 +1,4 @@ -// aspire.ts - Capability-based Aspire SDK +// aspire.ts - Capability-based Aspire SDK // This SDK uses the ATS (Aspire Type System) capability API. // Capabilities are endpoints like 'Aspire.Hosting/createBuilder'. // @@ -16,11 +16,7 @@ import { registerHandleWrapper } from './transport.js'; -import type { - ICancellationToken, - IHandleReference, - IReferenceExpression -} from './base.js'; +import type { HandleReference } from './base.js'; import { ResourceBuilderBase, @@ -451,7 +447,7 @@ export interface AddContainerRegistryFromStringOptions { } export interface AddContainerRegistryOptions { - repository?: IParameterResource; + repository?: ParameterResource; } export interface AddDockerfileOptions { @@ -490,43 +486,43 @@ export interface AppendValueProviderOptions { export interface CompleteStepMarkdownOptions { completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface CompleteStepOptions { completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface CompleteTaskMarkdownOptions { completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface CompleteTaskOptions { completionMessage?: string; completionState?: string; - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface CreateMarkdownTaskOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface CreateTaskOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface GetStatusAsyncOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface PublishAsDockerFileOptions { - configure?: (obj: IContainerResource) => Promise; + configure?: (obj: ContainerResource) => Promise; } export interface PublishResourceUpdateOptions { @@ -535,19 +531,19 @@ export interface PublishResourceUpdateOptions { } export interface RunOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface SaveStateJsonOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface UpdateTaskMarkdownOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface UpdateTaskOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface WaitForCompletionOptions { @@ -555,7 +551,7 @@ export interface WaitForCompletionOptions { } export interface WaitForReadyAsyncOptions { - cancellationToken?: AbortSignal | ICancellationToken; + cancellationToken?: AbortSignal | CancellationToken; } export interface WaitForResourceStateOptions { @@ -630,7 +626,7 @@ export interface WithHttpProbeOptions { } export interface WithHttpsDeveloperCertificateOptions { - password?: IParameterResource; + password?: ParameterResource; } export interface WithHttpsEndpointOptions { @@ -654,8 +650,18 @@ export interface WithMcpServerOptions { endpointName?: string; } +export interface WithMergeLoggingOptions { + enableConsole?: boolean; + maxFiles?: number; +} + +export interface WithMergeLoggingPathOptions { + enableConsole?: boolean; + maxFiles?: number; +} + export interface WithOptionalCallbackOptions { - callback?: (arg: ITestCallbackContext) => Promise; + callback?: (arg: TestCallbackContext) => Promise; } export interface WithOptionalStringOptions { @@ -698,27 +704,27 @@ export interface WithVolumeOptions { } // ============================================================================ -// IAfterResourcesCreatedEvent +// AfterResourcesCreatedEvent // ============================================================================ -export interface IAfterResourcesCreatedEvent { +export interface AfterResourcesCreatedEvent { toJSON(): MarshalledHandle; services: { - get: () => Promise; + get: () => Promise; }; model: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// AfterResourcesCreatedEvent +// AfterResourcesCreatedEventImpl // ============================================================================ /** * Type class for AfterResourcesCreatedEvent. */ -export class AfterResourcesCreatedEvent { +class AfterResourcesCreatedEventImpl implements AfterResourcesCreatedEvent { constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -731,7 +737,7 @@ export class AfterResourcesCreatedEvent { 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; @@ -742,34 +748,34 @@ export class AfterResourcesCreatedEvent { 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', { context: this._handle } ); - return new DistributedApplicationModel(handle, this._client); + return new DistributedApplicationModelImpl(handle, this._client); }, }; } // ============================================================================ -// IBeforeResourceStartedEvent +// BeforeResourceStartedEvent // ============================================================================ -export interface IBeforeResourceStartedEvent { +export interface BeforeResourceStartedEvent { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// BeforeResourceStartedEvent +// BeforeResourceStartedEventImpl // ============================================================================ /** * Type class for BeforeResourceStartedEvent. */ -export class BeforeResourceStartedEvent { +class BeforeResourceStartedEventImpl implements BeforeResourceStartedEvent { constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -782,7 +788,7 @@ export class BeforeResourceStartedEvent { 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -793,34 +799,34 @@ export class BeforeResourceStartedEvent { 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; } // ============================================================================ -// IBeforeStartEvent +// BeforeStartEvent // ============================================================================ -export interface IBeforeStartEvent { +export interface BeforeStartEvent { toJSON(): MarshalledHandle; services: { - get: () => Promise; + get: () => Promise; }; model: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// BeforeStartEvent +// BeforeStartEventImpl // ============================================================================ /** * Type class for BeforeStartEvent. */ -export class BeforeStartEvent { +class BeforeStartEventImpl implements BeforeStartEvent { constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -833,7 +839,7 @@ export class BeforeStartEvent { 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; @@ -844,43 +850,43 @@ export class BeforeStartEvent { 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', { context: this._handle } ); - return new DistributedApplicationModel(handle, this._client); + return new DistributedApplicationModelImpl(handle, this._client); }, }; } // ============================================================================ -// ICommandLineArgsCallbackContext +// CommandLineArgsCallbackContext // ============================================================================ -export interface ICommandLineArgsCallbackContext { +export interface CommandLineArgsCallbackContext { toJSON(): MarshalledHandle; readonly args: AspireList; cancellationToken: { - get: () => Promise; + get: () => Promise; }; executionContext: { - get: () => Promise; - set: (value: IDistributedApplicationExecutionContext) => Promise; + get: () => Promise; + set: (value: DistributedApplicationExecutionContext) => Promise; }; logger: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; resource: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// CommandLineArgsCallbackContext +// CommandLineArgsCallbackContextImpl // ============================================================================ /** * Type class for CommandLineArgsCallbackContext. */ -export class CommandLineArgsCallbackContext { +class CommandLineArgsCallbackContextImpl implements CommandLineArgsCallbackContext { constructor(private _handle: CommandLineArgsCallbackContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -902,7 +908,7 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } @@ -918,9 +924,9 @@ export class CommandLineArgsCallbackContext { 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.executionContext', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new DistributedApplicationExecutionContextImpl(handle, this._client); }, - set: async (value: IDistributedApplicationExecutionContext): Promise => { + set: async (value: DistributedApplicationExecutionContext): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setExecutionContext', { context: this._handle, value } @@ -935,9 +941,9 @@ export class CommandLineArgsCallbackContext { 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', { context: this._handle } ); - return new Logger(handle, this._client); + return new LoggerImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.setLogger', { context: this._handle, value } @@ -952,34 +958,34 @@ export class CommandLineArgsCallbackContext { 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; } // ============================================================================ -// IConnectionStringAvailableEvent +// ConnectionStringAvailableEvent // ============================================================================ -export interface IConnectionStringAvailableEvent { +export interface ConnectionStringAvailableEvent { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// ConnectionStringAvailableEvent +// ConnectionStringAvailableEventImpl // ============================================================================ /** * Type class for ConnectionStringAvailableEvent. */ -export class ConnectionStringAvailableEvent { +class ConnectionStringAvailableEventImpl implements ConnectionStringAvailableEvent { constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -992,7 +998,7 @@ export class ConnectionStringAvailableEvent { 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -1003,33 +1009,33 @@ export class ConnectionStringAvailableEvent { 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; } // ============================================================================ -// IDistributedApplication +// DistributedApplication // ============================================================================ -export interface IDistributedApplication { +export interface DistributedApplication { toJSON(): MarshalledHandle; - run(options?: RunOptions): IDistributedApplicationPromise; + run(options?: RunOptions): DistributedApplicationPromise; } -export interface IDistributedApplicationPromise extends PromiseLike { - run(options?: RunOptions): IDistributedApplicationPromise; +export interface DistributedApplicationPromise extends PromiseLike { + run(options?: RunOptions): DistributedApplicationPromise; } // ============================================================================ -// DistributedApplication +// DistributedApplicationImpl // ============================================================================ /** * Type class for DistributedApplication. */ -export class DistributedApplication { +class DistributedApplicationImpl implements DistributedApplication { constructor(private _handle: DistributedApplicationHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -1037,7 +1043,7 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal | ICancellationToken): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( @@ -1049,7 +1055,7 @@ export class DistributedApplication { run(options?: RunOptions): DistributedApplicationPromise { const cancellationToken = options?.cancellationToken; - return new DistributedApplicationPromise(this._runInternal(cancellationToken)); + return new DistributedApplicationPromiseImpl(this._runInternal(cancellationToken)); } } @@ -1057,7 +1063,7 @@ export class DistributedApplication { /** * Thenable wrapper for DistributedApplication that enables fluent chaining. */ -export class DistributedApplicationPromise implements PromiseLike { +class DistributedApplicationPromiseImpl implements DistributedApplicationPromise { constructor(private _promise: Promise) {} then( @@ -1069,16 +1075,16 @@ export class DistributedApplicationPromise implements PromiseLike obj.run(options))); + return new DistributedApplicationPromiseImpl(this._promise.then(obj => obj.run(options))); } } // ============================================================================ -// IDistributedApplicationExecutionContext +// DistributedApplicationExecutionContext // ============================================================================ -export interface IDistributedApplicationExecutionContext { +export interface DistributedApplicationExecutionContext { toJSON(): MarshalledHandle; publisherName: { get: () => Promise; @@ -1088,7 +1094,7 @@ export interface IDistributedApplicationExecutionContext { get: () => Promise; }; serviceProvider: { - get: () => Promise; + get: () => Promise; }; isPublishMode: { get: () => Promise; @@ -1099,13 +1105,13 @@ export interface IDistributedApplicationExecutionContext { } // ============================================================================ -// DistributedApplicationExecutionContext +// DistributedApplicationExecutionContextImpl // ============================================================================ /** * Type class for DistributedApplicationExecutionContext. */ -export class DistributedApplicationExecutionContext { +class DistributedApplicationExecutionContextImpl implements DistributedApplicationExecutionContext { constructor(private _handle: DistributedApplicationExecutionContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -1144,7 +1150,7 @@ export class DistributedApplicationExecutionContext { 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; @@ -1171,37 +1177,37 @@ export class DistributedApplicationExecutionContext { } // ============================================================================ -// IDistributedApplicationModel +// DistributedApplicationModel // ============================================================================ -export interface IDistributedApplicationModel { +export interface DistributedApplicationModel { toJSON(): MarshalledHandle; - getResources(): Promise; - findResourceByName(name: string): IResourcePromise; + getResources(): Promise; + findResourceByName(name: string): ResourcePromise; } -export interface IDistributedApplicationModelPromise extends PromiseLike { - getResources(): Promise; - findResourceByName(name: string): IResourcePromise; +export interface DistributedApplicationModelPromise extends PromiseLike { + getResources(): Promise; + findResourceByName(name: string): ResourcePromise; } // ============================================================================ -// DistributedApplicationModel +// DistributedApplicationModelImpl // ============================================================================ /** * Type class for DistributedApplicationModel. */ -export class DistributedApplicationModel { +class DistributedApplicationModelImpl implements 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 { + async getResources(): Promise { const rpcArgs: Record = { model: this._handle }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getResources', rpcArgs ); @@ -1215,11 +1221,11 @@ export class DistributedApplicationModel { 'Aspire.Hosting/findResourceByName', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } findResourceByName(name: string): ResourcePromise { - return new ResourcePromise(this._findResourceByNameInternal(name)); + return new ResourcePromiseImpl(this._findResourceByNameInternal(name)); } } @@ -1227,7 +1233,7 @@ export class DistributedApplicationModel { /** * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. */ -export class DistributedApplicationModelPromise implements PromiseLike { +class DistributedApplicationModelPromiseImpl implements DistributedApplicationModelPromise { constructor(private _promise: Promise) {} then( @@ -1238,25 +1244,25 @@ export class DistributedApplicationModelPromise implements PromiseLike { + 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))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.findResourceByName(name))); } } // ============================================================================ -// IEndpointReference +// EndpointReference // ============================================================================ -export interface IEndpointReference { +export interface EndpointReference { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; endpointName: { get: () => Promise; @@ -1280,6 +1286,9 @@ export interface IEndpointReference { tlsEnabled: { get: () => Promise; }; + excludeReferenceEndpoint: { + get: () => Promise; + }; port: { get: () => Promise; }; @@ -1296,22 +1305,22 @@ export interface IEndpointReference { get: () => Promise; }; getValueAsync(options?: GetValueAsyncOptions): Promise; - getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; + getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise; } -export interface IEndpointReferencePromise extends PromiseLike { +export interface EndpointReferencePromise extends PromiseLike { getValueAsync(options?: GetValueAsyncOptions): Promise; - getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise; + getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise; } // ============================================================================ -// EndpointReference +// EndpointReferenceImpl // ============================================================================ /** * Type class for EndpointReference. */ -export class EndpointReference { +class EndpointReferenceImpl implements EndpointReference { constructor(private _handle: EndpointReferenceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -1324,7 +1333,7 @@ export class EndpointReference { 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', { context: this._handle } ); - return new ResourceWithEndpoints(handle, this._client); + return new ResourceWithEndpointsImpl(handle, this._client); }, }; @@ -1404,6 +1413,16 @@ export class EndpointReference { }, }; + /** Gets the ExcludeReferenceEndpoint property */ + excludeReferenceEndpoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { @@ -1466,9 +1485,9 @@ export class EndpointReference { } /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ - async getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { + async getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise { const rpcArgs: Record = { context: this._handle, enabledValue, disabledValue }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EndpointReference.getTlsValue', rpcArgs ); @@ -1479,7 +1498,7 @@ export class EndpointReference { /** * Thenable wrapper for EndpointReference that enables fluent chaining. */ -export class EndpointReferencePromise implements PromiseLike { +class EndpointReferencePromiseImpl implements EndpointReferencePromise { constructor(private _promise: Promise) {} then( @@ -1495,20 +1514,20 @@ export class EndpointReferencePromise implements PromiseLike } /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ - getTlsValue(enabledValue: IReferenceExpression, disabledValue: IReferenceExpression): Promise { + getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): Promise { return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); } } // ============================================================================ -// IEndpointReferenceExpression +// EndpointReferenceExpression // ============================================================================ -export interface IEndpointReferenceExpression { +export interface EndpointReferenceExpression { toJSON(): MarshalledHandle; endpoint: { - get: () => Promise; + get: () => Promise; }; property: { get: () => Promise; @@ -1519,13 +1538,13 @@ export interface IEndpointReferenceExpression { } // ============================================================================ -// EndpointReferenceExpression +// EndpointReferenceExpressionImpl // ============================================================================ /** * Type class for EndpointReferenceExpression. */ -export class EndpointReferenceExpression { +class EndpointReferenceExpressionImpl implements EndpointReferenceExpression { constructor(private _handle: EndpointReferenceExpressionHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -1538,7 +1557,7 @@ export class EndpointReferenceExpression { 'Aspire.Hosting.ApplicationModel/EndpointReferenceExpression.endpoint', { context: this._handle } ); - return new EndpointReference(handle, this._client); + return new EndpointReferenceImpl(handle, this._client); }, }; @@ -1565,45 +1584,45 @@ export class EndpointReferenceExpression { } // ============================================================================ -// IEnvironmentCallbackContext +// EnvironmentCallbackContext // ============================================================================ -export interface IEnvironmentCallbackContext { +export interface EnvironmentCallbackContext { toJSON(): MarshalledHandle; - readonly environmentVariables: AspireDict; + readonly environmentVariables: AspireDict; cancellationToken: { - get: () => Promise; + get: () => Promise; }; logger: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; resource: { - get: () => Promise; + get: () => Promise; }; executionContext: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// EnvironmentCallbackContext +// EnvironmentCallbackContextImpl // ============================================================================ /** * Type class for EnvironmentCallbackContext. */ -export class EnvironmentCallbackContext { +class EnvironmentCallbackContextImpl implements EnvironmentCallbackContext { constructor(private _handle: EnvironmentCallbackContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } /** Gets the EnvironmentVariables property */ - private _environmentVariables?: AspireDict; - get environmentVariables(): AspireDict { + private _environmentVariables?: AspireDict; + get environmentVariables(): AspireDict { if (!this._environmentVariables) { - this._environmentVariables = new AspireDict( + this._environmentVariables = new AspireDict( this._handle, this._client, 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.environmentVariables', @@ -1615,7 +1634,7 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } @@ -1631,9 +1650,9 @@ export class EnvironmentCallbackContext { 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', { context: this._handle } ); - return new Logger(handle, this._client); + return new LoggerImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.setLogger', { context: this._handle, value } @@ -1648,7 +1667,7 @@ export class EnvironmentCallbackContext { 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -1659,40 +1678,40 @@ export class EnvironmentCallbackContext { 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.executionContext', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new DistributedApplicationExecutionContextImpl(handle, this._client); }, }; } // ============================================================================ -// IExecuteCommandContext +// ExecuteCommandContext // ============================================================================ -export interface IExecuteCommandContext { +export interface ExecuteCommandContext { toJSON(): MarshalledHandle; serviceProvider: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; resourceName: { get: () => Promise; set: (value: string) => Promise; }; cancellationToken: { - get: () => Promise; - set: (value: AbortSignal | ICancellationToken) => Promise; + get: () => Promise; + set: (value: AbortSignal | CancellationToken) => Promise; }; } // ============================================================================ -// ExecuteCommandContext +// ExecuteCommandContextImpl // ============================================================================ /** * Type class for ExecuteCommandContext. */ -export class ExecuteCommandContext { +class ExecuteCommandContextImpl implements ExecuteCommandContext { constructor(private _handle: ExecuteCommandContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -1705,9 +1724,9 @@ export class ExecuteCommandContext { 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setServiceProvider', { context: this._handle, value } @@ -1733,14 +1752,14 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + 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 | ICancellationToken): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -1751,36 +1770,36 @@ export class ExecuteCommandContext { } // ============================================================================ -// IInitializeResourceEvent +// InitializeResourceEvent // ============================================================================ -export interface IInitializeResourceEvent { +export interface InitializeResourceEvent { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; eventing: { - get: () => Promise; + get: () => Promise; }; logger: { - get: () => Promise; + get: () => Promise; }; notifications: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// InitializeResourceEvent +// InitializeResourceEventImpl // ============================================================================ /** * Type class for InitializeResourceEvent. */ -export class InitializeResourceEvent { +class InitializeResourceEventImpl implements InitializeResourceEvent { constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -1793,7 +1812,7 @@ export class InitializeResourceEvent { 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -1804,7 +1823,7 @@ export class InitializeResourceEvent { 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); + return new DistributedApplicationEventingImpl(handle, this._client); }, }; @@ -1815,7 +1834,7 @@ export class InitializeResourceEvent { 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', { context: this._handle } ); - return new Logger(handle, this._client); + return new LoggerImpl(handle, this._client); }, }; @@ -1826,7 +1845,7 @@ export class InitializeResourceEvent { 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', { context: this._handle } ); - return new ResourceNotificationService(handle, this._client); + return new ResourceNotificationServiceImpl(handle, this._client); }, }; @@ -1837,45 +1856,45 @@ export class InitializeResourceEvent { 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; } // ============================================================================ -// IPipelineConfigurationContext +// PipelineConfigurationContext // ============================================================================ -export interface IPipelineConfigurationContext { +export interface PipelineConfigurationContext { toJSON(): MarshalledHandle; services: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; steps: { - get: () => Promise; - set: (value: IPipelineStep[]) => Promise; + get: () => Promise; + set: (value: PipelineStep[]) => Promise; }; model: { - get: () => Promise; - set: (value: IDistributedApplicationModel) => Promise; + get: () => Promise; + set: (value: DistributedApplicationModel) => Promise; }; - getStepsByTag(tag: string): Promise; + getStepsByTag(tag: string): Promise; } -export interface IPipelineConfigurationContextPromise extends PromiseLike { - getStepsByTag(tag: string): Promise; +export interface PipelineConfigurationContextPromise extends PromiseLike { + getStepsByTag(tag: string): Promise; } // ============================================================================ -// PipelineConfigurationContext +// PipelineConfigurationContextImpl // ============================================================================ /** * Type class for PipelineConfigurationContext. */ -export class PipelineConfigurationContext { +class PipelineConfigurationContextImpl implements PipelineConfigurationContext { constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -1888,9 +1907,9 @@ export class PipelineConfigurationContext { 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setServices', { context: this._handle, value } @@ -1900,13 +1919,13 @@ export class PipelineConfigurationContext { /** Gets the Steps property */ steps = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + return await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', { context: this._handle } ); }, - set: async (value: IPipelineStep[]): Promise => { + set: async (value: PipelineStep[]): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', { context: this._handle, value } @@ -1921,9 +1940,9 @@ export class PipelineConfigurationContext { 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', { context: this._handle } ); - return new DistributedApplicationModel(handle, this._client); + return new DistributedApplicationModelImpl(handle, this._client); }, - set: async (value: IDistributedApplicationModel): Promise => { + set: async (value: DistributedApplicationModel): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setModel', { context: this._handle, value } @@ -1932,9 +1951,9 @@ export class PipelineConfigurationContext { }; /** Gets pipeline steps with the specified tag */ - async getStepsByTag(tag: string): Promise { + async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/getStepsByTag', rpcArgs ); @@ -1945,7 +1964,7 @@ export class PipelineConfigurationContext { /** * Thenable wrapper for PipelineConfigurationContext that enables fluent chaining. */ -export class PipelineConfigurationContextPromise implements PromiseLike { +class PipelineConfigurationContextPromiseImpl implements PipelineConfigurationContextPromise { constructor(private _promise: Promise) {} then( @@ -1956,47 +1975,47 @@ export class PipelineConfigurationContextPromise implements PromiseLike { + getStepsByTag(tag: string): Promise { return this._promise.then(obj => obj.getStepsByTag(tag)); } } // ============================================================================ -// IPipelineContext +// PipelineContext // ============================================================================ -export interface IPipelineContext { +export interface PipelineContext { toJSON(): MarshalledHandle; model: { - get: () => Promise; + get: () => Promise; }; executionContext: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; logger: { - get: () => Promise; + get: () => Promise; }; cancellationToken: { - get: () => Promise; - set: (value: AbortSignal | ICancellationToken) => Promise; + get: () => Promise; + set: (value: AbortSignal | CancellationToken) => Promise; }; summary: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// PipelineContext +// PipelineContextImpl // ============================================================================ /** * Type class for PipelineContext. */ -export class PipelineContext { +class PipelineContextImpl implements PipelineContext { constructor(private _handle: PipelineContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2009,7 +2028,7 @@ export class PipelineContext { 'Aspire.Hosting.Pipelines/PipelineContext.model', { context: this._handle } ); - return new DistributedApplicationModel(handle, this._client); + return new DistributedApplicationModelImpl(handle, this._client); }, }; @@ -2020,7 +2039,7 @@ export class PipelineContext { 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new DistributedApplicationExecutionContextImpl(handle, this._client); }, }; @@ -2031,7 +2050,7 @@ export class PipelineContext { 'Aspire.Hosting.Pipelines/PipelineContext.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; @@ -2042,20 +2061,20 @@ export class PipelineContext { 'Aspire.Hosting.Pipelines/PipelineContext.logger', { context: this._handle } ); - return new Logger(handle, this._client); + return new LoggerImpl(handle, this._client); }, }; /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + 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 | ICancellationToken): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -2070,17 +2089,17 @@ export class PipelineContext { 'Aspire.Hosting.Pipelines/PipelineContext.summary', { context: this._handle } ); - return new PipelineSummary(handle, this._client); + return new PipelineSummaryImpl(handle, this._client); }, }; } // ============================================================================ -// IPipelineStep +// PipelineStep // ============================================================================ -export interface IPipelineStep { +export interface PipelineStep { toJSON(): MarshalledHandle; name: { get: () => Promise; @@ -2094,26 +2113,26 @@ export interface IPipelineStep { readonly requiredBySteps: AspireList; readonly tags: AspireList; resource: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; - dependsOn(stepName: string): IPipelineStepPromise; - requiredBy(stepName: string): IPipelineStepPromise; + dependsOn(stepName: string): PipelineStepPromise; + requiredBy(stepName: string): PipelineStepPromise; } -export interface IPipelineStepPromise extends PromiseLike { - dependsOn(stepName: string): IPipelineStepPromise; - requiredBy(stepName: string): IPipelineStepPromise; +export interface PipelineStepPromise extends PromiseLike { + dependsOn(stepName: string): PipelineStepPromise; + requiredBy(stepName: string): PipelineStepPromise; } // ============================================================================ -// PipelineStep +// PipelineStepImpl // ============================================================================ /** * Type class for PipelineStep. */ -export class PipelineStep { +class PipelineStepImpl implements PipelineStep { constructor(private _handle: PipelineStepHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2200,9 +2219,9 @@ export class PipelineStep { 'Aspire.Hosting.Pipelines/PipelineStep.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStep.setResource', { context: this._handle, value } @@ -2222,7 +2241,7 @@ export class PipelineStep { } dependsOn(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._dependsOnInternal(stepName)); + return new PipelineStepPromiseImpl(this._dependsOnInternal(stepName)); } /** Specifies that another step requires this step by name */ @@ -2237,7 +2256,7 @@ export class PipelineStep { } requiredBy(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._requiredByInternal(stepName)); + return new PipelineStepPromiseImpl(this._requiredByInternal(stepName)); } } @@ -2245,7 +2264,7 @@ export class PipelineStep { /** * Thenable wrapper for PipelineStep that enables fluent chaining. */ -export class PipelineStepPromise implements PromiseLike { +class PipelineStepPromiseImpl implements PipelineStepPromise { constructor(private _promise: Promise) {} then( @@ -2257,58 +2276,58 @@ export class PipelineStepPromise implements PromiseLike { /** Adds a dependency on another step by name */ dependsOn(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._promise.then(obj => obj.dependsOn(stepName))); + return new PipelineStepPromiseImpl(this._promise.then(obj => obj.dependsOn(stepName))); } /** Specifies that another step requires this step by name */ requiredBy(stepName: string): PipelineStepPromise { - return new PipelineStepPromise(this._promise.then(obj => obj.requiredBy(stepName))); + return new PipelineStepPromiseImpl(this._promise.then(obj => obj.requiredBy(stepName))); } } // ============================================================================ -// IPipelineStepContext +// PipelineStepContext // ============================================================================ -export interface IPipelineStepContext { +export interface PipelineStepContext { toJSON(): MarshalledHandle; pipelineContext: { - get: () => Promise; - set: (value: IPipelineContext) => Promise; + get: () => Promise; + set: (value: PipelineContext) => Promise; }; reportingStep: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; model: { - get: () => Promise; + get: () => Promise; }; executionContext: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; logger: { - get: () => Promise; + get: () => Promise; }; cancellationToken: { - get: () => Promise; + get: () => Promise; }; summary: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// PipelineStepContext +// PipelineStepContextImpl // ============================================================================ /** * Type class for PipelineStepContext. */ -export class PipelineStepContext { +class PipelineStepContextImpl implements PipelineStepContext { constructor(private _handle: PipelineStepContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2321,9 +2340,9 @@ export class PipelineStepContext { 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', { context: this._handle } ); - return new PipelineContext(handle, this._client); + return new PipelineContextImpl(handle, this._client); }, - set: async (value: IPipelineContext): Promise => { + set: async (value: PipelineContext): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.setPipelineContext', { context: this._handle, value } @@ -2338,9 +2357,9 @@ export class PipelineStepContext { 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', { context: this._handle } ); - return new ReportingStep(handle, this._client); + return new ReportingStepImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.setReportingStep', { context: this._handle, value } @@ -2355,7 +2374,7 @@ export class PipelineStepContext { 'Aspire.Hosting.Pipelines/PipelineStepContext.model', { context: this._handle } ); - return new DistributedApplicationModel(handle, this._client); + return new DistributedApplicationModelImpl(handle, this._client); }, }; @@ -2366,7 +2385,7 @@ export class PipelineStepContext { 'Aspire.Hosting.Pipelines/PipelineStepContext.executionContext', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new DistributedApplicationExecutionContextImpl(handle, this._client); }, }; @@ -2377,7 +2396,7 @@ export class PipelineStepContext { 'Aspire.Hosting.Pipelines/PipelineStepContext.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; @@ -2388,13 +2407,13 @@ export class PipelineStepContext { 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', { context: this._handle } ); - return new Logger(handle, this._client); + return new LoggerImpl(handle, this._client); }, }; /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } @@ -2410,36 +2429,36 @@ export class PipelineStepContext { 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', { context: this._handle } ); - return new PipelineSummary(handle, this._client); + return new PipelineSummaryImpl(handle, this._client); }, }; } // ============================================================================ -// IPipelineStepFactoryContext +// PipelineStepFactoryContext // ============================================================================ -export interface IPipelineStepFactoryContext { +export interface PipelineStepFactoryContext { toJSON(): MarshalledHandle; pipelineContext: { - get: () => Promise; - set: (value: IPipelineContext) => Promise; + get: () => Promise; + set: (value: PipelineContext) => Promise; }; resource: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; } // ============================================================================ -// PipelineStepFactoryContext +// PipelineStepFactoryContextImpl // ============================================================================ /** * Type class for PipelineStepFactoryContext. */ -export class PipelineStepFactoryContext { +class PipelineStepFactoryContextImpl implements PipelineStepFactoryContext { constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2452,9 +2471,9 @@ export class PipelineStepFactoryContext { 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', { context: this._handle } ); - return new PipelineContext(handle, this._client); + return new PipelineContextImpl(handle, this._client); }, - set: async (value: IPipelineContext): Promise => { + set: async (value: PipelineContext): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setPipelineContext', { context: this._handle, value } @@ -2469,9 +2488,9 @@ export class PipelineStepFactoryContext { 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.setResource', { context: this._handle, value } @@ -2482,28 +2501,28 @@ export class PipelineStepFactoryContext { } // ============================================================================ -// IPipelineSummary +// PipelineSummary // ============================================================================ -export interface IPipelineSummary { +export interface PipelineSummary { toJSON(): MarshalledHandle; - add(key: string, value: string): IPipelineSummaryPromise; - addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; + add(key: string, value: string): PipelineSummaryPromise; + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise; } -export interface IPipelineSummaryPromise extends PromiseLike { - add(key: string, value: string): IPipelineSummaryPromise; - addMarkdown(key: string, markdownString: string): IPipelineSummaryPromise; +export interface PipelineSummaryPromise extends PromiseLike { + add(key: string, value: string): PipelineSummaryPromise; + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise; } // ============================================================================ -// PipelineSummary +// PipelineSummaryImpl // ============================================================================ /** * Type class for PipelineSummary. */ -export class PipelineSummary { +class PipelineSummaryImpl implements PipelineSummary { constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2521,7 +2540,7 @@ export class PipelineSummary { } add(key: string, value: string): PipelineSummaryPromise { - return new PipelineSummaryPromise(this._addInternal(key, value)); + return new PipelineSummaryPromiseImpl(this._addInternal(key, value)); } /** Adds a Markdown-formatted value to the pipeline summary */ @@ -2536,7 +2555,7 @@ export class PipelineSummary { } addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { - return new PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + return new PipelineSummaryPromiseImpl(this._addMarkdownInternal(key, markdownString)); } } @@ -2544,7 +2563,7 @@ export class PipelineSummary { /** * Thenable wrapper for PipelineSummary that enables fluent chaining. */ -export class PipelineSummaryPromise implements PromiseLike { +class PipelineSummaryPromiseImpl implements PipelineSummaryPromise { constructor(private _promise: Promise) {} then( @@ -2556,21 +2575,21 @@ export class PipelineSummaryPromise implements PromiseLike { /** Invokes the Add method */ add(key: string, value: string): PipelineSummaryPromise { - return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + return new PipelineSummaryPromiseImpl(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))); + return new PipelineSummaryPromiseImpl(this._promise.then(obj => obj.addMarkdown(key, markdownString))); } } // ============================================================================ -// IProjectResourceOptions +// ProjectResourceOptions // ============================================================================ -export interface IProjectResourceOptions { +export interface ProjectResourceOptions { toJSON(): MarshalledHandle; launchProfileName: { get: () => Promise; @@ -2587,13 +2606,13 @@ export interface IProjectResourceOptions { } // ============================================================================ -// ProjectResourceOptions +// ProjectResourceOptionsImpl // ============================================================================ /** * Type class for ProjectResourceOptions. */ -export class ProjectResourceOptions { +class ProjectResourceOptionsImpl implements ProjectResourceOptions { constructor(private _handle: ProjectResourceOptionsHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2650,35 +2669,35 @@ export class ProjectResourceOptions { } // ============================================================================ -// IReferenceExpressionBuilder +// ReferenceExpressionBuilder // ============================================================================ -export interface IReferenceExpressionBuilder { +export interface ReferenceExpressionBuilder { toJSON(): MarshalledHandle; isEmpty: { get: () => Promise; }; - appendLiteral(value: string): IReferenceExpressionBuilderPromise; - appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; - appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; - build(): Promise; + appendLiteral(value: string): ReferenceExpressionBuilderPromise; + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise; + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise; + build(): Promise; } -export interface IReferenceExpressionBuilderPromise extends PromiseLike { - appendLiteral(value: string): IReferenceExpressionBuilderPromise; - appendFormatted(value: string, options?: AppendFormattedOptions): IReferenceExpressionBuilderPromise; - appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): IReferenceExpressionBuilderPromise; - build(): Promise; +export interface ReferenceExpressionBuilderPromise extends PromiseLike { + appendLiteral(value: string): ReferenceExpressionBuilderPromise; + appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise; + appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise; + build(): Promise; } // ============================================================================ -// ReferenceExpressionBuilder +// ReferenceExpressionBuilderImpl // ============================================================================ /** * Type class for ReferenceExpressionBuilder. */ -export class ReferenceExpressionBuilder { +class ReferenceExpressionBuilderImpl implements ReferenceExpressionBuilder { constructor(private _handle: ReferenceExpressionBuilderHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2706,7 +2725,7 @@ export class ReferenceExpressionBuilder { } appendLiteral(value: string): ReferenceExpressionBuilderPromise { - return new ReferenceExpressionBuilderPromise(this._appendLiteralInternal(value)); + return new ReferenceExpressionBuilderPromiseImpl(this._appendLiteralInternal(value)); } /** Appends a formatted string value to the reference expression */ @@ -2723,7 +2742,7 @@ export class ReferenceExpressionBuilder { appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { const format = options?.format; - return new ReferenceExpressionBuilderPromise(this._appendFormattedInternal(value, format)); + return new ReferenceExpressionBuilderPromiseImpl(this._appendFormattedInternal(value, format)); } /** Appends a value provider to the reference expression */ @@ -2740,13 +2759,13 @@ export class ReferenceExpressionBuilder { appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { const format = options?.format; - return new ReferenceExpressionBuilderPromise(this._appendValueProviderInternal(valueProvider, format)); + return new ReferenceExpressionBuilderPromiseImpl(this._appendValueProviderInternal(valueProvider, format)); } /** Builds the reference expression */ - async build(): Promise { + async build(): Promise { const rpcArgs: Record = { context: this._handle }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/build', rpcArgs ); @@ -2757,7 +2776,7 @@ export class ReferenceExpressionBuilder { /** * Thenable wrapper for ReferenceExpressionBuilder that enables fluent chaining. */ -export class ReferenceExpressionBuilderPromise implements PromiseLike { +class ReferenceExpressionBuilderPromiseImpl implements ReferenceExpressionBuilderPromise { constructor(private _promise: Promise) {} then( @@ -2769,48 +2788,48 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike obj.appendLiteral(value))); + return new ReferenceExpressionBuilderPromiseImpl(this._promise.then(obj => obj.appendLiteral(value))); } /** Appends a formatted string value to the reference expression */ appendFormatted(value: string, options?: AppendFormattedOptions): ReferenceExpressionBuilderPromise { - return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendFormatted(value, options))); + return new ReferenceExpressionBuilderPromiseImpl(this._promise.then(obj => obj.appendFormatted(value, options))); } /** Appends a value provider to the reference expression */ appendValueProvider(valueProvider: any, options?: AppendValueProviderOptions): ReferenceExpressionBuilderPromise { - return new ReferenceExpressionBuilderPromise(this._promise.then(obj => obj.appendValueProvider(valueProvider, options))); + return new ReferenceExpressionBuilderPromiseImpl(this._promise.then(obj => obj.appendValueProvider(valueProvider, options))); } /** Builds the reference expression */ - build(): Promise { + build(): Promise { return this._promise.then(obj => obj.build()); } } // ============================================================================ -// IResourceEndpointsAllocatedEvent +// ResourceEndpointsAllocatedEvent // ============================================================================ -export interface IResourceEndpointsAllocatedEvent { +export interface ResourceEndpointsAllocatedEvent { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// ResourceEndpointsAllocatedEvent +// ResourceEndpointsAllocatedEventImpl // ============================================================================ /** * Type class for ResourceEndpointsAllocatedEvent. */ -export class ResourceEndpointsAllocatedEvent { +class ResourceEndpointsAllocatedEventImpl implements ResourceEndpointsAllocatedEvent { constructor(private _handle: ResourceEndpointsAllocatedEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2823,7 +2842,7 @@ export class ResourceEndpointsAllocatedEvent { 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -2834,35 +2853,35 @@ export class ResourceEndpointsAllocatedEvent { 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; } // ============================================================================ -// IResourceLoggerService +// ResourceLoggerService // ============================================================================ -export interface IResourceLoggerService { +export interface ResourceLoggerService { toJSON(): MarshalledHandle; - completeLog(resource: IHandleReference): IResourceLoggerServicePromise; - completeLogByName(resourceName: string): IResourceLoggerServicePromise; + completeLog(resource: HandleReference): ResourceLoggerServicePromise; + completeLogByName(resourceName: string): ResourceLoggerServicePromise; } -export interface IResourceLoggerServicePromise extends PromiseLike { - completeLog(resource: IHandleReference): IResourceLoggerServicePromise; - completeLogByName(resourceName: string): IResourceLoggerServicePromise; +export interface ResourceLoggerServicePromise extends PromiseLike { + completeLog(resource: HandleReference): ResourceLoggerServicePromise; + completeLogByName(resourceName: string): ResourceLoggerServicePromise; } // ============================================================================ -// ResourceLoggerService +// ResourceLoggerServiceImpl // ============================================================================ /** * Type class for ResourceLoggerService. */ -export class ResourceLoggerService { +class ResourceLoggerServiceImpl implements ResourceLoggerService { constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2870,7 +2889,7 @@ export class ResourceLoggerService { /** Completes the log stream for a resource */ /** @internal */ - async _completeLogInternal(resource: IHandleReference): Promise { + async _completeLogInternal(resource: HandleReference): Promise { const rpcArgs: Record = { loggerService: this._handle, resource }; await this._client.invokeCapability( 'Aspire.Hosting/completeLog', @@ -2879,8 +2898,8 @@ export class ResourceLoggerService { return this; } - completeLog(resource: IHandleReference): ResourceLoggerServicePromise { - return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + completeLog(resource: HandleReference): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(this._completeLogInternal(resource)); } /** Completes the log stream by resource name */ @@ -2895,7 +2914,7 @@ export class ResourceLoggerService { } completeLogByName(resourceName: string): ResourceLoggerServicePromise { - return new ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + return new ResourceLoggerServicePromiseImpl(this._completeLogByNameInternal(resourceName)); } } @@ -2903,7 +2922,7 @@ export class ResourceLoggerService { /** * Thenable wrapper for ResourceLoggerService that enables fluent chaining. */ -export class ResourceLoggerServicePromise implements PromiseLike { +class ResourceLoggerServicePromiseImpl implements ResourceLoggerServicePromise { constructor(private _promise: Promise) {} then( @@ -2914,48 +2933,48 @@ export class ResourceLoggerServicePromise implements PromiseLike obj.completeLog(resource))); + completeLog(resource: HandleReference): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromiseImpl(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))); + return new ResourceLoggerServicePromiseImpl(this._promise.then(obj => obj.completeLogByName(resourceName))); } } // ============================================================================ -// IResourceNotificationService +// ResourceNotificationService // ============================================================================ -export interface IResourceNotificationService { +export interface ResourceNotificationService { toJSON(): MarshalledHandle; - waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): IResourceNotificationServicePromise; + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise; waitForResourceStates(resourceName: string, targetStates: string[]): Promise; waitForResourceHealthy(resourceName: string): Promise; - waitForDependencies(resource: IHandleReference): IResourceNotificationServicePromise; + waitForDependencies(resource: HandleReference): ResourceNotificationServicePromise; tryGetResourceState(resourceName: string): Promise; - publishResourceUpdate(resource: IHandleReference, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; + publishResourceUpdate(resource: HandleReference, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise; } -export interface IResourceNotificationServicePromise extends PromiseLike { - waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): IResourceNotificationServicePromise; +export interface ResourceNotificationServicePromise extends PromiseLike { + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise; waitForResourceStates(resourceName: string, targetStates: string[]): Promise; waitForResourceHealthy(resourceName: string): Promise; - waitForDependencies(resource: IHandleReference): IResourceNotificationServicePromise; + waitForDependencies(resource: HandleReference): ResourceNotificationServicePromise; tryGetResourceState(resourceName: string): Promise; - publishResourceUpdate(resource: IHandleReference, options?: PublishResourceUpdateOptions): IResourceNotificationServicePromise; + publishResourceUpdate(resource: HandleReference, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise; } // ============================================================================ -// ResourceNotificationService +// ResourceNotificationServiceImpl // ============================================================================ /** * Type class for ResourceNotificationService. */ -export class ResourceNotificationService { +class ResourceNotificationServiceImpl implements ResourceNotificationService { constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -2975,7 +2994,7 @@ export class ResourceNotificationService { waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { const targetState = options?.targetState; - return new ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + return new ResourceNotificationServicePromiseImpl(this._waitForResourceStateInternal(resourceName, targetState)); } /** Waits for a resource to reach one of the specified states */ @@ -2998,7 +3017,7 @@ export class ResourceNotificationService { /** Waits for all dependencies of a resource to be ready */ /** @internal */ - async _waitForDependenciesInternal(resource: IHandleReference): Promise { + async _waitForDependenciesInternal(resource: HandleReference): Promise { const rpcArgs: Record = { notificationService: this._handle, resource }; await this._client.invokeCapability( 'Aspire.Hosting/waitForDependencies', @@ -3007,8 +3026,8 @@ export class ResourceNotificationService { return this; } - waitForDependencies(resource: IHandleReference): ResourceNotificationServicePromise { - return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + waitForDependencies(resource: HandleReference): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._waitForDependenciesInternal(resource)); } /** Tries to get the current state of a resource */ @@ -3022,7 +3041,7 @@ export class ResourceNotificationService { /** Publishes an update for a resource's state */ /** @internal */ - async _publishResourceUpdateInternal(resource: IHandleReference, state?: string, stateStyle?: string): Promise { + async _publishResourceUpdateInternal(resource: HandleReference, state?: string, stateStyle?: string): Promise { const rpcArgs: Record = { notificationService: this._handle, resource }; if (state !== undefined) rpcArgs.state = state; if (stateStyle !== undefined) rpcArgs.stateStyle = stateStyle; @@ -3033,10 +3052,10 @@ export class ResourceNotificationService { return this; } - publishResourceUpdate(resource: IHandleReference, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + publishResourceUpdate(resource: HandleReference, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { const state = options?.state; const stateStyle = options?.stateStyle; - return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + return new ResourceNotificationServicePromiseImpl(this._publishResourceUpdateInternal(resource, state, stateStyle)); } } @@ -3044,7 +3063,7 @@ export class ResourceNotificationService { /** * Thenable wrapper for ResourceNotificationService that enables fluent chaining. */ -export class ResourceNotificationServicePromise implements PromiseLike { +class ResourceNotificationServicePromiseImpl implements ResourceNotificationServicePromise { constructor(private _promise: Promise) {} then( @@ -3056,7 +3075,7 @@ export class ResourceNotificationServicePromise implements PromiseLike obj.waitForResourceState(resourceName, options))); + return new ResourceNotificationServicePromiseImpl(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); } /** Waits for a resource to reach one of the specified states */ @@ -3070,8 +3089,8 @@ export class ResourceNotificationServicePromise implements PromiseLike obj.waitForDependencies(resource))); + waitForDependencies(resource: HandleReference): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._promise.then(obj => obj.waitForDependencies(resource))); } /** Tries to get the current state of a resource */ @@ -3080,34 +3099,34 @@ export class ResourceNotificationServicePromise implements PromiseLike obj.publishResourceUpdate(resource, options))); + publishResourceUpdate(resource: HandleReference, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromiseImpl(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); } } // ============================================================================ -// IResourceReadyEvent +// ResourceReadyEvent // ============================================================================ -export interface IResourceReadyEvent { +export interface ResourceReadyEvent { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// ResourceReadyEvent +// ResourceReadyEventImpl // ============================================================================ /** * Type class for ResourceReadyEvent. */ -export class ResourceReadyEvent { +class ResourceReadyEventImpl implements ResourceReadyEvent { constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3120,7 +3139,7 @@ export class ResourceReadyEvent { 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -3131,34 +3150,34 @@ export class ResourceReadyEvent { 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; } // ============================================================================ -// IResourceStoppedEvent +// ResourceStoppedEvent // ============================================================================ -export interface IResourceStoppedEvent { +export interface ResourceStoppedEvent { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; services: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// ResourceStoppedEvent +// ResourceStoppedEventImpl // ============================================================================ /** * Type class for ResourceStoppedEvent. */ -export class ResourceStoppedEvent { +class ResourceStoppedEventImpl implements ResourceStoppedEvent { constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3171,7 +3190,7 @@ export class ResourceStoppedEvent { 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -3182,42 +3201,42 @@ export class ResourceStoppedEvent { 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, }; } // ============================================================================ -// IResourceUrlsCallbackContext +// ResourceUrlsCallbackContext // ============================================================================ -export interface IResourceUrlsCallbackContext { +export interface ResourceUrlsCallbackContext { toJSON(): MarshalledHandle; resource: { - get: () => Promise; + get: () => Promise; }; readonly urls: AspireList; cancellationToken: { - get: () => Promise; + get: () => Promise; }; logger: { - get: () => Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; executionContext: { - get: () => Promise; + get: () => Promise; }; } // ============================================================================ -// ResourceUrlsCallbackContext +// ResourceUrlsCallbackContextImpl // ============================================================================ /** * Type class for ResourceUrlsCallbackContext. */ -export class ResourceUrlsCallbackContext { +class ResourceUrlsCallbackContextImpl implements ResourceUrlsCallbackContext { constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3230,7 +3249,7 @@ export class ResourceUrlsCallbackContext { 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', { context: this._handle } ); - return new Resource(handle, this._client); + return new ResourceImpl(handle, this._client); }, }; @@ -3250,7 +3269,7 @@ export class ResourceUrlsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', { context: this._handle } @@ -3266,9 +3285,9 @@ export class ResourceUrlsCallbackContext { 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', { context: this._handle } ); - return new Logger(handle, this._client); + return new LoggerImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.setLogger', { context: this._handle, value } @@ -3283,17 +3302,17 @@ export class ResourceUrlsCallbackContext { 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new DistributedApplicationExecutionContextImpl(handle, this._client); }, }; } // ============================================================================ -// ITestCallbackContext +// TestCallbackContext // ============================================================================ -export interface ITestCallbackContext { +export interface TestCallbackContext { toJSON(): MarshalledHandle; name: { get: () => Promise; @@ -3304,19 +3323,19 @@ export interface ITestCallbackContext { set: (value: number) => Promise; }; cancellationToken: { - get: () => Promise; - set: (value: AbortSignal | ICancellationToken) => Promise; + get: () => Promise; + set: (value: AbortSignal | CancellationToken) => Promise; }; } // ============================================================================ -// TestCallbackContext +// TestCallbackContextImpl // ============================================================================ /** * Type class for TestCallbackContext. */ -export class TestCallbackContext { +class TestCallbackContextImpl implements TestCallbackContext { constructor(private _handle: TestCallbackContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3356,14 +3375,14 @@ export class TestCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { + get: async (): Promise => { const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.cancellationToken', { context: this._handle } ); return CancellationToken.fromValue(result); }, - set: async (value: AbortSignal | ICancellationToken): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes/TestCallbackContext.setCancellationToken', { context: this._handle, value: CancellationToken.fromValue(value) } @@ -3374,23 +3393,23 @@ export class TestCallbackContext { } // ============================================================================ -// ITestCollectionContext +// TestCollectionContext // ============================================================================ -export interface ITestCollectionContext { +export interface TestCollectionContext { toJSON(): MarshalledHandle; readonly items: AspireList; readonly metadata: AspireDict; } // ============================================================================ -// TestCollectionContext +// TestCollectionContextImpl // ============================================================================ /** * Type class for TestCollectionContext. */ -export class TestCollectionContext { +class TestCollectionContextImpl implements TestCollectionContext { constructor(private _handle: TestCollectionContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3427,10 +3446,10 @@ export class TestCollectionContext { } // ============================================================================ -// ITestEnvironmentContext +// TestEnvironmentContext // ============================================================================ -export interface ITestEnvironmentContext { +export interface TestEnvironmentContext { toJSON(): MarshalledHandle; name: { get: () => Promise; @@ -3447,13 +3466,13 @@ export interface ITestEnvironmentContext { } // ============================================================================ -// TestEnvironmentContext +// TestEnvironmentContextImpl // ============================================================================ /** * Type class for TestEnvironmentContext. */ -export class TestEnvironmentContext { +class TestEnvironmentContextImpl implements TestEnvironmentContext { constructor(private _handle: TestEnvironmentContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3510,10 +3529,10 @@ export class TestEnvironmentContext { } // ============================================================================ -// ITestResourceContext +// TestResourceContext // ============================================================================ -export interface ITestResourceContext { +export interface TestResourceContext { toJSON(): MarshalledHandle; name: { get: () => Promise; @@ -3524,24 +3543,24 @@ export interface ITestResourceContext { set: (value: number) => Promise; }; getValueAsync(): Promise; - setValueAsync(value: string): ITestResourceContextPromise; + setValueAsync(value: string): TestResourceContextPromise; validateAsync(): Promise; } -export interface ITestResourceContextPromise extends PromiseLike { +export interface TestResourceContextPromise extends PromiseLike { getValueAsync(): Promise; - setValueAsync(value: string): ITestResourceContextPromise; + setValueAsync(value: string): TestResourceContextPromise; validateAsync(): Promise; } // ============================================================================ -// TestResourceContext +// TestResourceContextImpl // ============================================================================ /** * Type class for TestResourceContext. */ -export class TestResourceContext { +class TestResourceContextImpl implements TestResourceContext { constructor(private _handle: TestResourceContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3600,7 +3619,7 @@ export class TestResourceContext { } setValueAsync(value: string): TestResourceContextPromise { - return new TestResourceContextPromise(this._setValueAsyncInternal(value)); + return new TestResourceContextPromiseImpl(this._setValueAsyncInternal(value)); } /** Invokes the ValidateAsync method */ @@ -3617,7 +3636,7 @@ export class TestResourceContext { /** * Thenable wrapper for TestResourceContext that enables fluent chaining. */ -export class TestResourceContextPromise implements PromiseLike { +class TestResourceContextPromiseImpl implements TestResourceContextPromise { constructor(private _promise: Promise) {} then( @@ -3634,7 +3653,7 @@ export class TestResourceContextPromise implements PromiseLike obj.setValueAsync(value))); + return new TestResourceContextPromiseImpl(this._promise.then(obj => obj.setValueAsync(value))); } /** Invokes the ValidateAsync method */ @@ -3645,25 +3664,25 @@ export class TestResourceContextPromise implements PromiseLike Promise; - set: (value: IHandleReference) => Promise; + get: () => Promise; + set: (value: HandleReference) => Promise; }; } // ============================================================================ -// UpdateCommandStateContext +// UpdateCommandStateContextImpl // ============================================================================ /** * Type class for UpdateCommandStateContext. */ -export class UpdateCommandStateContext { +class UpdateCommandStateContextImpl implements UpdateCommandStateContext { constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3676,9 +3695,9 @@ export class UpdateCommandStateContext { 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', { context: this._handle } ); - return new ServiceProvider(handle, this._client); + return new ServiceProviderImpl(handle, this._client); }, - set: async (value: IHandleReference): Promise => { + set: async (value: HandleReference): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.setServiceProvider', { context: this._handle, value } @@ -3689,10 +3708,10 @@ export class UpdateCommandStateContext { } // ============================================================================ -// IConfiguration +// Configuration // ============================================================================ -export interface IConfiguration { +export interface Configuration { toJSON(): MarshalledHandle; getConfigValue(key: string): Promise; getConnectionString(name: string): Promise; @@ -3701,7 +3720,7 @@ export interface IConfiguration { exists(key: string): Promise; } -export interface IConfigurationPromise extends PromiseLike { +export interface ConfigurationPromise extends PromiseLike { getConfigValue(key: string): Promise; getConnectionString(name: string): Promise; getSection(key: string): Promise; @@ -3710,13 +3729,13 @@ export interface IConfigurationPromise extends PromiseLike { } // ============================================================================ -// Configuration +// ConfigurationImpl // ============================================================================ /** * Type class for Configuration. */ -export class Configuration { +class ConfigurationImpl implements Configuration { constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3772,7 +3791,7 @@ export class Configuration { /** * Thenable wrapper for Configuration that enables fluent chaining. */ -export class ConfigurationPromise implements PromiseLike { +class ConfigurationPromiseImpl implements ConfigurationPromise { constructor(private _promise: Promise) {} then( @@ -3810,89 +3829,89 @@ export class ConfigurationPromise implements PromiseLike { } // ============================================================================ -// IDistributedApplicationBuilder +// DistributedApplicationBuilder // ============================================================================ -export interface IDistributedApplicationBuilder { +export interface DistributedApplicationBuilder { toJSON(): MarshalledHandle; appHostDirectory: { get: () => Promise; }; environment: { - get: () => Promise; + get: () => Promise; }; eventing: { - get: () => Promise; + get: () => Promise; }; executionContext: { - get: () => Promise; + get: () => Promise; }; userSecretsManager: { - get: () => Promise; + get: () => Promise; }; - build(): IDistributedApplicationPromise; - addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; - addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; - addContainer(name: string, image: string): IContainerResourcePromise; - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; - addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; - addExternalService(name: string, url: string): IExternalServiceResourcePromise; - addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; - addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; - addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; - addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; - addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; - addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; - addCSharpApp(name: string, path: string): IProjectResourcePromise; - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; - getConfiguration(): IConfigurationPromise; - subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; - subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; - addTestRedis(name: string, options?: AddTestRedisOptions): ITestRedisResourcePromise; - addTestVault(name: string): ITestVaultResourcePromise; -} - -export interface IDistributedApplicationBuilderPromise extends PromiseLike { - build(): IDistributedApplicationPromise; - addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): IConnectionStringResourcePromise; - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): IConnectionStringResourcePromise; - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): IContainerRegistryResourcePromise; - addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): IContainerRegistryResourcePromise; - addContainer(name: string, image: string): IContainerResourcePromise; - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): IContainerResourcePromise; - addDotnetTool(name: string, packageId: string): IDotnetToolResourcePromise; - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): IExecutableResourcePromise; - addExternalService(name: string, url: string): IExternalServiceResourcePromise; - addExternalServiceUri(name: string, uri: string): IExternalServiceResourcePromise; - addExternalServiceParameter(name: string, urlParameter: IParameterResource): IExternalServiceResourcePromise; - addParameter(name: string, options?: AddParameterOptions): IParameterResourcePromise; - addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): IParameterResourcePromise; - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): IParameterResourcePromise; - addConnectionString(name: string, options?: AddConnectionStringOptions): IResourceWithConnectionStringPromise; - addProject(name: string, projectPath: string, launchProfileName: string): IProjectResourcePromise; - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): IProjectResourcePromise; - addCSharpApp(name: string, path: string): IProjectResourcePromise; - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): ICSharpAppResourcePromise; - getConfiguration(): IConfigurationPromise; - subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise; - subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise; - addTestRedis(name: string, options?: AddTestRedisOptions): ITestRedisResourcePromise; - addTestVault(name: string): ITestVaultResourcePromise; -} - -// ============================================================================ -// DistributedApplicationBuilder + build(): DistributedApplicationPromise; + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise; + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise; + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise; + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise; + addContainer(name: string, image: string): ContainerResourcePromise; + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise; + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise; + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise; + addExternalService(name: string, url: string): ExternalServiceResourcePromise; + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise; + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise; + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise; + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise; + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise; + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise; + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise; + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise; + addCSharpApp(name: string, path: string): ProjectResourcePromise; + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise; + getConfiguration(): ConfigurationPromise; + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise; + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise; + addTestRedis(name: string, options?: AddTestRedisOptions): TestRedisResourcePromise; + addTestVault(name: string): TestVaultResourcePromise; +} + +export interface DistributedApplicationBuilderPromise extends PromiseLike { + build(): DistributedApplicationPromise; + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise; + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise; + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise; + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise; + addContainer(name: string, image: string): ContainerResourcePromise; + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise; + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise; + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise; + addExternalService(name: string, url: string): ExternalServiceResourcePromise; + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise; + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise; + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise; + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise; + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise; + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise; + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise; + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise; + addCSharpApp(name: string, path: string): ProjectResourcePromise; + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise; + getConfiguration(): ConfigurationPromise; + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise; + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise; + addTestRedis(name: string, options?: AddTestRedisOptions): TestRedisResourcePromise; + addTestVault(name: string): TestVaultResourcePromise; +} + +// ============================================================================ +// DistributedApplicationBuilderImpl // ============================================================================ /** * Type class for DistributedApplicationBuilder. */ -export class DistributedApplicationBuilder { +class DistributedApplicationBuilderImpl implements DistributedApplicationBuilder { constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -3915,7 +3934,7 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/IDistributedApplicationBuilder.environment', { context: this._handle } ); - return new HostEnvironment(handle, this._client); + return new HostEnvironmentImpl(handle, this._client); }, }; @@ -3926,7 +3945,7 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); + return new DistributedApplicationEventingImpl(handle, this._client); }, }; @@ -3937,7 +3956,7 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new DistributedApplicationExecutionContextImpl(handle, this._client); }, }; @@ -3948,7 +3967,7 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', { context: this._handle } ); - return new UserSecretsManager(handle, this._client); + return new UserSecretsManagerImpl(handle, this._client); }, }; @@ -3960,34 +3979,34 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/build', rpcArgs ); - return new DistributedApplication(result, this._client); + return new DistributedApplicationImpl(result, this._client); } build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); + return new DistributedApplicationPromiseImpl(this._buildInternal()); } /** Adds a connection string with a reference expression */ /** @internal */ - async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: IReferenceExpression): Promise { + 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); + return new ConnectionStringResourceImpl(result, this._client); } - addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); } /** Adds a connection string with a builder callback */ /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): Promise { + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { const connectionStringBuilderId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); + const obj = new ReferenceExpressionBuilderImpl(objHandle, this._client); await connectionStringBuilder(obj); }); const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; @@ -3995,28 +4014,28 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addConnectionStringBuilder', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); } /** Adds a container registry resource */ /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: IParameterResource, repository?: IParameterResource): Promise { + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, endpoint }; if (repository !== undefined) rpcArgs.repository = repository; const result = await this._client.invokeCapability( 'Aspire.Hosting/addContainerRegistry', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + return new ContainerRegistryResourcePromiseImpl(this._addContainerRegistryInternal(name, endpoint, repository)); } /** Adds a container registry with string endpoint */ @@ -4028,12 +4047,12 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addContainerRegistryFromString', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + return new ContainerRegistryResourcePromiseImpl(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); } /** Adds a container resource */ @@ -4044,11 +4063,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addContainer', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + return new ContainerResourcePromiseImpl(this._addContainerInternal(name, image)); } /** Adds a container resource built from a Dockerfile */ @@ -4061,13 +4080,13 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addDockerfile', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { const dockerfilePath = options?.dockerfilePath; const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + return new ContainerResourcePromiseImpl(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); } /** Adds a .NET tool resource */ @@ -4078,11 +4097,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addDotnetTool', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + return new DotnetToolResourcePromiseImpl(this._addDotnetToolInternal(name, packageId)); } /** Adds an executable resource */ @@ -4093,11 +4112,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addExecutable', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + return new ExecutableResourcePromiseImpl(this._addExecutableInternal(name, command, workingDirectory, args)); } /** Adds an external service resource */ @@ -4108,11 +4127,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addExternalService', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + return new ExternalServiceResourcePromiseImpl(this._addExternalServiceInternal(name, url)); } /** Adds an external service with a URI */ @@ -4123,26 +4142,26 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addExternalServiceUri', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + return new ExternalServiceResourcePromiseImpl(this._addExternalServiceUriInternal(name, uri)); } /** Adds an external service with a parameter URL */ /** @internal */ - async _addExternalServiceParameterInternal(name: string, urlParameter: IParameterResource): Promise { + 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); + return new ExternalServiceResourceImpl(result, this._client); } - addExternalServiceParameter(name: string, urlParameter: IParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._addExternalServiceParameterInternal(name, urlParameter)); } /** Adds a parameter resource */ @@ -4154,12 +4173,12 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addParameter', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + return new ParameterResourcePromiseImpl(this._addParameterInternal(name, secret)); } /** Adds a parameter with a default value */ @@ -4172,13 +4191,13 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addParameterWithValue', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(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)); + return new ParameterResourcePromiseImpl(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); } /** Adds a parameter sourced from configuration */ @@ -4190,12 +4209,12 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addParameterFromConfiguration', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + return new ParameterResourcePromiseImpl(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); } /** Adds a connection string resource */ @@ -4207,12 +4226,12 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addConnectionString', rpcArgs ); - return new ResourceWithConnectionString(result, this._client); + return new ResourceWithConnectionStringImpl(result, this._client); } addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + return new ResourceWithConnectionStringPromiseImpl(this._addConnectionStringInternal(name, environmentVariableName)); } /** Adds a .NET project resource */ @@ -4223,19 +4242,19 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addProject', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + return new ProjectResourcePromiseImpl(this._addProjectInternal(name, projectPath, launchProfileName)); } /** Adds a project resource with configuration options */ /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); + const obj = new ProjectResourceOptionsImpl(objHandle, this._client); await configure(obj); }); const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; @@ -4243,11 +4262,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addProjectWithOptions', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._addProjectWithOptionsInternal(name, projectPath, configure)); } /** Adds a C# application resource */ @@ -4258,19 +4277,19 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addCSharpApp', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + return new ProjectResourcePromiseImpl(this._addCSharpAppInternal(name, path)); } /** Adds a C# application resource with configuration options */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): Promise { + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); + const obj = new ProjectResourceOptionsImpl(objHandle, this._client); await configure(obj); }); const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; @@ -4278,11 +4297,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/addCSharpAppWithOptions', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._addCSharpAppWithOptionsInternal(name, path, configure)); } /** Gets the application configuration */ @@ -4293,18 +4312,18 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting/getConfiguration', rpcArgs ); - return new Configuration(result, this._client); + return new ConfigurationImpl(result, this._client); } getConfiguration(): ConfigurationPromise { - return new ConfigurationPromise(this._getConfigurationInternal()); + return new ConfigurationPromiseImpl(this._getConfigurationInternal()); } /** Subscribes to the BeforeStart event */ - async subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise { + 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); + const arg = new BeforeStartEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -4315,10 +4334,10 @@ export class DistributedApplicationBuilder { } /** Subscribes to the AfterResourcesCreated event */ - async subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise { + 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); + const arg = new AfterResourcesCreatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -4337,12 +4356,12 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/addTestRedis', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } addTestRedis(name: string, options?: AddTestRedisOptions): TestRedisResourcePromise { const port = options?.port; - return new TestRedisResourcePromise(this._addTestRedisInternal(name, port)); + return new TestRedisResourcePromiseImpl(this._addTestRedisInternal(name, port)); } /** Adds a test vault resource */ @@ -4353,11 +4372,11 @@ export class DistributedApplicationBuilder { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/addTestVault', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } addTestVault(name: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._addTestVaultInternal(name)); + return new TestVaultResourcePromiseImpl(this._addTestVaultInternal(name)); } } @@ -4365,7 +4384,7 @@ export class DistributedApplicationBuilder { /** * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { +class DistributedApplicationBuilderPromiseImpl implements DistributedApplicationBuilderPromise { constructor(private _promise: Promise) {} then( @@ -4377,152 +4396,152 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.build())); + return new DistributedApplicationPromiseImpl(this._promise.then(obj => obj.build())); } /** Adds a connection string with a reference expression */ - addConnectionStringExpression(name: string, connectionStringExpression: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); } /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: IReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); } /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: IParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => 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))); + return new ContainerRegistryResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.addContainer(name, image))); } /** Adds a container resource built from a Dockerfile */ addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); } /** Adds a .NET tool resource */ addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.addDotnetTool(name, packageId))); } /** Adds an executable resource */ addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); } /** Adds an external service resource */ addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => 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))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); } /** Adds an external service with a parameter URL */ - addExternalServiceParameter(name: string, urlParameter: IParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(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))); + return new ParameterResourcePromiseImpl(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))); + return new ParameterResourcePromiseImpl(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))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); } /** Adds a connection string resource */ addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.addConnectionString(name, options))); } /** Adds a .NET project resource */ addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); } /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: IProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); } /** Adds a C# application resource */ addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.addCSharpApp(name, path))); } /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: IProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); } /** Gets the application configuration */ getConfiguration(): ConfigurationPromise { - return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + return new ConfigurationPromiseImpl(this._promise.then(obj => obj.getConfiguration())); } /** Subscribes to the BeforeStart event */ - subscribeBeforeStart(callback: (arg: IBeforeStartEvent) => Promise): Promise { + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { return this._promise.then(obj => obj.subscribeBeforeStart(callback)); } /** Subscribes to the AfterResourcesCreated event */ - subscribeAfterResourcesCreated(callback: (arg: IAfterResourcesCreatedEvent) => Promise): Promise { + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); } /** Adds a test Redis resource */ addTestRedis(name: string, options?: AddTestRedisOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.addTestRedis(name, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.addTestRedis(name, options))); } /** Adds a test vault resource */ addTestVault(name: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.addTestVault(name))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.addTestVault(name))); } } // ============================================================================ -// IDistributedApplicationEventing +// DistributedApplicationEventing // ============================================================================ -export interface IDistributedApplicationEventing { +export interface DistributedApplicationEventing { toJSON(): MarshalledHandle; - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): IDistributedApplicationEventingPromise; + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise; } -export interface IDistributedApplicationEventingPromise extends PromiseLike { - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): IDistributedApplicationEventingPromise; +export interface DistributedApplicationEventingPromise extends PromiseLike { + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise; } // ============================================================================ -// DistributedApplicationEventing +// DistributedApplicationEventingImpl // ============================================================================ /** * Type class for DistributedApplicationEventing. */ -export class DistributedApplicationEventing { +class DistributedApplicationEventingImpl implements DistributedApplicationEventing { constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -4540,7 +4559,7 @@ export class DistributedApplicationEventing { } unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + return new DistributedApplicationEventingPromiseImpl(this._unsubscribeInternal(subscription)); } } @@ -4548,7 +4567,7 @@ export class DistributedApplicationEventing { /** * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { +class DistributedApplicationEventingPromiseImpl implements DistributedApplicationEventingPromise { constructor(private _promise: Promise) {} then( @@ -4560,16 +4579,16 @@ export class DistributedApplicationEventingPromise implements PromiseLike obj.unsubscribe(subscription))); + return new DistributedApplicationEventingPromiseImpl(this._promise.then(obj => obj.unsubscribe(subscription))); } } // ============================================================================ -// IHostEnvironment +// HostEnvironment // ============================================================================ -export interface IHostEnvironment { +export interface HostEnvironment { toJSON(): MarshalledHandle; isDevelopment(): Promise; isProduction(): Promise; @@ -4577,7 +4596,7 @@ export interface IHostEnvironment { isEnvironment(environmentName: string): Promise; } -export interface IHostEnvironmentPromise extends PromiseLike { +export interface HostEnvironmentPromise extends PromiseLike { isDevelopment(): Promise; isProduction(): Promise; isStaging(): Promise; @@ -4585,13 +4604,13 @@ export interface IHostEnvironmentPromise extends PromiseLike { } // ============================================================================ -// HostEnvironment +// HostEnvironmentImpl // ============================================================================ /** * Type class for HostEnvironment. */ -export class HostEnvironment { +class HostEnvironmentImpl implements HostEnvironment { constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -4638,7 +4657,7 @@ export class HostEnvironment { /** * Thenable wrapper for HostEnvironment that enables fluent chaining. */ -export class HostEnvironmentPromise implements PromiseLike { +class HostEnvironmentPromiseImpl implements HostEnvironmentPromise { constructor(private _promise: Promise) {} then( @@ -4671,34 +4690,34 @@ export class HostEnvironmentPromise implements PromiseLike { } // ============================================================================ -// ILogger +// Logger // ============================================================================ -export interface ILogger { +export interface Logger { toJSON(): MarshalledHandle; - logInformation(message: string): ILoggerPromise; - logWarning(message: string): ILoggerPromise; - logError(message: string): ILoggerPromise; - logDebug(message: string): ILoggerPromise; - log(level: string, message: string): ILoggerPromise; + logInformation(message: string): LoggerPromise; + logWarning(message: string): LoggerPromise; + logError(message: string): LoggerPromise; + logDebug(message: string): LoggerPromise; + log(level: string, message: string): LoggerPromise; } -export interface ILoggerPromise extends PromiseLike { - logInformation(message: string): ILoggerPromise; - logWarning(message: string): ILoggerPromise; - logError(message: string): ILoggerPromise; - logDebug(message: string): ILoggerPromise; - log(level: string, message: string): ILoggerPromise; +export interface LoggerPromise extends PromiseLike { + logInformation(message: string): LoggerPromise; + logWarning(message: string): LoggerPromise; + logError(message: string): LoggerPromise; + logDebug(message: string): LoggerPromise; + log(level: string, message: string): LoggerPromise; } // ============================================================================ -// Logger +// LoggerImpl // ============================================================================ /** * Type class for Logger. */ -export class Logger { +class LoggerImpl implements Logger { constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -4716,7 +4735,7 @@ export class Logger { } logInformation(message: string): LoggerPromise { - return new LoggerPromise(this._logInformationInternal(message)); + return new LoggerPromiseImpl(this._logInformationInternal(message)); } /** Logs a warning message */ @@ -4731,7 +4750,7 @@ export class Logger { } logWarning(message: string): LoggerPromise { - return new LoggerPromise(this._logWarningInternal(message)); + return new LoggerPromiseImpl(this._logWarningInternal(message)); } /** Logs an error message */ @@ -4746,7 +4765,7 @@ export class Logger { } logError(message: string): LoggerPromise { - return new LoggerPromise(this._logErrorInternal(message)); + return new LoggerPromiseImpl(this._logErrorInternal(message)); } /** Logs a debug message */ @@ -4761,7 +4780,7 @@ export class Logger { } logDebug(message: string): LoggerPromise { - return new LoggerPromise(this._logDebugInternal(message)); + return new LoggerPromiseImpl(this._logDebugInternal(message)); } /** Logs a message with specified level */ @@ -4776,7 +4795,7 @@ export class Logger { } log(level: string, message: string): LoggerPromise { - return new LoggerPromise(this._logInternal(level, message)); + return new LoggerPromiseImpl(this._logInternal(level, message)); } } @@ -4784,7 +4803,7 @@ export class Logger { /** * Thenable wrapper for Logger that enables fluent chaining. */ -export class LoggerPromise implements PromiseLike { +class LoggerPromiseImpl implements LoggerPromise { constructor(private _promise: Promise) {} then( @@ -4796,52 +4815,52 @@ export class LoggerPromise implements PromiseLike { /** Logs an information message */ logInformation(message: string): LoggerPromise { - return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); + return new LoggerPromiseImpl(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))); + return new LoggerPromiseImpl(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))); + return new LoggerPromiseImpl(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))); + return new LoggerPromiseImpl(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))); + return new LoggerPromiseImpl(this._promise.then(obj => obj.log(level, message))); } } // ============================================================================ -// ILoggerFactory +// LoggerFactory // ============================================================================ -export interface ILoggerFactory { +export interface LoggerFactory { toJSON(): MarshalledHandle; - createLogger(categoryName: string): ILoggerPromise; + createLogger(categoryName: string): LoggerPromise; } -export interface ILoggerFactoryPromise extends PromiseLike { - createLogger(categoryName: string): ILoggerPromise; +export interface LoggerFactoryPromise extends PromiseLike { + createLogger(categoryName: string): LoggerPromise; } // ============================================================================ -// LoggerFactory +// LoggerFactoryImpl // ============================================================================ /** * Type class for LoggerFactory. */ -export class LoggerFactory { +class LoggerFactoryImpl implements LoggerFactory { constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -4855,11 +4874,11 @@ export class LoggerFactory { 'Aspire.Hosting/createLogger', rpcArgs ); - return new Logger(result, this._client); + return new LoggerImpl(result, this._client); } createLogger(categoryName: string): LoggerPromise { - return new LoggerPromise(this._createLoggerInternal(categoryName)); + return new LoggerPromiseImpl(this._createLoggerInternal(categoryName)); } } @@ -4867,7 +4886,7 @@ export class LoggerFactory { /** * Thenable wrapper for LoggerFactory that enables fluent chaining. */ -export class LoggerFactoryPromise implements PromiseLike { +class LoggerFactoryPromiseImpl implements LoggerFactoryPromise { constructor(private _promise: Promise) {} then( @@ -4879,42 +4898,42 @@ export class LoggerFactoryPromise implements PromiseLike { /** Creates a logger for a category */ createLogger(categoryName: string): LoggerPromise { - return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); + return new LoggerPromiseImpl(this._promise.then(obj => obj.createLogger(categoryName))); } } // ============================================================================ -// IReportingStep +// ReportingStep // ============================================================================ -export interface IReportingStep { +export interface ReportingStep { toJSON(): MarshalledHandle; - createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; - createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; - logStep(level: string, message: string): IReportingStepPromise; - logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; - completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; - completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise; + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise; + logStep(level: string, message: string): ReportingStepPromise; + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise; + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise; + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise; } -export interface IReportingStepPromise extends PromiseLike { - createTask(statusText: string, options?: CreateTaskOptions): IReportingTaskPromise; - createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): IReportingTaskPromise; - logStep(level: string, message: string): IReportingStepPromise; - logStepMarkdown(level: string, markdownString: string): IReportingStepPromise; - completeStep(completionText: string, options?: CompleteStepOptions): IReportingStepPromise; - completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): IReportingStepPromise; +export interface ReportingStepPromise extends PromiseLike { + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise; + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise; + logStep(level: string, message: string): ReportingStepPromise; + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise; + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise; + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise; } // ============================================================================ -// ReportingStep +// ReportingStepImpl // ============================================================================ /** * Type class for ReportingStep. */ -export class ReportingStep { +class ReportingStepImpl implements ReportingStep { constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -4922,36 +4941,36 @@ export class ReportingStep { /** Creates a reporting task with plain-text status text */ /** @internal */ - async _createTaskInternal(statusText: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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); + return new ReportingTaskImpl(result, this._client); } createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { const cancellationToken = options?.cancellationToken; - return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); + return new ReportingTaskPromiseImpl(this._createTaskInternal(statusText, cancellationToken)); } /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _createMarkdownTaskInternal(markdownString: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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); + return new ReportingTaskImpl(result, this._client); } createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { const cancellationToken = options?.cancellationToken; - return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); + return new ReportingTaskPromiseImpl(this._createMarkdownTaskInternal(markdownString, cancellationToken)); } /** Logs a plain-text message for the reporting step */ @@ -4966,7 +4985,7 @@ export class ReportingStep { } logStep(level: string, message: string): ReportingStepPromise { - return new ReportingStepPromise(this._logStepInternal(level, message)); + return new ReportingStepPromiseImpl(this._logStepInternal(level, message)); } /** Logs a Markdown-formatted message for the reporting step */ @@ -4981,12 +5000,12 @@ export class ReportingStep { } logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { - return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); + return new ReportingStepPromiseImpl(this._logStepMarkdownInternal(level, markdownString)); } /** Completes the reporting step with plain-text completion text */ /** @internal */ - async _completeStepInternal(completionText: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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); @@ -5000,12 +5019,12 @@ export class ReportingStep { completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { const completionState = options?.completionState; const cancellationToken = options?.cancellationToken; - return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); + return new ReportingStepPromiseImpl(this._completeStepInternal(completionText, completionState, cancellationToken)); } /** Completes the reporting step with Markdown-formatted completion text */ /** @internal */ - async _completeStepMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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); @@ -5019,7 +5038,7 @@ export class ReportingStep { completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { const completionState = options?.completionState; const cancellationToken = options?.cancellationToken; - return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); + return new ReportingStepPromiseImpl(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } } @@ -5027,7 +5046,7 @@ export class ReportingStep { /** * Thenable wrapper for ReportingStep that enables fluent chaining. */ -export class ReportingStepPromise implements PromiseLike { +class ReportingStepPromiseImpl implements ReportingStepPromise { constructor(private _promise: Promise) {} then( @@ -5039,63 +5058,63 @@ export class ReportingStepPromise implements PromiseLike { /** 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))); + return new ReportingTaskPromiseImpl(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))); + return new ReportingTaskPromiseImpl(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))); + return new ReportingStepPromiseImpl(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))); + return new ReportingStepPromiseImpl(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))); + return new ReportingStepPromiseImpl(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))); + return new ReportingStepPromiseImpl(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); } } // ============================================================================ -// IReportingTask +// ReportingTask // ============================================================================ -export interface IReportingTask { +export interface ReportingTask { toJSON(): MarshalledHandle; - updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; - updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; - completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; - completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise; + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise; + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise; + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise; } -export interface IReportingTaskPromise extends PromiseLike { - updateTask(statusText: string, options?: UpdateTaskOptions): IReportingTaskPromise; - updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): IReportingTaskPromise; - completeTask(options?: CompleteTaskOptions): IReportingTaskPromise; - completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): IReportingTaskPromise; +export interface ReportingTaskPromise extends PromiseLike { + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise; + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise; + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise; + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise; } // ============================================================================ -// ReportingTask +// ReportingTaskImpl // ============================================================================ /** * Type class for ReportingTask. */ -export class ReportingTask { +class ReportingTaskImpl implements ReportingTask { constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -5103,7 +5122,7 @@ export class ReportingTask { /** Updates the reporting task with plain-text status text */ /** @internal */ - async _updateTaskInternal(statusText: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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( @@ -5115,12 +5134,12 @@ export class ReportingTask { updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { const cancellationToken = options?.cancellationToken; - return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); + return new ReportingTaskPromiseImpl(this._updateTaskInternal(statusText, cancellationToken)); } /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _updateTaskMarkdownInternal(markdownString: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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( @@ -5132,12 +5151,12 @@ export class ReportingTask { updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { const cancellationToken = options?.cancellationToken; - return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); + return new ReportingTaskPromiseImpl(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _completeTaskInternal(completionMessage?: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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; @@ -5153,12 +5172,12 @@ export class ReportingTask { const completionMessage = options?.completionMessage; const completionState = options?.completionState; const cancellationToken = options?.cancellationToken; - return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); + return new ReportingTaskPromiseImpl(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _completeTaskMarkdownInternal(markdownString: string, completionState?: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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); @@ -5172,7 +5191,7 @@ export class ReportingTask { completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { const completionState = options?.completionState; const cancellationToken = options?.cancellationToken; - return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); + return new ReportingTaskPromiseImpl(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } @@ -5180,7 +5199,7 @@ export class ReportingTask { /** * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class ReportingTaskPromise implements PromiseLike { +class ReportingTaskPromiseImpl implements ReportingTaskPromise { constructor(private _promise: Promise) {} then( @@ -5192,57 +5211,57 @@ export class ReportingTaskPromise implements PromiseLike { /** 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))); + return new ReportingTaskPromiseImpl(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))); + return new ReportingTaskPromiseImpl(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))); + return new ReportingTaskPromiseImpl(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))); + return new ReportingTaskPromiseImpl(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } } // ============================================================================ -// IServiceProvider +// ServiceProvider // ============================================================================ -export interface IServiceProvider { +export interface ServiceProvider { toJSON(): MarshalledHandle; - getEventing(): IDistributedApplicationEventingPromise; - getLoggerFactory(): ILoggerFactoryPromise; - getResourceLoggerService(): IResourceLoggerServicePromise; - getDistributedApplicationModel(): IDistributedApplicationModelPromise; - getResourceNotificationService(): IResourceNotificationServicePromise; - getUserSecretsManager(): IUserSecretsManagerPromise; + getEventing(): DistributedApplicationEventingPromise; + getLoggerFactory(): LoggerFactoryPromise; + getResourceLoggerService(): ResourceLoggerServicePromise; + getDistributedApplicationModel(): DistributedApplicationModelPromise; + getResourceNotificationService(): ResourceNotificationServicePromise; + getUserSecretsManager(): UserSecretsManagerPromise; } -export interface IServiceProviderPromise extends PromiseLike { - getEventing(): IDistributedApplicationEventingPromise; - getLoggerFactory(): ILoggerFactoryPromise; - getResourceLoggerService(): IResourceLoggerServicePromise; - getDistributedApplicationModel(): IDistributedApplicationModelPromise; - getResourceNotificationService(): IResourceNotificationServicePromise; - getUserSecretsManager(): IUserSecretsManagerPromise; +export interface ServiceProviderPromise extends PromiseLike { + getEventing(): DistributedApplicationEventingPromise; + getLoggerFactory(): LoggerFactoryPromise; + getResourceLoggerService(): ResourceLoggerServicePromise; + getDistributedApplicationModel(): DistributedApplicationModelPromise; + getResourceNotificationService(): ResourceNotificationServicePromise; + getUserSecretsManager(): UserSecretsManagerPromise; } // ============================================================================ -// ServiceProvider +// ServiceProviderImpl // ============================================================================ /** * Type class for ServiceProvider. */ -export class ServiceProvider { +class ServiceProviderImpl implements ServiceProvider { constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -5256,11 +5275,11 @@ export class ServiceProvider { 'Aspire.Hosting/getEventing', rpcArgs ); - return new DistributedApplicationEventing(result, this._client); + return new DistributedApplicationEventingImpl(result, this._client); } getEventing(): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._getEventingInternal()); + return new DistributedApplicationEventingPromiseImpl(this._getEventingInternal()); } /** Gets the logger factory from the service provider */ @@ -5271,11 +5290,11 @@ export class ServiceProvider { 'Aspire.Hosting/getLoggerFactory', rpcArgs ); - return new LoggerFactory(result, this._client); + return new LoggerFactoryImpl(result, this._client); } getLoggerFactory(): LoggerFactoryPromise { - return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); + return new LoggerFactoryPromiseImpl(this._getLoggerFactoryInternal()); } /** Gets the resource logger service from the service provider */ @@ -5286,11 +5305,11 @@ export class ServiceProvider { 'Aspire.Hosting/getResourceLoggerService', rpcArgs ); - return new ResourceLoggerService(result, this._client); + return new ResourceLoggerServiceImpl(result, this._client); } getResourceLoggerService(): ResourceLoggerServicePromise { - return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); + return new ResourceLoggerServicePromiseImpl(this._getResourceLoggerServiceInternal()); } /** Gets the distributed application model from the service provider */ @@ -5301,11 +5320,11 @@ export class ServiceProvider { 'Aspire.Hosting/getDistributedApplicationModel', rpcArgs ); - return new DistributedApplicationModel(result, this._client); + return new DistributedApplicationModelImpl(result, this._client); } getDistributedApplicationModel(): DistributedApplicationModelPromise { - return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); + return new DistributedApplicationModelPromiseImpl(this._getDistributedApplicationModelInternal()); } /** Gets the resource notification service from the service provider */ @@ -5316,11 +5335,11 @@ export class ServiceProvider { 'Aspire.Hosting/getResourceNotificationService', rpcArgs ); - return new ResourceNotificationService(result, this._client); + return new ResourceNotificationServiceImpl(result, this._client); } getResourceNotificationService(): ResourceNotificationServicePromise { - return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); + return new ResourceNotificationServicePromiseImpl(this._getResourceNotificationServiceInternal()); } /** Gets the user secrets manager from the service provider */ @@ -5331,11 +5350,11 @@ export class ServiceProvider { 'Aspire.Hosting/getUserSecretsManager', rpcArgs ); - return new UserSecretsManager(result, this._client); + return new UserSecretsManagerImpl(result, this._client); } getUserSecretsManager(): UserSecretsManagerPromise { - return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); + return new UserSecretsManagerPromiseImpl(this._getUserSecretsManagerInternal()); } } @@ -5343,7 +5362,7 @@ export class ServiceProvider { /** * Thenable wrapper for ServiceProvider that enables fluent chaining. */ -export class ServiceProviderPromise implements PromiseLike { +class ServiceProviderPromiseImpl implements ServiceProviderPromise { constructor(private _promise: Promise) {} then( @@ -5355,41 +5374,41 @@ export class ServiceProviderPromise implements PromiseLike { /** Gets the distributed application eventing service from the service provider */ getEventing(): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); + return new DistributedApplicationEventingPromiseImpl(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())); + return new LoggerFactoryPromiseImpl(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())); + return new ResourceLoggerServicePromiseImpl(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())); + return new DistributedApplicationModelPromiseImpl(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())); + return new ResourceNotificationServicePromiseImpl(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())); + return new UserSecretsManagerPromiseImpl(this._promise.then(obj => obj.getUserSecretsManager())); } } // ============================================================================ -// IUserSecretsManager +// UserSecretsManager // ============================================================================ -export interface IUserSecretsManager { +export interface UserSecretsManager { toJSON(): MarshalledHandle; isAvailable: { get: () => Promise; @@ -5398,24 +5417,24 @@ export interface IUserSecretsManager { get: () => Promise; }; trySetSecret(name: string, value: string): Promise; - saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; - getOrSetSecret(resourceBuilder: IHandleReference, name: string, value: string): IUserSecretsManagerPromise; + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise; + getOrSetSecret(resourceBuilder: HandleReference, name: string, value: string): UserSecretsManagerPromise; } -export interface IUserSecretsManagerPromise extends PromiseLike { +export interface UserSecretsManagerPromise extends PromiseLike { trySetSecret(name: string, value: string): Promise; - saveStateJson(json: string, options?: SaveStateJsonOptions): IUserSecretsManagerPromise; - getOrSetSecret(resourceBuilder: IHandleReference, name: string, value: string): IUserSecretsManagerPromise; + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise; + getOrSetSecret(resourceBuilder: HandleReference, name: string, value: string): UserSecretsManagerPromise; } // ============================================================================ -// UserSecretsManager +// UserSecretsManagerImpl // ============================================================================ /** * Type class for UserSecretsManager. */ -export class UserSecretsManager { +class UserSecretsManagerImpl implements UserSecretsManager { constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ @@ -5452,7 +5471,7 @@ export class UserSecretsManager { /** Saves state to user secrets from a JSON string */ /** @internal */ - async _saveStateJsonInternal(json: string, cancellationToken?: AbortSignal | ICancellationToken): Promise { + 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( @@ -5464,12 +5483,12 @@ export class UserSecretsManager { saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { const cancellationToken = options?.cancellationToken; - return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + return new UserSecretsManagerPromiseImpl(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: IHandleReference, name: string, value: string): Promise { + async _getOrSetSecretInternal(resourceBuilder: HandleReference, name: string, value: string): Promise { const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; await this._client.invokeCapability( 'Aspire.Hosting/getOrSetSecret', @@ -5478,8 +5497,8 @@ export class UserSecretsManager { return this; } - getOrSetSecret(resourceBuilder: IHandleReference, name: string, value: string): UserSecretsManagerPromise { - return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); + getOrSetSecret(resourceBuilder: HandleReference, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromiseImpl(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } @@ -5487,7 +5506,7 @@ export class UserSecretsManager { /** * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class UserSecretsManagerPromise implements PromiseLike { +class UserSecretsManagerPromiseImpl implements UserSecretsManagerPromise { constructor(private _promise: Promise) {} then( @@ -5504,145 +5523,155 @@ export class UserSecretsManagerPromise implements PromiseLike obj.saveStateJson(json, options))); + return new UserSecretsManagerPromiseImpl(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: IHandleReference, name: string, value: string): UserSecretsManagerPromise { - return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); + getOrSetSecret(resourceBuilder: HandleReference, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromiseImpl(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } // ============================================================================ -// IConnectionStringResource +// ConnectionStringResource // ============================================================================ -export interface IConnectionStringResource { +export interface ConnectionStringResource { toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IConnectionStringResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; - withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; - getConnectionProperty(key: string): Promise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; - excludeFromManifest(): IConnectionStringResourcePromise; - waitFor(dependency: IHandleReference): IConnectionStringResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - waitForStart(dependency: IHandleReference): IConnectionStringResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - withExplicitStart(): IConnectionStringResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; - withHealthCheck(key: string): IConnectionStringResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; - withParentRelationship(parent: IHandleReference): IConnectionStringResourcePromise; - withChildRelationship(child: IHandleReference): IConnectionStringResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; - excludeFromMcp(): IConnectionStringResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + withContainerRegistry(registry: HandleReference): ConnectionStringResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise; + withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise; + withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise; + excludeFromManifest(): ConnectionStringResourcePromise; + waitFor(dependency: HandleReference): ConnectionStringResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise; + waitForStart(dependency: HandleReference): ConnectionStringResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise; + withExplicitStart(): ConnectionStringResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ConnectionStringResourcePromise; + withHealthCheck(key: string): ConnectionStringResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise; + withParentRelationship(parent: HandleReference): ConnectionStringResourcePromise; + withChildRelationship(child: HandleReference): ConnectionStringResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise; + excludeFromMcp(): ConnectionStringResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IConnectionStringResourcePromise; - withConfig(config: TestConfigDto): IConnectionStringResourcePromise; - withConnectionString(connectionString: IReferenceExpression): IConnectionStringResourcePromise; - withCreatedAt(createdAt: string): IConnectionStringResourcePromise; - withModifiedAt(modifiedAt: string): IConnectionStringResourcePromise; - withCorrelationId(correlationId: string): IConnectionStringResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IConnectionStringResourcePromise; - withStatus(status: TestResourceStatus): IConnectionStringResourcePromise; - withNestedConfig(config: TestNestedDto): IConnectionStringResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IConnectionStringResourcePromise; - testWaitFor(dependency: IHandleReference): IConnectionStringResourcePromise; - withConnectionStringDirect(connectionString: string): IConnectionStringResourcePromise; - withDependency(dependency: IHandleReference): IConnectionStringResourcePromise; - withEndpoints(endpoints: string[]): IConnectionStringResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IConnectionStringResourcePromise; -} - -export interface IConnectionStringResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IConnectionStringResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IConnectionStringResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IConnectionStringResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): IConnectionStringResourcePromise; - withConnectionPropertyValue(name: string, value: string): IConnectionStringResourcePromise; - getConnectionProperty(key: string): Promise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IConnectionStringResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IConnectionStringResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IConnectionStringResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IConnectionStringResourcePromise; - excludeFromManifest(): IConnectionStringResourcePromise; - waitFor(dependency: IHandleReference): IConnectionStringResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - waitForStart(dependency: IHandleReference): IConnectionStringResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IConnectionStringResourcePromise; - withExplicitStart(): IConnectionStringResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IConnectionStringResourcePromise; - withHealthCheck(key: string): IConnectionStringResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IConnectionStringResourcePromise; - withParentRelationship(parent: IHandleReference): IConnectionStringResourcePromise; - withChildRelationship(child: IHandleReference): IConnectionStringResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IConnectionStringResourcePromise; - excludeFromMcp(): IConnectionStringResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IConnectionStringResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IConnectionStringResourcePromise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise; + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ConnectionStringResourcePromise; + withConfig(config: TestConfigDto): ConnectionStringResourcePromise; + withConnectionString(connectionString: ReferenceExpression): ConnectionStringResourcePromise; + withCreatedAt(createdAt: string): ConnectionStringResourcePromise; + withModifiedAt(modifiedAt: string): ConnectionStringResourcePromise; + withCorrelationId(correlationId: string): ConnectionStringResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ConnectionStringResourcePromise; + withStatus(status: TestResourceStatus): ConnectionStringResourcePromise; + withNestedConfig(config: TestNestedDto): ConnectionStringResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ConnectionStringResourcePromise; + testWaitFor(dependency: HandleReference): ConnectionStringResourcePromise; + withConnectionStringDirect(connectionString: string): ConnectionStringResourcePromise; + withDependency(dependency: HandleReference): ConnectionStringResourcePromise; + withEndpoints(endpoints: string[]): ConnectionStringResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ConnectionStringResourcePromise; + withMergeLabel(label: string): ConnectionStringResourcePromise; + withMergeLabelCategorized(label: string, category: string): ConnectionStringResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ConnectionStringResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ConnectionStringResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ConnectionStringResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ConnectionStringResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ConnectionStringResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ConnectionStringResourcePromise; +} + +export interface ConnectionStringResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ConnectionStringResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise; + withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise; + withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise; + excludeFromManifest(): ConnectionStringResourcePromise; + waitFor(dependency: HandleReference): ConnectionStringResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise; + waitForStart(dependency: HandleReference): ConnectionStringResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise; + withExplicitStart(): ConnectionStringResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ConnectionStringResourcePromise; + withHealthCheck(key: string): ConnectionStringResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise; + withParentRelationship(parent: HandleReference): ConnectionStringResourcePromise; + withChildRelationship(child: HandleReference): ConnectionStringResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise; + excludeFromMcp(): ConnectionStringResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IConnectionStringResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IConnectionStringResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IConnectionStringResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IConnectionStringResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IConnectionStringResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IConnectionStringResourcePromise; - withConfig(config: TestConfigDto): IConnectionStringResourcePromise; - withConnectionString(connectionString: IReferenceExpression): IConnectionStringResourcePromise; - withCreatedAt(createdAt: string): IConnectionStringResourcePromise; - withModifiedAt(modifiedAt: string): IConnectionStringResourcePromise; - withCorrelationId(correlationId: string): IConnectionStringResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IConnectionStringResourcePromise; - withStatus(status: TestResourceStatus): IConnectionStringResourcePromise; - withNestedConfig(config: TestNestedDto): IConnectionStringResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IConnectionStringResourcePromise; - testWaitFor(dependency: IHandleReference): IConnectionStringResourcePromise; - withConnectionStringDirect(connectionString: string): IConnectionStringResourcePromise; - withDependency(dependency: IHandleReference): IConnectionStringResourcePromise; - withEndpoints(endpoints: string[]): IConnectionStringResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IConnectionStringResourcePromise; -} - -// ============================================================================ -// ConnectionStringResource -// ============================================================================ - -export class ConnectionStringResource extends ResourceBuilderBase { + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise; + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ConnectionStringResourcePromise; + withConfig(config: TestConfigDto): ConnectionStringResourcePromise; + withConnectionString(connectionString: ReferenceExpression): ConnectionStringResourcePromise; + withCreatedAt(createdAt: string): ConnectionStringResourcePromise; + withModifiedAt(modifiedAt: string): ConnectionStringResourcePromise; + withCorrelationId(correlationId: string): ConnectionStringResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ConnectionStringResourcePromise; + withStatus(status: TestResourceStatus): ConnectionStringResourcePromise; + withNestedConfig(config: TestNestedDto): ConnectionStringResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ConnectionStringResourcePromise; + testWaitFor(dependency: HandleReference): ConnectionStringResourcePromise; + withConnectionStringDirect(connectionString: string): ConnectionStringResourcePromise; + withDependency(dependency: HandleReference): ConnectionStringResourcePromise; + withEndpoints(endpoints: string[]): ConnectionStringResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ConnectionStringResourcePromise; + withMergeLabel(label: string): ConnectionStringResourcePromise; + withMergeLabelCategorized(label: string, category: string): ConnectionStringResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ConnectionStringResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ConnectionStringResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ConnectionStringResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ConnectionStringResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ConnectionStringResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ConnectionStringResourcePromise; +} + +// ============================================================================ +// ConnectionStringResourceImpl +// ============================================================================ + +class ConnectionStringResourceImpl extends ResourceBuilderBase implements ConnectionStringResource { constructor(handle: ConnectionStringResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -5654,14 +5683,14 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withConnectionPropertyInternal(name, value)); + withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withConnectionPropertyInternal(name, value)); } /** @internal */ @@ -5703,28 +5732,19 @@ export class ConnectionStringResource extends ResourceBuilderBase { - const rpcArgs: Record = { resource: this._handle, key }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getConnectionProperty', - rpcArgs - ); + return new ConnectionStringResourcePromiseImpl(this._withConnectionPropertyValueInternal(name, value)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -5732,32 +5752,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -5768,30 +5768,30 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { const displayText = options?.displayText; - return new ConnectionStringResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ConnectionStringResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -5805,12 +5805,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ConnectionStringResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ @@ -5820,72 +5820,72 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -5895,29 +5895,29 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { const exitCode = options?.exitCode; - return new ConnectionStringResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new ConnectionStringResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -5927,19 +5927,19 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -5948,43 +5948,43 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { const commandOptions = options?.commandOptions; - return new ConnectionStringResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ConnectionStringResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: IHandleReference): Promise { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -5995,13 +5995,13 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -6035,43 +6035,23 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ConnectionStringResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new ConnectionStringResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -6079,12 +6059,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -6097,10 +6077,10 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -6108,19 +6088,19 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -6128,19 +6108,19 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => Promise): Promise { + 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); + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -6148,19 +6128,19 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -6168,19 +6148,19 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -6188,12 +6168,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -6205,14 +6185,14 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withConnectionStringInternal(connectionString: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withConnectionStringInternal(connectionString)); + withConnectionString(connectionString: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withConnectionStringInternal(connectionString)); } /** @internal */ @@ -6252,12 +6232,12 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -6303,13 +6283,13 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -6354,27 +6334,27 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ @@ -6384,27 +6364,27 @@ export class ConnectionStringResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return new ConnectionStringResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -6414,16 +6394,16 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -6433,12 +6413,140 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ConnectionStringResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ConnectionStringResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ConnectionStringResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ConnectionStringResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new ConnectionStringResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -6448,7 +6556,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { +class ConnectionStringResourcePromiseImpl implements ConnectionStringResourcePromise { constructor(private _promise: Promise) {} then( @@ -6459,138 +6567,123 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value))); } /** Adds a connection property with a string value */ withConnectionPropertyValue(name: string, value: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** Gets a connection property by key */ - getConnectionProperty(key: string): Promise { - return this._promise.then(obj => obj.getConnectionProperty(key)); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -6599,214 +6692,266 @@ export class ConnectionStringResourcePromise implements PromiseLike Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionString(connectionString))); + withConnectionString(connectionString: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withConnectionString(connectionString))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Sets connection string using direct interface target */ withConnectionStringDirect(connectionString: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// IContainerRegistryResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface IContainerRegistryResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IContainerRegistryResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; - excludeFromManifest(): IContainerRegistryResourcePromise; - withExplicitStart(): IContainerRegistryResourcePromise; - withHealthCheck(key: string): IContainerRegistryResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; - withParentRelationship(parent: IHandleReference): IContainerRegistryResourcePromise; - withChildRelationship(child: IHandleReference): IContainerRegistryResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; - excludeFromMcp(): IContainerRegistryResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IContainerRegistryResourcePromise; - withConfig(config: TestConfigDto): IContainerRegistryResourcePromise; - withCreatedAt(createdAt: string): IContainerRegistryResourcePromise; - withModifiedAt(modifiedAt: string): IContainerRegistryResourcePromise; - withCorrelationId(correlationId: string): IContainerRegistryResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerRegistryResourcePromise; - withStatus(status: TestResourceStatus): IContainerRegistryResourcePromise; - withNestedConfig(config: TestNestedDto): IContainerRegistryResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerRegistryResourcePromise; - testWaitFor(dependency: IHandleReference): IContainerRegistryResourcePromise; - withDependency(dependency: IHandleReference): IContainerRegistryResourcePromise; - withEndpoints(endpoints: string[]): IContainerRegistryResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerRegistryResourcePromise; -} - -export interface IContainerRegistryResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IContainerRegistryResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerRegistryResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerRegistryResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerRegistryResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerRegistryResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerRegistryResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerRegistryResourcePromise; - excludeFromManifest(): IContainerRegistryResourcePromise; - withExplicitStart(): IContainerRegistryResourcePromise; - withHealthCheck(key: string): IContainerRegistryResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerRegistryResourcePromise; - withParentRelationship(parent: IHandleReference): IContainerRegistryResourcePromise; - withChildRelationship(child: IHandleReference): IContainerRegistryResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerRegistryResourcePromise; - excludeFromMcp(): IContainerRegistryResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerRegistryResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerRegistryResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerRegistryResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerRegistryResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerRegistryResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerRegistryResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IContainerRegistryResourcePromise; - withConfig(config: TestConfigDto): IContainerRegistryResourcePromise; - withCreatedAt(createdAt: string): IContainerRegistryResourcePromise; - withModifiedAt(modifiedAt: string): IContainerRegistryResourcePromise; - withCorrelationId(correlationId: string): IContainerRegistryResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerRegistryResourcePromise; - withStatus(status: TestResourceStatus): IContainerRegistryResourcePromise; - withNestedConfig(config: TestNestedDto): IContainerRegistryResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerRegistryResourcePromise; - testWaitFor(dependency: IHandleReference): IContainerRegistryResourcePromise; - withDependency(dependency: IHandleReference): IContainerRegistryResourcePromise; - withEndpoints(endpoints: string[]): IContainerRegistryResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerRegistryResourcePromise; } // ============================================================================ // ContainerRegistryResource // ============================================================================ -export class ContainerRegistryResource extends ResourceBuilderBase { +export interface ContainerRegistryResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): ContainerRegistryResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise; + excludeFromManifest(): ContainerRegistryResourcePromise; + withExplicitStart(): ContainerRegistryResourcePromise; + withHealthCheck(key: string): ContainerRegistryResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise; + withParentRelationship(parent: HandleReference): ContainerRegistryResourcePromise; + withChildRelationship(child: HandleReference): ContainerRegistryResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise; + excludeFromMcp(): ContainerRegistryResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ContainerRegistryResourcePromise; + withConfig(config: TestConfigDto): ContainerRegistryResourcePromise; + withCreatedAt(createdAt: string): ContainerRegistryResourcePromise; + withModifiedAt(modifiedAt: string): ContainerRegistryResourcePromise; + withCorrelationId(correlationId: string): ContainerRegistryResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ContainerRegistryResourcePromise; + withStatus(status: TestResourceStatus): ContainerRegistryResourcePromise; + withNestedConfig(config: TestNestedDto): ContainerRegistryResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerRegistryResourcePromise; + testWaitFor(dependency: HandleReference): ContainerRegistryResourcePromise; + withDependency(dependency: HandleReference): ContainerRegistryResourcePromise; + withEndpoints(endpoints: string[]): ContainerRegistryResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerRegistryResourcePromise; + withMergeLabel(label: string): ContainerRegistryResourcePromise; + withMergeLabelCategorized(label: string, category: string): ContainerRegistryResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ContainerRegistryResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerRegistryResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerRegistryResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerRegistryResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerRegistryResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerRegistryResourcePromise; +} + +export interface ContainerRegistryResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ContainerRegistryResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise; + excludeFromManifest(): ContainerRegistryResourcePromise; + withExplicitStart(): ContainerRegistryResourcePromise; + withHealthCheck(key: string): ContainerRegistryResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise; + withParentRelationship(parent: HandleReference): ContainerRegistryResourcePromise; + withChildRelationship(child: HandleReference): ContainerRegistryResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise; + excludeFromMcp(): ContainerRegistryResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ContainerRegistryResourcePromise; + withConfig(config: TestConfigDto): ContainerRegistryResourcePromise; + withCreatedAt(createdAt: string): ContainerRegistryResourcePromise; + withModifiedAt(modifiedAt: string): ContainerRegistryResourcePromise; + withCorrelationId(correlationId: string): ContainerRegistryResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ContainerRegistryResourcePromise; + withStatus(status: TestResourceStatus): ContainerRegistryResourcePromise; + withNestedConfig(config: TestNestedDto): ContainerRegistryResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerRegistryResourcePromise; + testWaitFor(dependency: HandleReference): ContainerRegistryResourcePromise; + withDependency(dependency: HandleReference): ContainerRegistryResourcePromise; + withEndpoints(endpoints: string[]): ContainerRegistryResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerRegistryResourcePromise; + withMergeLabel(label: string): ContainerRegistryResourcePromise; + withMergeLabelCategorized(label: string, category: string): ContainerRegistryResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ContainerRegistryResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerRegistryResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerRegistryResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerRegistryResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerRegistryResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerRegistryResourcePromise; +} + +// ============================================================================ +// ContainerRegistryResourceImpl +// ============================================================================ + +class ContainerRegistryResourceImpl extends ResourceBuilderBase implements ContainerRegistryResource { constructor(handle: ContainerRegistryResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -6818,14 +6963,14 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -6857,32 +7002,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -6893,30 +7018,30 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { const displayText = options?.displayText; - return new ContainerRegistryResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ContainerRegistryResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -6930,12 +7055,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ContainerRegistryResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ @@ -6945,12 +7070,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -6996,43 +7121,43 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { const commandOptions = options?.commandOptions; - return new ContainerRegistryResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ContainerRegistryResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: IHandleReference): Promise { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -7043,13 +7168,13 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -7083,43 +7208,23 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ContainerRegistryResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new ContainerRegistryResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -7127,12 +7232,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -7145,10 +7250,10 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -7156,19 +7261,19 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -7176,19 +7281,19 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -7196,19 +7301,19 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -7216,12 +7321,12 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -7233,14 +7338,14 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -7316,13 +7421,13 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -7367,42 +7472,42 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return new ContainerRegistryResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -7412,16 +7517,16 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -7431,22 +7536,150 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } -} - -/** + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerRegistryResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ContainerRegistryResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerRegistryResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ContainerRegistryResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new ContainerRegistryResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); + } + +} + +/** * Thenable wrapper for ContainerRegistryResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class ContainerRegistryResourcePromise implements PromiseLike { +class ContainerRegistryResourcePromiseImpl implements ContainerRegistryResourcePromise { constructor(private _promise: Promise) {} then( @@ -7457,98 +7690,88 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ withExplicitStart(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ withHealthCheck(key: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -7557,311 +7780,363 @@ export class ContainerRegistryResourcePromise implements PromiseLike Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// IContainerResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface IContainerResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IContainerResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; - withEntrypoint(entrypoint: string): IContainerResourcePromise; - withImageTag(tag: string): IContainerResourcePromise; - withImageRegistry(registry: string): IContainerResourcePromise; - withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; - withImageSHA256(sha256: string): IContainerResourcePromise; - withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; - withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; - publishAsContainer(): IContainerResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; - withContainerName(name: string): IContainerResourcePromise; - withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; - withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; - withContainerNetworkAlias(alias: string): IContainerResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; - withOtlpExporter(): IContainerResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; - publishAsConnectionString(): IContainerResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IContainerResourcePromise; - withArgs(args: string[]): IContainerResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IContainerResourcePromise; - withReferenceUri(name: string, uri: string): IContainerResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; - withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; - withExternalHttpEndpoints(): IContainerResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IContainerResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; - excludeFromManifest(): IContainerResourcePromise; - waitFor(dependency: IHandleReference): IContainerResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; - waitForStart(dependency: IHandleReference): IContainerResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; - withExplicitStart(): IContainerResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IContainerResourcePromise; - withHealthCheck(key: string): IContainerResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; - withoutHttpsCertificate(): IContainerResourcePromise; - withParentRelationship(parent: IHandleReference): IContainerResourcePromise; - withChildRelationship(child: IHandleReference): IContainerResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; - excludeFromMcp(): IContainerResourcePromise; - withRemoteImageName(remoteImageName: string): IContainerResourcePromise; - withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IContainerResourcePromise; - withConfig(config: TestConfigDto): IContainerResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IContainerResourcePromise; - withCreatedAt(createdAt: string): IContainerResourcePromise; - withModifiedAt(modifiedAt: string): IContainerResourcePromise; - withCorrelationId(correlationId: string): IContainerResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerResourcePromise; - withStatus(status: TestResourceStatus): IContainerResourcePromise; - withNestedConfig(config: TestNestedDto): IContainerResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerResourcePromise; - testWaitFor(dependency: IHandleReference): IContainerResourcePromise; - withDependency(dependency: IHandleReference): IContainerResourcePromise; - withEndpoints(endpoints: string[]): IContainerResourcePromise; - withEnvironmentVariables(variables: Record): IContainerResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerResourcePromise; -} - -export interface IContainerResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IContainerResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): IContainerResourcePromise; - withEntrypoint(entrypoint: string): IContainerResourcePromise; - withImageTag(tag: string): IContainerResourcePromise; - withImageRegistry(registry: string): IContainerResourcePromise; - withImage(image: string, options?: WithImageOptions): IContainerResourcePromise; - withImageSHA256(sha256: string): IContainerResourcePromise; - withContainerRuntimeArgs(args: string[]): IContainerResourcePromise; - withLifetime(lifetime: ContainerLifetime): IContainerResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): IContainerResourcePromise; - publishAsContainer(): IContainerResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): IContainerResourcePromise; - withContainerName(name: string): IContainerResourcePromise; - withBuildArg(name: string, value: IParameterResource): IContainerResourcePromise; - withBuildSecret(name: string, value: IParameterResource): IContainerResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): IContainerResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IContainerResourcePromise; - withContainerNetworkAlias(alias: string): IContainerResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IContainerResourcePromise; - withOtlpExporter(): IContainerResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IContainerResourcePromise; - publishAsConnectionString(): IContainerResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IContainerResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IContainerResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IContainerResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IContainerResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IContainerResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IContainerResourcePromise; - withArgs(args: string[]): IContainerResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IContainerResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IContainerResourcePromise; - withReferenceUri(name: string, uri: string): IContainerResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IContainerResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IContainerResourcePromise; - withEndpoint(options?: WithEndpointOptions): IContainerResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IContainerResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IContainerResourcePromise; - withExternalHttpEndpoints(): IContainerResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IContainerResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IContainerResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IContainerResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IContainerResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IContainerResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IContainerResourcePromise; - excludeFromManifest(): IContainerResourcePromise; - waitFor(dependency: IHandleReference): IContainerResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; - waitForStart(dependency: IHandleReference): IContainerResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IContainerResourcePromise; - withExplicitStart(): IContainerResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IContainerResourcePromise; - withHealthCheck(key: string): IContainerResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IContainerResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IContainerResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IContainerResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IContainerResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IContainerResourcePromise; - withoutHttpsCertificate(): IContainerResourcePromise; - withParentRelationship(parent: IHandleReference): IContainerResourcePromise; - withChildRelationship(child: IHandleReference): IContainerResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IContainerResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IContainerResourcePromise; - excludeFromMcp(): IContainerResourcePromise; - withRemoteImageName(remoteImageName: string): IContainerResourcePromise; - withRemoteImageTag(remoteImageTag: string): IContainerResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IContainerResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IContainerResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): IContainerResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IContainerResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IContainerResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IContainerResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IContainerResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IContainerResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IContainerResourcePromise; - withConfig(config: TestConfigDto): IContainerResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IContainerResourcePromise; - withCreatedAt(createdAt: string): IContainerResourcePromise; - withModifiedAt(modifiedAt: string): IContainerResourcePromise; - withCorrelationId(correlationId: string): IContainerResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IContainerResourcePromise; - withStatus(status: TestResourceStatus): IContainerResourcePromise; - withNestedConfig(config: TestNestedDto): IContainerResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IContainerResourcePromise; - testWaitFor(dependency: IHandleReference): IContainerResourcePromise; - withDependency(dependency: IHandleReference): IContainerResourcePromise; - withEndpoints(endpoints: string[]): IContainerResourcePromise; - withEnvironmentVariables(variables: Record): IContainerResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IContainerResourcePromise; } // ============================================================================ // ContainerResource // ============================================================================ -export class ContainerResource extends ResourceBuilderBase { +export interface ContainerResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): ContainerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise; + withEntrypoint(entrypoint: string): ContainerResourcePromise; + withImageTag(tag: string): ContainerResourcePromise; + withImageRegistry(registry: string): ContainerResourcePromise; + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise; + withImageSHA256(sha256: string): ContainerResourcePromise; + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise; + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise; + publishAsContainer(): ContainerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise; + withContainerName(name: string): ContainerResourcePromise; + withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise; + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise; + withContainerNetworkAlias(alias: string): ContainerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise; + withOtlpExporter(): ContainerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise; + publishAsConnectionString(): ContainerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise; + withEnvironment(name: string, value: string): ContainerResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ContainerResourcePromise; + withArgs(args: string[]): ContainerResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ContainerResourcePromise; + withReferenceUri(name: string, uri: string): ContainerResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): ContainerResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): ContainerResourcePromise; + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise; + withExternalHttpEndpoints(): ContainerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ContainerResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise; + excludeFromManifest(): ContainerResourcePromise; + waitFor(dependency: HandleReference): ContainerResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise; + waitForStart(dependency: HandleReference): ContainerResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise; + withExplicitStart(): ContainerResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise; + withHealthCheck(key: string): ContainerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise; + withoutHttpsCertificate(): ContainerResourcePromise; + withParentRelationship(parent: HandleReference): ContainerResourcePromise; + withChildRelationship(child: HandleReference): ContainerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise; + excludeFromMcp(): ContainerResourcePromise; + withRemoteImageName(remoteImageName: string): ContainerResourcePromise; + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ContainerResourcePromise; + withConfig(config: TestConfigDto): ContainerResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ContainerResourcePromise; + withCreatedAt(createdAt: string): ContainerResourcePromise; + withModifiedAt(modifiedAt: string): ContainerResourcePromise; + withCorrelationId(correlationId: string): ContainerResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ContainerResourcePromise; + withStatus(status: TestResourceStatus): ContainerResourcePromise; + withNestedConfig(config: TestNestedDto): ContainerResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerResourcePromise; + testWaitFor(dependency: HandleReference): ContainerResourcePromise; + withDependency(dependency: HandleReference): ContainerResourcePromise; + withEndpoints(endpoints: string[]): ContainerResourcePromise; + withEnvironmentVariables(variables: Record): ContainerResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerResourcePromise; + withMergeLabel(label: string): ContainerResourcePromise; + withMergeLabelCategorized(label: string, category: string): ContainerResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ContainerResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerResourcePromise; +} + +export interface ContainerResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ContainerResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise; + withEntrypoint(entrypoint: string): ContainerResourcePromise; + withImageTag(tag: string): ContainerResourcePromise; + withImageRegistry(registry: string): ContainerResourcePromise; + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise; + withImageSHA256(sha256: string): ContainerResourcePromise; + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise; + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise; + publishAsContainer(): ContainerResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise; + withContainerName(name: string): ContainerResourcePromise; + withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise; + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise; + withContainerNetworkAlias(alias: string): ContainerResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise; + withOtlpExporter(): ContainerResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise; + publishAsConnectionString(): ContainerResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise; + withEnvironment(name: string, value: string): ContainerResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ContainerResourcePromise; + withArgs(args: string[]): ContainerResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ContainerResourcePromise; + withReferenceUri(name: string, uri: string): ContainerResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): ContainerResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): ContainerResourcePromise; + withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise; + withExternalHttpEndpoints(): ContainerResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ContainerResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise; + excludeFromManifest(): ContainerResourcePromise; + waitFor(dependency: HandleReference): ContainerResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise; + waitForStart(dependency: HandleReference): ContainerResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise; + withExplicitStart(): ContainerResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise; + withHealthCheck(key: string): ContainerResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise; + withoutHttpsCertificate(): ContainerResourcePromise; + withParentRelationship(parent: HandleReference): ContainerResourcePromise; + withChildRelationship(child: HandleReference): ContainerResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise; + excludeFromMcp(): ContainerResourcePromise; + withRemoteImageName(remoteImageName: string): ContainerResourcePromise; + withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ContainerResourcePromise; + withConfig(config: TestConfigDto): ContainerResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ContainerResourcePromise; + withCreatedAt(createdAt: string): ContainerResourcePromise; + withModifiedAt(modifiedAt: string): ContainerResourcePromise; + withCorrelationId(correlationId: string): ContainerResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ContainerResourcePromise; + withStatus(status: TestResourceStatus): ContainerResourcePromise; + withNestedConfig(config: TestNestedDto): ContainerResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerResourcePromise; + testWaitFor(dependency: HandleReference): ContainerResourcePromise; + withDependency(dependency: HandleReference): ContainerResourcePromise; + withEndpoints(endpoints: string[]): ContainerResourcePromise; + withEnvironmentVariables(variables: Record): ContainerResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerResourcePromise; + withMergeLabel(label: string): ContainerResourcePromise; + withMergeLabelCategorized(label: string, category: string): ContainerResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ContainerResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerResourcePromise; +} + +// ============================================================================ +// ContainerResourceImpl +// ============================================================================ + +class ContainerResourceImpl extends ResourceBuilderBase implements ContainerResource { constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -7872,13 +8147,13 @@ export class ContainerResource extends ResourceBuilderBase { + 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', + 'Aspire.Hosting/withBuildArg', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); + withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { + 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', + 'Aspire.Hosting/withBuildSecret', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withBuildSecretInternal(name, value)); } /** @internal */ @@ -8089,12 +8364,12 @@ export class ContainerResource extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -8299,19 +8589,19 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -8319,36 +8609,16 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -8357,15 +8627,15 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -8428,7 +8698,7 @@ export class ContainerResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -8525,19 +8795,19 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -8545,32 +8815,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -8581,30 +8831,30 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { const displayText = options?.displayText; - return new ContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ContainerResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -8618,19 +8868,19 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ContainerResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -8638,12 +8888,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ @@ -8653,72 +8903,72 @@ export class ContainerResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -8728,29 +8978,29 @@ export class ContainerResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise { const exitCode = options?.exitCode; - return new ContainerResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new ContainerResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -8760,12 +9010,12 @@ export class ContainerResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -8802,13 +9052,13 @@ export class ContainerResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ContainerResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { const commandOptions = options?.commandOptions; - return new ContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ContainerResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -8818,12 +9068,12 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { const password = options?.password; - return new ContainerResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new ContainerResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -8865,42 +9115,42 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -8911,13 +9161,13 @@ export class ContainerResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -9010,43 +9260,23 @@ export class ContainerResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new ContainerResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -9054,12 +9284,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -9071,14 +9301,14 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -9102,19 +9332,19 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -9122,19 +9352,19 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -9142,19 +9372,19 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -9162,19 +9392,19 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -9182,12 +9412,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -9199,14 +9429,14 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -9236,12 +9466,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -9251,12 +9481,12 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -9302,13 +9532,13 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -9353,42 +9583,42 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -9398,12 +9628,12 @@ export class ContainerResource extends ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentVariablesInternal(variables)); + return new ContainerResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -9432,12 +9662,140 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ContainerResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ContainerResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new ContainerResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -9447,7 +9805,7 @@ export class ContainerResource extends ResourceBuilderBase { +class ContainerResourcePromiseImpl implements ContainerResourcePromise { constructor(private _promise: Promise) {} then( @@ -9458,363 +9816,353 @@ export class ContainerResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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())); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name))); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value))); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new ContainerResourcePromiseImpl(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())); + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ withArgs(args: string[]): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(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))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options))); } /** Gets the resource name */ @@ -9823,298 +10171,350 @@ export class ContainerResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ContainerResourcePromise { + return new ContainerResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// ICSharpAppResource +// CSharpAppResource // ============================================================================ -export interface ICSharpAppResource { +export interface CSharpAppResource { toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): ICSharpAppResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; - withOtlpExporter(): ICSharpAppResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; - withReplicas(replicas: number): ICSharpAppResourcePromise; - disableForwardedHeaders(): ICSharpAppResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ICSharpAppResourcePromise; - withArgs(args: string[]): ICSharpAppResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ICSharpAppResourcePromise; - withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; - withExternalHttpEndpoints(): ICSharpAppResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ICSharpAppResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; - publishWithContainerFiles(source: IHandleReference, destinationPath: string): ICSharpAppResourcePromise; - excludeFromManifest(): ICSharpAppResourcePromise; - waitFor(dependency: IHandleReference): ICSharpAppResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - waitForStart(dependency: IHandleReference): ICSharpAppResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - withExplicitStart(): ICSharpAppResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; - withHealthCheck(key: string): ICSharpAppResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; - withoutHttpsCertificate(): ICSharpAppResourcePromise; - withParentRelationship(parent: IHandleReference): ICSharpAppResourcePromise; - withChildRelationship(child: IHandleReference): ICSharpAppResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; - excludeFromMcp(): ICSharpAppResourcePromise; - withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; - withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + withContainerRegistry(registry: HandleReference): CSharpAppResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise; + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise; + withOtlpExporter(): CSharpAppResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise; + withReplicas(replicas: number): CSharpAppResourcePromise; + disableForwardedHeaders(): CSharpAppResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise; + withEnvironment(name: string, value: string): CSharpAppResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): CSharpAppResourcePromise; + withArgs(args: string[]): CSharpAppResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): CSharpAppResourcePromise; + withReferenceUri(name: string, uri: string): CSharpAppResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): CSharpAppResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): CSharpAppResourcePromise; + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise; + withExternalHttpEndpoints(): CSharpAppResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): CSharpAppResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise; + withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): CSharpAppResourcePromise; + publishWithContainerFiles(source: HandleReference, destinationPath: string): CSharpAppResourcePromise; + excludeFromManifest(): CSharpAppResourcePromise; + waitFor(dependency: HandleReference): CSharpAppResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise; + waitForStart(dependency: HandleReference): CSharpAppResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise; + withExplicitStart(): CSharpAppResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise; + withHealthCheck(key: string): CSharpAppResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise; + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise; + withoutHttpsCertificate(): CSharpAppResourcePromise; + withParentRelationship(parent: HandleReference): CSharpAppResourcePromise; + withChildRelationship(child: HandleReference): CSharpAppResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise; + excludeFromMcp(): CSharpAppResourcePromise; + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise; + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ICSharpAppResourcePromise; - withConfig(config: TestConfigDto): ICSharpAppResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ICSharpAppResourcePromise; - withCreatedAt(createdAt: string): ICSharpAppResourcePromise; - withModifiedAt(modifiedAt: string): ICSharpAppResourcePromise; - withCorrelationId(correlationId: string): ICSharpAppResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ICSharpAppResourcePromise; - withStatus(status: TestResourceStatus): ICSharpAppResourcePromise; - withNestedConfig(config: TestNestedDto): ICSharpAppResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ICSharpAppResourcePromise; - testWaitFor(dependency: IHandleReference): ICSharpAppResourcePromise; - withDependency(dependency: IHandleReference): ICSharpAppResourcePromise; - withEndpoints(endpoints: string[]): ICSharpAppResourcePromise; - withEnvironmentVariables(variables: Record): ICSharpAppResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ICSharpAppResourcePromise; -} - -export interface ICSharpAppResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): ICSharpAppResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ICSharpAppResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ICSharpAppResourcePromise; - withOtlpExporter(): ICSharpAppResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ICSharpAppResourcePromise; - withReplicas(replicas: number): ICSharpAppResourcePromise; - disableForwardedHeaders(): ICSharpAppResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): ICSharpAppResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ICSharpAppResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ICSharpAppResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ICSharpAppResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ICSharpAppResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ICSharpAppResourcePromise; - withArgs(args: string[]): ICSharpAppResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ICSharpAppResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ICSharpAppResourcePromise; - withReferenceUri(name: string, uri: string): ICSharpAppResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ICSharpAppResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ICSharpAppResourcePromise; - withEndpoint(options?: WithEndpointOptions): ICSharpAppResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ICSharpAppResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ICSharpAppResourcePromise; - withExternalHttpEndpoints(): ICSharpAppResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ICSharpAppResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ICSharpAppResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ICSharpAppResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ICSharpAppResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ICSharpAppResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ICSharpAppResourcePromise; - publishWithContainerFiles(source: IHandleReference, destinationPath: string): ICSharpAppResourcePromise; - excludeFromManifest(): ICSharpAppResourcePromise; - waitFor(dependency: IHandleReference): ICSharpAppResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - waitForStart(dependency: IHandleReference): ICSharpAppResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ICSharpAppResourcePromise; - withExplicitStart(): ICSharpAppResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ICSharpAppResourcePromise; - withHealthCheck(key: string): ICSharpAppResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ICSharpAppResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ICSharpAppResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ICSharpAppResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ICSharpAppResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ICSharpAppResourcePromise; - withoutHttpsCertificate(): ICSharpAppResourcePromise; - withParentRelationship(parent: IHandleReference): ICSharpAppResourcePromise; - withChildRelationship(child: IHandleReference): ICSharpAppResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ICSharpAppResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ICSharpAppResourcePromise; - excludeFromMcp(): ICSharpAppResourcePromise; - withRemoteImageName(remoteImageName: string): ICSharpAppResourcePromise; - withRemoteImageTag(remoteImageTag: string): ICSharpAppResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ICSharpAppResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ICSharpAppResourcePromise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): CSharpAppResourcePromise; + withConfig(config: TestConfigDto): CSharpAppResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): CSharpAppResourcePromise; + withCreatedAt(createdAt: string): CSharpAppResourcePromise; + withModifiedAt(modifiedAt: string): CSharpAppResourcePromise; + withCorrelationId(correlationId: string): CSharpAppResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): CSharpAppResourcePromise; + withStatus(status: TestResourceStatus): CSharpAppResourcePromise; + withNestedConfig(config: TestNestedDto): CSharpAppResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): CSharpAppResourcePromise; + testWaitFor(dependency: HandleReference): CSharpAppResourcePromise; + withDependency(dependency: HandleReference): CSharpAppResourcePromise; + withEndpoints(endpoints: string[]): CSharpAppResourcePromise; + withEnvironmentVariables(variables: Record): CSharpAppResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): CSharpAppResourcePromise; + withMergeLabel(label: string): CSharpAppResourcePromise; + withMergeLabelCategorized(label: string, category: string): CSharpAppResourcePromise; + withMergeEndpoint(endpointName: string, port: number): CSharpAppResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): CSharpAppResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): CSharpAppResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): CSharpAppResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): CSharpAppResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): CSharpAppResourcePromise; +} + +export interface CSharpAppResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): CSharpAppResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise; + withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise; + withOtlpExporter(): CSharpAppResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise; + withReplicas(replicas: number): CSharpAppResourcePromise; + disableForwardedHeaders(): CSharpAppResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise; + withEnvironment(name: string, value: string): CSharpAppResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): CSharpAppResourcePromise; + withArgs(args: string[]): CSharpAppResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): CSharpAppResourcePromise; + withReferenceUri(name: string, uri: string): CSharpAppResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): CSharpAppResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): CSharpAppResourcePromise; + withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise; + withExternalHttpEndpoints(): CSharpAppResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): CSharpAppResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise; + withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): CSharpAppResourcePromise; + publishWithContainerFiles(source: HandleReference, destinationPath: string): CSharpAppResourcePromise; + excludeFromManifest(): CSharpAppResourcePromise; + waitFor(dependency: HandleReference): CSharpAppResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise; + waitForStart(dependency: HandleReference): CSharpAppResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise; + withExplicitStart(): CSharpAppResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise; + withHealthCheck(key: string): CSharpAppResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise; + withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise; + withoutHttpsCertificate(): CSharpAppResourcePromise; + withParentRelationship(parent: HandleReference): CSharpAppResourcePromise; + withChildRelationship(child: HandleReference): CSharpAppResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise; + excludeFromMcp(): CSharpAppResourcePromise; + withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise; + withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ICSharpAppResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ICSharpAppResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ICSharpAppResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ICSharpAppResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ICSharpAppResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ICSharpAppResourcePromise; - withConfig(config: TestConfigDto): ICSharpAppResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ICSharpAppResourcePromise; - withCreatedAt(createdAt: string): ICSharpAppResourcePromise; - withModifiedAt(modifiedAt: string): ICSharpAppResourcePromise; - withCorrelationId(correlationId: string): ICSharpAppResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ICSharpAppResourcePromise; - withStatus(status: TestResourceStatus): ICSharpAppResourcePromise; - withNestedConfig(config: TestNestedDto): ICSharpAppResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ICSharpAppResourcePromise; - testWaitFor(dependency: IHandleReference): ICSharpAppResourcePromise; - withDependency(dependency: IHandleReference): ICSharpAppResourcePromise; - withEndpoints(endpoints: string[]): ICSharpAppResourcePromise; - withEnvironmentVariables(variables: Record): ICSharpAppResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ICSharpAppResourcePromise; -} - -// ============================================================================ -// CSharpAppResource -// ============================================================================ - -export class CSharpAppResource extends ResourceBuilderBase { + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): CSharpAppResourcePromise; + withConfig(config: TestConfigDto): CSharpAppResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): CSharpAppResourcePromise; + withCreatedAt(createdAt: string): CSharpAppResourcePromise; + withModifiedAt(modifiedAt: string): CSharpAppResourcePromise; + withCorrelationId(correlationId: string): CSharpAppResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): CSharpAppResourcePromise; + withStatus(status: TestResourceStatus): CSharpAppResourcePromise; + withNestedConfig(config: TestNestedDto): CSharpAppResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): CSharpAppResourcePromise; + testWaitFor(dependency: HandleReference): CSharpAppResourcePromise; + withDependency(dependency: HandleReference): CSharpAppResourcePromise; + withEndpoints(endpoints: string[]): CSharpAppResourcePromise; + withEnvironmentVariables(variables: Record): CSharpAppResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): CSharpAppResourcePromise; + withMergeLabel(label: string): CSharpAppResourcePromise; + withMergeLabelCategorized(label: string, category: string): CSharpAppResourcePromise; + withMergeEndpoint(endpointName: string, port: number): CSharpAppResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): CSharpAppResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): CSharpAppResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): CSharpAppResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): CSharpAppResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): CSharpAppResourcePromise; +} + +// ============================================================================ +// CSharpAppResourceImpl +// ============================================================================ + +class CSharpAppResourceImpl extends ResourceBuilderBase implements CSharpAppResource { constructor(handle: CSharpAppResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -10126,14 +10526,14 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + 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); + const obj = new ContainerResourceImpl(objHandle, this._client); await configure(obj); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -10228,13 +10628,13 @@ export class CSharpAppResource extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -10341,19 +10756,19 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -10361,36 +10776,16 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -10399,15 +10794,15 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -10470,7 +10865,7 @@ export class CSharpAppResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -10567,19 +10962,19 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -10587,32 +10982,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -10623,30 +10998,30 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { const displayText = options?.displayText; - return new CSharpAppResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new CSharpAppResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -10660,19 +11035,19 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new CSharpAppResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -10680,27 +11055,27 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _publishWithContainerFilesInternal(source: IHandleReference, destinationPath: string): Promise { + private async _publishWithContainerFilesInternal(source: HandleReference, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFilesFromResource', + 'Aspire.Hosting/publishWithContainerFiles', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IHandleReference, destinationPath: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + publishWithContainerFiles(source: HandleReference, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._publishWithContainerFilesInternal(source, destinationPath)); } /** @internal */ @@ -10710,72 +11085,72 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -10785,29 +11160,29 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise { const exitCode = options?.exitCode; - return new CSharpAppResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new CSharpAppResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -10817,12 +11192,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -10859,13 +11234,13 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { const commandOptions = options?.commandOptions; - return new CSharpAppResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new CSharpAppResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -10875,12 +11250,12 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { const password = options?.password; - return new CSharpAppResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new CSharpAppResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -10922,42 +11297,42 @@ export class CSharpAppResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -10968,13 +11343,13 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -11067,43 +11442,23 @@ export class CSharpAppResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new CSharpAppResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new CSharpAppResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -11111,12 +11466,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -11129,10 +11484,10 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -11140,19 +11495,19 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -11160,19 +11515,19 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -11180,19 +11535,19 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -11200,19 +11555,19 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -11220,12 +11575,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -11237,14 +11592,14 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -11274,12 +11629,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -11289,12 +11644,12 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -11340,13 +11695,13 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -11391,42 +11746,42 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new CSharpAppResource(result, this._client); + return new CSharpAppResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -11436,12 +11791,12 @@ export class CSharpAppResource extends ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentVariablesInternal(variables)); + return new CSharpAppResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -11470,12 +11825,140 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): CSharpAppResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new CSharpAppResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): CSharpAppResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new CSharpAppResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new CSharpAppResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -11485,7 +11968,7 @@ export class CSharpAppResource extends ResourceBuilderBase { +class CSharpAppResourcePromiseImpl implements CSharpAppResourcePromise { constructor(private _promise: Promise) {} then( @@ -11496,293 +11979,283 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } /** Sets the number of replicas */ withReplicas(replicas: number): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReplicas(replicas))); } /** Disables forwarded headers for the project */ disableForwardedHeaders(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.disableForwardedHeaders())); } /** Publishes a project as a Docker file with optional container configuration */ publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(options))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ withArgs(args: string[]): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IHandleReference, destinationPath: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + publishWithContainerFiles(source: HandleReference, destinationPath: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -11791,310 +12264,362 @@ export class CSharpAppResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// IDotnetToolResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface IDotnetToolResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IDotnetToolResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; - withToolPackage(packageId: string): IDotnetToolResourcePromise; - withToolVersion(version: string): IDotnetToolResourcePromise; - withToolPrerelease(): IDotnetToolResourcePromise; - withToolSource(source: string): IDotnetToolResourcePromise; - withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; - withToolIgnoreFailedSources(): IDotnetToolResourcePromise; - publishAsDockerFile(): IDotnetToolResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; - withExecutableCommand(command: string): IDotnetToolResourcePromise; - withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; - withOtlpExporter(): IDotnetToolResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IDotnetToolResourcePromise; - withArgs(args: string[]): IDotnetToolResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IDotnetToolResourcePromise; - withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; - withExternalHttpEndpoints(): IDotnetToolResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IDotnetToolResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; - excludeFromManifest(): IDotnetToolResourcePromise; - waitFor(dependency: IHandleReference): IDotnetToolResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - waitForStart(dependency: IHandleReference): IDotnetToolResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - withExplicitStart(): IDotnetToolResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; - withHealthCheck(key: string): IDotnetToolResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; - withoutHttpsCertificate(): IDotnetToolResourcePromise; - withParentRelationship(parent: IHandleReference): IDotnetToolResourcePromise; - withChildRelationship(child: IHandleReference): IDotnetToolResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; - excludeFromMcp(): IDotnetToolResourcePromise; - withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; - withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IDotnetToolResourcePromise; - withConfig(config: TestConfigDto): IDotnetToolResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IDotnetToolResourcePromise; - withCreatedAt(createdAt: string): IDotnetToolResourcePromise; - withModifiedAt(modifiedAt: string): IDotnetToolResourcePromise; - withCorrelationId(correlationId: string): IDotnetToolResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IDotnetToolResourcePromise; - withStatus(status: TestResourceStatus): IDotnetToolResourcePromise; - withNestedConfig(config: TestNestedDto): IDotnetToolResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IDotnetToolResourcePromise; - testWaitFor(dependency: IHandleReference): IDotnetToolResourcePromise; - withDependency(dependency: IHandleReference): IDotnetToolResourcePromise; - withEndpoints(endpoints: string[]): IDotnetToolResourcePromise; - withEnvironmentVariables(variables: Record): IDotnetToolResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IDotnetToolResourcePromise; -} - -export interface IDotnetToolResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IDotnetToolResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IDotnetToolResourcePromise; - withToolPackage(packageId: string): IDotnetToolResourcePromise; - withToolVersion(version: string): IDotnetToolResourcePromise; - withToolPrerelease(): IDotnetToolResourcePromise; - withToolSource(source: string): IDotnetToolResourcePromise; - withToolIgnoreExistingFeeds(): IDotnetToolResourcePromise; - withToolIgnoreFailedSources(): IDotnetToolResourcePromise; - publishAsDockerFile(): IDotnetToolResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IDotnetToolResourcePromise; - withExecutableCommand(command: string): IDotnetToolResourcePromise; - withWorkingDirectory(workingDirectory: string): IDotnetToolResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IDotnetToolResourcePromise; - withOtlpExporter(): IDotnetToolResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IDotnetToolResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IDotnetToolResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IDotnetToolResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IDotnetToolResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IDotnetToolResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IDotnetToolResourcePromise; - withArgs(args: string[]): IDotnetToolResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IDotnetToolResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IDotnetToolResourcePromise; - withReferenceUri(name: string, uri: string): IDotnetToolResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IDotnetToolResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IDotnetToolResourcePromise; - withEndpoint(options?: WithEndpointOptions): IDotnetToolResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IDotnetToolResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IDotnetToolResourcePromise; - withExternalHttpEndpoints(): IDotnetToolResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IDotnetToolResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IDotnetToolResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IDotnetToolResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IDotnetToolResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IDotnetToolResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IDotnetToolResourcePromise; - excludeFromManifest(): IDotnetToolResourcePromise; - waitFor(dependency: IHandleReference): IDotnetToolResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - waitForStart(dependency: IHandleReference): IDotnetToolResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IDotnetToolResourcePromise; - withExplicitStart(): IDotnetToolResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IDotnetToolResourcePromise; - withHealthCheck(key: string): IDotnetToolResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IDotnetToolResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IDotnetToolResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IDotnetToolResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IDotnetToolResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IDotnetToolResourcePromise; - withoutHttpsCertificate(): IDotnetToolResourcePromise; - withParentRelationship(parent: IHandleReference): IDotnetToolResourcePromise; - withChildRelationship(child: IHandleReference): IDotnetToolResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IDotnetToolResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IDotnetToolResourcePromise; - excludeFromMcp(): IDotnetToolResourcePromise; - withRemoteImageName(remoteImageName: string): IDotnetToolResourcePromise; - withRemoteImageTag(remoteImageTag: string): IDotnetToolResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IDotnetToolResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IDotnetToolResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IDotnetToolResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IDotnetToolResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IDotnetToolResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IDotnetToolResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IDotnetToolResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IDotnetToolResourcePromise; - withConfig(config: TestConfigDto): IDotnetToolResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IDotnetToolResourcePromise; - withCreatedAt(createdAt: string): IDotnetToolResourcePromise; - withModifiedAt(modifiedAt: string): IDotnetToolResourcePromise; - withCorrelationId(correlationId: string): IDotnetToolResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IDotnetToolResourcePromise; - withStatus(status: TestResourceStatus): IDotnetToolResourcePromise; - withNestedConfig(config: TestNestedDto): IDotnetToolResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IDotnetToolResourcePromise; - testWaitFor(dependency: IHandleReference): IDotnetToolResourcePromise; - withDependency(dependency: IHandleReference): IDotnetToolResourcePromise; - withEndpoints(endpoints: string[]): IDotnetToolResourcePromise; - withEnvironmentVariables(variables: Record): IDotnetToolResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IDotnetToolResourcePromise; } // ============================================================================ // DotnetToolResource // ============================================================================ -export class DotnetToolResource extends ResourceBuilderBase { +export interface DotnetToolResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): DotnetToolResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise; + withToolPackage(packageId: string): DotnetToolResourcePromise; + withToolVersion(version: string): DotnetToolResourcePromise; + withToolPrerelease(): DotnetToolResourcePromise; + withToolSource(source: string): DotnetToolResourcePromise; + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise; + withToolIgnoreFailedSources(): DotnetToolResourcePromise; + publishAsDockerFile(): DotnetToolResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise; + withExecutableCommand(command: string): DotnetToolResourcePromise; + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise; + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise; + withOtlpExporter(): DotnetToolResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise; + withEnvironment(name: string, value: string): DotnetToolResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): DotnetToolResourcePromise; + withArgs(args: string[]): DotnetToolResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): DotnetToolResourcePromise; + withReferenceUri(name: string, uri: string): DotnetToolResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): DotnetToolResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): DotnetToolResourcePromise; + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise; + withExternalHttpEndpoints(): DotnetToolResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): DotnetToolResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise; + withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DotnetToolResourcePromise; + excludeFromManifest(): DotnetToolResourcePromise; + waitFor(dependency: HandleReference): DotnetToolResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise; + waitForStart(dependency: HandleReference): DotnetToolResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise; + withExplicitStart(): DotnetToolResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): DotnetToolResourcePromise; + withHealthCheck(key: string): DotnetToolResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise; + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise; + withoutHttpsCertificate(): DotnetToolResourcePromise; + withParentRelationship(parent: HandleReference): DotnetToolResourcePromise; + withChildRelationship(child: HandleReference): DotnetToolResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise; + excludeFromMcp(): DotnetToolResourcePromise; + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise; + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): DotnetToolResourcePromise; + withConfig(config: TestConfigDto): DotnetToolResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): DotnetToolResourcePromise; + withCreatedAt(createdAt: string): DotnetToolResourcePromise; + withModifiedAt(modifiedAt: string): DotnetToolResourcePromise; + withCorrelationId(correlationId: string): DotnetToolResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): DotnetToolResourcePromise; + withStatus(status: TestResourceStatus): DotnetToolResourcePromise; + withNestedConfig(config: TestNestedDto): DotnetToolResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): DotnetToolResourcePromise; + testWaitFor(dependency: HandleReference): DotnetToolResourcePromise; + withDependency(dependency: HandleReference): DotnetToolResourcePromise; + withEndpoints(endpoints: string[]): DotnetToolResourcePromise; + withEnvironmentVariables(variables: Record): DotnetToolResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): DotnetToolResourcePromise; + withMergeLabel(label: string): DotnetToolResourcePromise; + withMergeLabelCategorized(label: string, category: string): DotnetToolResourcePromise; + withMergeEndpoint(endpointName: string, port: number): DotnetToolResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): DotnetToolResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): DotnetToolResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): DotnetToolResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): DotnetToolResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): DotnetToolResourcePromise; +} + +export interface DotnetToolResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): DotnetToolResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise; + withToolPackage(packageId: string): DotnetToolResourcePromise; + withToolVersion(version: string): DotnetToolResourcePromise; + withToolPrerelease(): DotnetToolResourcePromise; + withToolSource(source: string): DotnetToolResourcePromise; + withToolIgnoreExistingFeeds(): DotnetToolResourcePromise; + withToolIgnoreFailedSources(): DotnetToolResourcePromise; + publishAsDockerFile(): DotnetToolResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise; + withExecutableCommand(command: string): DotnetToolResourcePromise; + withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise; + withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise; + withOtlpExporter(): DotnetToolResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise; + withEnvironment(name: string, value: string): DotnetToolResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): DotnetToolResourcePromise; + withArgs(args: string[]): DotnetToolResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): DotnetToolResourcePromise; + withReferenceUri(name: string, uri: string): DotnetToolResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): DotnetToolResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): DotnetToolResourcePromise; + withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise; + withExternalHttpEndpoints(): DotnetToolResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): DotnetToolResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise; + withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DotnetToolResourcePromise; + excludeFromManifest(): DotnetToolResourcePromise; + waitFor(dependency: HandleReference): DotnetToolResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise; + waitForStart(dependency: HandleReference): DotnetToolResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise; + withExplicitStart(): DotnetToolResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): DotnetToolResourcePromise; + withHealthCheck(key: string): DotnetToolResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise; + withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise; + withoutHttpsCertificate(): DotnetToolResourcePromise; + withParentRelationship(parent: HandleReference): DotnetToolResourcePromise; + withChildRelationship(child: HandleReference): DotnetToolResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise; + excludeFromMcp(): DotnetToolResourcePromise; + withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise; + withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): DotnetToolResourcePromise; + withConfig(config: TestConfigDto): DotnetToolResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): DotnetToolResourcePromise; + withCreatedAt(createdAt: string): DotnetToolResourcePromise; + withModifiedAt(modifiedAt: string): DotnetToolResourcePromise; + withCorrelationId(correlationId: string): DotnetToolResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): DotnetToolResourcePromise; + withStatus(status: TestResourceStatus): DotnetToolResourcePromise; + withNestedConfig(config: TestNestedDto): DotnetToolResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): DotnetToolResourcePromise; + testWaitFor(dependency: HandleReference): DotnetToolResourcePromise; + withDependency(dependency: HandleReference): DotnetToolResourcePromise; + withEndpoints(endpoints: string[]): DotnetToolResourcePromise; + withEnvironmentVariables(variables: Record): DotnetToolResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): DotnetToolResourcePromise; + withMergeLabel(label: string): DotnetToolResourcePromise; + withMergeLabelCategorized(label: string, category: string): DotnetToolResourcePromise; + withMergeEndpoint(endpointName: string, port: number): DotnetToolResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): DotnetToolResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): DotnetToolResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): DotnetToolResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): DotnetToolResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): DotnetToolResourcePromise; +} + +// ============================================================================ +// DotnetToolResourceImpl +// ============================================================================ + +class DotnetToolResourceImpl extends ResourceBuilderBase implements DotnetToolResource { constructor(handle: DotnetToolResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -12106,14 +12631,14 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + 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); + const obj = new ContainerResourceImpl(objHandle, this._client); await configure(obj); }); const rpcArgs: Record = { builder: this._handle, configure: configureId }; @@ -12233,12 +12758,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._publishAsDockerFileWithConfigureInternal(configure)); } /** @internal */ @@ -12248,12 +12773,12 @@ export class DotnetToolResource extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -12424,19 +12964,19 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -12444,36 +12984,16 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -12482,15 +13002,15 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -12553,7 +13073,7 @@ export class DotnetToolResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -12650,19 +13170,19 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -12670,32 +13190,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -12706,30 +13206,30 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { const displayText = options?.displayText; - return new DotnetToolResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new DotnetToolResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -12743,19 +13243,19 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new DotnetToolResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -12763,12 +13263,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ @@ -12778,72 +13278,72 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -12853,29 +13353,29 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): DotnetToolResourcePromise { const exitCode = options?.exitCode; - return new DotnetToolResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new DotnetToolResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -12885,12 +13385,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -12927,13 +13427,13 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { const commandOptions = options?.commandOptions; - return new DotnetToolResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new DotnetToolResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -12943,12 +13443,12 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { const password = options?.password; - return new DotnetToolResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new DotnetToolResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -12990,42 +13490,42 @@ export class DotnetToolResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -13036,13 +13536,13 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -13135,43 +13635,23 @@ export class DotnetToolResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new DotnetToolResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new DotnetToolResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -13179,12 +13659,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -13197,10 +13677,10 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -13208,19 +13688,19 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -13228,19 +13708,19 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -13248,19 +13728,19 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -13268,19 +13748,19 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -13288,12 +13768,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -13305,14 +13785,14 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -13342,12 +13822,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -13357,12 +13837,12 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -13408,13 +13888,13 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -13459,42 +13939,42 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new DotnetToolResource(result, this._client); + return new DotnetToolResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -13504,12 +13984,12 @@ export class DotnetToolResource extends ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentVariablesInternal(variables)); + return new DotnetToolResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -13538,349 +14018,467 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } -} - -/** - * Thenable wrapper for DotnetToolResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class DotnetToolResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + /** Adds a label to the resource */ + withMergeLabel(label: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): DotnetToolResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new DotnetToolResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): DotnetToolResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new DotnetToolResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new DotnetToolResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); + } + +} + +/** + * Thenable wrapper for DotnetToolResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +class DotnetToolResourcePromiseImpl implements DotnetToolResourcePromise { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DotnetToolResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Sets the tool package ID */ withToolPackage(packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPackage(packageId))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolPackage(packageId))); } /** Sets the tool version */ withToolVersion(version: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolVersion(version))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolVersion(version))); } /** Allows prerelease tool versions */ withToolPrerelease(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolPrerelease())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolPrerelease())); } /** Adds a NuGet source for the tool */ withToolSource(source: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolSource(source))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolSource(source))); } /** Ignores existing NuGet feeds */ withToolIgnoreExistingFeeds(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreExistingFeeds())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolIgnoreExistingFeeds())); } /** Ignores failed NuGet sources */ withToolIgnoreFailedSources(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withToolIgnoreFailedSources())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withToolIgnoreFailedSources())); } /** Publishes the executable as a Docker container */ publishAsDockerFile(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile())); } /** Publishes an executable as a Docker file with optional container configuration */ - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); } /** Sets the executable command */ withExecutableCommand(command: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withExecutableCommand(command))); } /** Sets the executable working directory */ withWorkingDirectory(workingDirectory: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); } /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ withArgs(args: string[]): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -13889,298 +14487,350 @@ export class DotnetToolResourcePromise implements PromiseLike Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// IExecutableResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface IExecutableResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IExecutableResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; - publishAsDockerFile(): IExecutableResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; - withExecutableCommand(command: string): IExecutableResourcePromise; - withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; - withOtlpExporter(): IExecutableResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IExecutableResourcePromise; - withArgs(args: string[]): IExecutableResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IExecutableResourcePromise; - withReferenceUri(name: string, uri: string): IExecutableResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; - withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; - withExternalHttpEndpoints(): IExecutableResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IExecutableResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; - excludeFromManifest(): IExecutableResourcePromise; - waitFor(dependency: IHandleReference): IExecutableResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; - waitForStart(dependency: IHandleReference): IExecutableResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; - withExplicitStart(): IExecutableResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IExecutableResourcePromise; - withHealthCheck(key: string): IExecutableResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; - withoutHttpsCertificate(): IExecutableResourcePromise; - withParentRelationship(parent: IHandleReference): IExecutableResourcePromise; - withChildRelationship(child: IHandleReference): IExecutableResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; - excludeFromMcp(): IExecutableResourcePromise; - withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; - withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IExecutableResourcePromise; - withConfig(config: TestConfigDto): IExecutableResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IExecutableResourcePromise; - withCreatedAt(createdAt: string): IExecutableResourcePromise; - withModifiedAt(modifiedAt: string): IExecutableResourcePromise; - withCorrelationId(correlationId: string): IExecutableResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IExecutableResourcePromise; - withStatus(status: TestResourceStatus): IExecutableResourcePromise; - withNestedConfig(config: TestNestedDto): IExecutableResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IExecutableResourcePromise; - testWaitFor(dependency: IHandleReference): IExecutableResourcePromise; - withDependency(dependency: IHandleReference): IExecutableResourcePromise; - withEndpoints(endpoints: string[]): IExecutableResourcePromise; - withEnvironmentVariables(variables: Record): IExecutableResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExecutableResourcePromise; -} - -export interface IExecutableResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IExecutableResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExecutableResourcePromise; - publishAsDockerFile(): IExecutableResourcePromise; - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): IExecutableResourcePromise; - withExecutableCommand(command: string): IExecutableResourcePromise; - withWorkingDirectory(workingDirectory: string): IExecutableResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IExecutableResourcePromise; - withOtlpExporter(): IExecutableResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IExecutableResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExecutableResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IExecutableResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IExecutableResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IExecutableResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IExecutableResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IExecutableResourcePromise; - withArgs(args: string[]): IExecutableResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IExecutableResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IExecutableResourcePromise; - withReferenceUri(name: string, uri: string): IExecutableResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IExecutableResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IExecutableResourcePromise; - withEndpoint(options?: WithEndpointOptions): IExecutableResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IExecutableResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IExecutableResourcePromise; - withExternalHttpEndpoints(): IExecutableResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IExecutableResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExecutableResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExecutableResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExecutableResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExecutableResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IExecutableResourcePromise; - excludeFromManifest(): IExecutableResourcePromise; - waitFor(dependency: IHandleReference): IExecutableResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; - waitForStart(dependency: IHandleReference): IExecutableResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IExecutableResourcePromise; - withExplicitStart(): IExecutableResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IExecutableResourcePromise; - withHealthCheck(key: string): IExecutableResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IExecutableResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExecutableResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IExecutableResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IExecutableResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IExecutableResourcePromise; - withoutHttpsCertificate(): IExecutableResourcePromise; - withParentRelationship(parent: IHandleReference): IExecutableResourcePromise; - withChildRelationship(child: IHandleReference): IExecutableResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExecutableResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IExecutableResourcePromise; - excludeFromMcp(): IExecutableResourcePromise; - withRemoteImageName(remoteImageName: string): IExecutableResourcePromise; - withRemoteImageTag(remoteImageTag: string): IExecutableResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExecutableResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExecutableResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExecutableResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExecutableResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExecutableResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IExecutableResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExecutableResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IExecutableResourcePromise; - withConfig(config: TestConfigDto): IExecutableResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IExecutableResourcePromise; - withCreatedAt(createdAt: string): IExecutableResourcePromise; - withModifiedAt(modifiedAt: string): IExecutableResourcePromise; - withCorrelationId(correlationId: string): IExecutableResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IExecutableResourcePromise; - withStatus(status: TestResourceStatus): IExecutableResourcePromise; - withNestedConfig(config: TestNestedDto): IExecutableResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IExecutableResourcePromise; - testWaitFor(dependency: IHandleReference): IExecutableResourcePromise; - withDependency(dependency: IHandleReference): IExecutableResourcePromise; - withEndpoints(endpoints: string[]): IExecutableResourcePromise; - withEnvironmentVariables(variables: Record): IExecutableResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExecutableResourcePromise; } // ============================================================================ // ExecutableResource // ============================================================================ -export class ExecutableResource extends ResourceBuilderBase { +export interface ExecutableResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): ExecutableResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise; + publishAsDockerFile(): ExecutableResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise; + withExecutableCommand(command: string): ExecutableResourcePromise; + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise; + withOtlpExporter(): ExecutableResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise; + withEnvironment(name: string, value: string): ExecutableResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ExecutableResourcePromise; + withArgs(args: string[]): ExecutableResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ExecutableResourcePromise; + withReferenceUri(name: string, uri: string): ExecutableResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): ExecutableResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): ExecutableResourcePromise; + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise; + withExternalHttpEndpoints(): ExecutableResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ExecutableResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise; + excludeFromManifest(): ExecutableResourcePromise; + waitFor(dependency: HandleReference): ExecutableResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise; + waitForStart(dependency: HandleReference): ExecutableResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise; + withExplicitStart(): ExecutableResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ExecutableResourcePromise; + withHealthCheck(key: string): ExecutableResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise; + withoutHttpsCertificate(): ExecutableResourcePromise; + withParentRelationship(parent: HandleReference): ExecutableResourcePromise; + withChildRelationship(child: HandleReference): ExecutableResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise; + excludeFromMcp(): ExecutableResourcePromise; + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise; + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ExecutableResourcePromise; + withConfig(config: TestConfigDto): ExecutableResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ExecutableResourcePromise; + withCreatedAt(createdAt: string): ExecutableResourcePromise; + withModifiedAt(modifiedAt: string): ExecutableResourcePromise; + withCorrelationId(correlationId: string): ExecutableResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ExecutableResourcePromise; + withStatus(status: TestResourceStatus): ExecutableResourcePromise; + withNestedConfig(config: TestNestedDto): ExecutableResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ExecutableResourcePromise; + testWaitFor(dependency: HandleReference): ExecutableResourcePromise; + withDependency(dependency: HandleReference): ExecutableResourcePromise; + withEndpoints(endpoints: string[]): ExecutableResourcePromise; + withEnvironmentVariables(variables: Record): ExecutableResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExecutableResourcePromise; + withMergeLabel(label: string): ExecutableResourcePromise; + withMergeLabelCategorized(label: string, category: string): ExecutableResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ExecutableResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExecutableResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExecutableResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExecutableResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ExecutableResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExecutableResourcePromise; +} + +export interface ExecutableResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ExecutableResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise; + publishAsDockerFile(): ExecutableResourcePromise; + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise; + withExecutableCommand(command: string): ExecutableResourcePromise; + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise; + withOtlpExporter(): ExecutableResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise; + withEnvironment(name: string, value: string): ExecutableResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ExecutableResourcePromise; + withArgs(args: string[]): ExecutableResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ExecutableResourcePromise; + withReferenceUri(name: string, uri: string): ExecutableResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): ExecutableResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): ExecutableResourcePromise; + withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise; + withExternalHttpEndpoints(): ExecutableResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ExecutableResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise; + excludeFromManifest(): ExecutableResourcePromise; + waitFor(dependency: HandleReference): ExecutableResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise; + waitForStart(dependency: HandleReference): ExecutableResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise; + withExplicitStart(): ExecutableResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ExecutableResourcePromise; + withHealthCheck(key: string): ExecutableResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise; + withoutHttpsCertificate(): ExecutableResourcePromise; + withParentRelationship(parent: HandleReference): ExecutableResourcePromise; + withChildRelationship(child: HandleReference): ExecutableResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise; + excludeFromMcp(): ExecutableResourcePromise; + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise; + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ExecutableResourcePromise; + withConfig(config: TestConfigDto): ExecutableResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ExecutableResourcePromise; + withCreatedAt(createdAt: string): ExecutableResourcePromise; + withModifiedAt(modifiedAt: string): ExecutableResourcePromise; + withCorrelationId(correlationId: string): ExecutableResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ExecutableResourcePromise; + withStatus(status: TestResourceStatus): ExecutableResourcePromise; + withNestedConfig(config: TestNestedDto): ExecutableResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ExecutableResourcePromise; + testWaitFor(dependency: HandleReference): ExecutableResourcePromise; + withDependency(dependency: HandleReference): ExecutableResourcePromise; + withEndpoints(endpoints: string[]): ExecutableResourcePromise; + withEnvironmentVariables(variables: Record): ExecutableResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExecutableResourcePromise; + withMergeLabel(label: string): ExecutableResourcePromise; + withMergeLabelCategorized(label: string, category: string): ExecutableResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ExecutableResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExecutableResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExecutableResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExecutableResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ExecutableResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExecutableResourcePromise; +} + +// ============================================================================ +// ExecutableResourceImpl +// ============================================================================ + +class ExecutableResourceImpl extends ResourceBuilderBase implements ExecutableResource { constructor(handle: ExecutableResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -14192,14 +14842,14 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + 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); + const obj = new ContainerResourceImpl(objHandle, this._client); await configure(obj); }); const rpcArgs: Record = { builder: this._handle, configure: configureId }; @@ -14229,12 +14879,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._publishAsDockerFileWithConfigureInternal(configure)); } /** @internal */ @@ -14244,12 +14894,12 @@ export class ExecutableResource extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -14420,19 +15085,19 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -14440,36 +15105,16 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -14478,15 +15123,15 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -14549,7 +15194,7 @@ export class ExecutableResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -14646,19 +15291,19 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -14666,32 +15311,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -14702,30 +15327,30 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { const displayText = options?.displayText; - return new ExecutableResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ExecutableResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -14739,19 +15364,19 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ExecutableResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -14759,12 +15384,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ @@ -14774,72 +15399,72 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -14849,29 +15474,29 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ExecutableResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ExecutableResourcePromise { const exitCode = options?.exitCode; - return new ExecutableResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new ExecutableResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -14881,12 +15506,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -14923,13 +15548,13 @@ export class ExecutableResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ExecutableResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { const commandOptions = options?.commandOptions; - return new ExecutableResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ExecutableResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -14939,12 +15564,12 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { const password = options?.password; - return new ExecutableResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new ExecutableResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -14986,42 +15611,42 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -15032,13 +15657,13 @@ export class ExecutableResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -15131,43 +15756,23 @@ export class ExecutableResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new ExecutableResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -15175,12 +15780,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -15193,10 +15798,10 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -15204,19 +15809,19 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -15224,19 +15829,19 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -15244,19 +15849,19 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -15264,19 +15869,19 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -15284,12 +15889,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -15301,14 +15906,14 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -15338,12 +15943,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -15353,12 +15958,12 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -15404,13 +16009,13 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -15455,42 +16060,42 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new ExecutableResource(result, this._client); + return new ExecutableResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -15500,12 +16105,12 @@ export class ExecutableResource extends ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentVariablesInternal(variables)); + return new ExecutableResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -15534,12 +16139,140 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExecutableResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ExecutableResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExecutableResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ExecutableResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new ExecutableResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -15549,7 +16282,7 @@ export class ExecutableResource extends ResourceBuilderBase { +class ExecutableResourcePromiseImpl implements ExecutableResourcePromise { constructor(private _promise: Promise) {} then( @@ -15560,293 +16293,283 @@ export class ExecutableResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Publishes the executable as a Docker container */ publishAsDockerFile(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile())); } /** Publishes an executable as a Docker file with optional container configuration */ - publishAsDockerFileWithConfigure(configure: (obj: IContainerResource) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(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))); + return new ExecutableResourcePromiseImpl(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))); + return new ExecutableResourcePromiseImpl(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))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ withArgs(args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -15855,216 +16578,268 @@ export class ExecutableResourcePromise implements PromiseLike Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// IExternalServiceResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExecutableResourcePromise { + return new ExecutableResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface IExternalServiceResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IExternalServiceResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; - withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; - excludeFromManifest(): IExternalServiceResourcePromise; - withExplicitStart(): IExternalServiceResourcePromise; - withHealthCheck(key: string): IExternalServiceResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; - withParentRelationship(parent: IHandleReference): IExternalServiceResourcePromise; - withChildRelationship(child: IHandleReference): IExternalServiceResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; - excludeFromMcp(): IExternalServiceResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IExternalServiceResourcePromise; - withConfig(config: TestConfigDto): IExternalServiceResourcePromise; - withCreatedAt(createdAt: string): IExternalServiceResourcePromise; - withModifiedAt(modifiedAt: string): IExternalServiceResourcePromise; - withCorrelationId(correlationId: string): IExternalServiceResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IExternalServiceResourcePromise; - withStatus(status: TestResourceStatus): IExternalServiceResourcePromise; - withNestedConfig(config: TestNestedDto): IExternalServiceResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IExternalServiceResourcePromise; - testWaitFor(dependency: IHandleReference): IExternalServiceResourcePromise; - withDependency(dependency: IHandleReference): IExternalServiceResourcePromise; - withEndpoints(endpoints: string[]): IExternalServiceResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExternalServiceResourcePromise; -} - -export interface IExternalServiceResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IExternalServiceResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IExternalServiceResourcePromise; - withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): IExternalServiceResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IExternalServiceResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IExternalServiceResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IExternalServiceResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IExternalServiceResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IExternalServiceResourcePromise; - excludeFromManifest(): IExternalServiceResourcePromise; - withExplicitStart(): IExternalServiceResourcePromise; - withHealthCheck(key: string): IExternalServiceResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IExternalServiceResourcePromise; - withParentRelationship(parent: IHandleReference): IExternalServiceResourcePromise; - withChildRelationship(child: IHandleReference): IExternalServiceResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IExternalServiceResourcePromise; - excludeFromMcp(): IExternalServiceResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IExternalServiceResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IExternalServiceResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IExternalServiceResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IExternalServiceResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IExternalServiceResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IExternalServiceResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IExternalServiceResourcePromise; - withConfig(config: TestConfigDto): IExternalServiceResourcePromise; - withCreatedAt(createdAt: string): IExternalServiceResourcePromise; - withModifiedAt(modifiedAt: string): IExternalServiceResourcePromise; - withCorrelationId(correlationId: string): IExternalServiceResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IExternalServiceResourcePromise; - withStatus(status: TestResourceStatus): IExternalServiceResourcePromise; - withNestedConfig(config: TestNestedDto): IExternalServiceResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IExternalServiceResourcePromise; - testWaitFor(dependency: IHandleReference): IExternalServiceResourcePromise; - withDependency(dependency: IHandleReference): IExternalServiceResourcePromise; - withEndpoints(endpoints: string[]): IExternalServiceResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IExternalServiceResourcePromise; } // ============================================================================ // ExternalServiceResource // ============================================================================ -export class ExternalServiceResource extends ResourceBuilderBase { +export interface ExternalServiceResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): ExternalServiceResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise; + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise; + excludeFromManifest(): ExternalServiceResourcePromise; + withExplicitStart(): ExternalServiceResourcePromise; + withHealthCheck(key: string): ExternalServiceResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise; + withParentRelationship(parent: HandleReference): ExternalServiceResourcePromise; + withChildRelationship(child: HandleReference): ExternalServiceResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise; + excludeFromMcp(): ExternalServiceResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ExternalServiceResourcePromise; + withConfig(config: TestConfigDto): ExternalServiceResourcePromise; + withCreatedAt(createdAt: string): ExternalServiceResourcePromise; + withModifiedAt(modifiedAt: string): ExternalServiceResourcePromise; + withCorrelationId(correlationId: string): ExternalServiceResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ExternalServiceResourcePromise; + withStatus(status: TestResourceStatus): ExternalServiceResourcePromise; + withNestedConfig(config: TestNestedDto): ExternalServiceResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ExternalServiceResourcePromise; + testWaitFor(dependency: HandleReference): ExternalServiceResourcePromise; + withDependency(dependency: HandleReference): ExternalServiceResourcePromise; + withEndpoints(endpoints: string[]): ExternalServiceResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExternalServiceResourcePromise; + withMergeLabel(label: string): ExternalServiceResourcePromise; + withMergeLabelCategorized(label: string, category: string): ExternalServiceResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ExternalServiceResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExternalServiceResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExternalServiceResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExternalServiceResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ExternalServiceResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExternalServiceResourcePromise; +} + +export interface ExternalServiceResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ExternalServiceResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise; + withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise; + excludeFromManifest(): ExternalServiceResourcePromise; + withExplicitStart(): ExternalServiceResourcePromise; + withHealthCheck(key: string): ExternalServiceResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise; + withParentRelationship(parent: HandleReference): ExternalServiceResourcePromise; + withChildRelationship(child: HandleReference): ExternalServiceResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise; + excludeFromMcp(): ExternalServiceResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ExternalServiceResourcePromise; + withConfig(config: TestConfigDto): ExternalServiceResourcePromise; + withCreatedAt(createdAt: string): ExternalServiceResourcePromise; + withModifiedAt(modifiedAt: string): ExternalServiceResourcePromise; + withCorrelationId(correlationId: string): ExternalServiceResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ExternalServiceResourcePromise; + withStatus(status: TestResourceStatus): ExternalServiceResourcePromise; + withNestedConfig(config: TestNestedDto): ExternalServiceResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ExternalServiceResourcePromise; + testWaitFor(dependency: HandleReference): ExternalServiceResourcePromise; + withDependency(dependency: HandleReference): ExternalServiceResourcePromise; + withEndpoints(endpoints: string[]): ExternalServiceResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExternalServiceResourcePromise; + withMergeLabel(label: string): ExternalServiceResourcePromise; + withMergeLabelCategorized(label: string, category: string): ExternalServiceResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ExternalServiceResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExternalServiceResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExternalServiceResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExternalServiceResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ExternalServiceResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExternalServiceResourcePromise; +} + +// ============================================================================ +// ExternalServiceResourceImpl +// ============================================================================ + +class ExternalServiceResourceImpl extends ResourceBuilderBase implements ExternalServiceResource { constructor(handle: ExternalServiceResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -16076,14 +16851,14 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -16134,32 +16909,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -16170,30 +16925,30 @@ export class ExternalServiceResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { const displayText = options?.displayText; - return new ExternalServiceResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ExternalServiceResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -16207,12 +16962,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ExternalServiceResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ @@ -16222,12 +16977,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -16273,43 +17028,43 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { const commandOptions = options?.commandOptions; - return new ExternalServiceResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ExternalServiceResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: IHandleReference): Promise { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -16320,13 +17075,13 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -16360,43 +17115,23 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ExternalServiceResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new ExternalServiceResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -16404,12 +17139,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -16422,10 +17157,10 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -16433,19 +17168,19 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -16453,19 +17188,19 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -16473,19 +17208,19 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -16493,12 +17228,12 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -16510,14 +17245,14 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -16593,13 +17328,13 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -16644,42 +17379,42 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return new ExternalServiceResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -16689,16 +17424,16 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -16708,12 +17443,140 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExternalServiceResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ExternalServiceResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExternalServiceResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ExternalServiceResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new ExternalServiceResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -16723,7 +17586,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { +class ExternalServiceResourcePromiseImpl implements ExternalServiceResourcePromise { constructor(private _promise: Promise) {} then( @@ -16734,103 +17597,93 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds an HTTP health check to an external service */ withExternalServiceHttpHealthCheck(options?: WithExternalServiceHttpHealthCheckOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExternalServiceHttpHealthCheck(options))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withExternalServiceHttpHealthCheck(options))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ withExplicitStart(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ withHealthCheck(key: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -16839,201 +17692,253 @@ export class ExternalServiceResourcePromise implements PromiseLike Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// IParameterResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface IParameterResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IParameterResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; - withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; - excludeFromManifest(): IParameterResourcePromise; - withExplicitStart(): IParameterResourcePromise; - withHealthCheck(key: string): IParameterResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; - withParentRelationship(parent: IHandleReference): IParameterResourcePromise; - withChildRelationship(child: IHandleReference): IParameterResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; - excludeFromMcp(): IParameterResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IParameterResourcePromise; - withConfig(config: TestConfigDto): IParameterResourcePromise; - withCreatedAt(createdAt: string): IParameterResourcePromise; - withModifiedAt(modifiedAt: string): IParameterResourcePromise; - withCorrelationId(correlationId: string): IParameterResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IParameterResourcePromise; - withStatus(status: TestResourceStatus): IParameterResourcePromise; - withNestedConfig(config: TestNestedDto): IParameterResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IParameterResourcePromise; - testWaitFor(dependency: IHandleReference): IParameterResourcePromise; - withDependency(dependency: IHandleReference): IParameterResourcePromise; - withEndpoints(endpoints: string[]): IParameterResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IParameterResourcePromise; -} - -export interface IParameterResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IParameterResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IParameterResourcePromise; - withDescription(description: string, options?: WithDescriptionOptions): IParameterResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IParameterResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IParameterResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IParameterResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IParameterResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IParameterResourcePromise; - excludeFromManifest(): IParameterResourcePromise; - withExplicitStart(): IParameterResourcePromise; - withHealthCheck(key: string): IParameterResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IParameterResourcePromise; - withParentRelationship(parent: IHandleReference): IParameterResourcePromise; - withChildRelationship(child: IHandleReference): IParameterResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IParameterResourcePromise; - excludeFromMcp(): IParameterResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IParameterResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IParameterResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IParameterResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IParameterResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IParameterResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IParameterResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IParameterResourcePromise; - withConfig(config: TestConfigDto): IParameterResourcePromise; - withCreatedAt(createdAt: string): IParameterResourcePromise; - withModifiedAt(modifiedAt: string): IParameterResourcePromise; - withCorrelationId(correlationId: string): IParameterResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IParameterResourcePromise; - withStatus(status: TestResourceStatus): IParameterResourcePromise; - withNestedConfig(config: TestNestedDto): IParameterResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IParameterResourcePromise; - testWaitFor(dependency: IHandleReference): IParameterResourcePromise; - withDependency(dependency: IHandleReference): IParameterResourcePromise; - withEndpoints(endpoints: string[]): IParameterResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IParameterResourcePromise; } // ============================================================================ // ParameterResource // ============================================================================ -export class ParameterResource extends ResourceBuilderBase { +export interface ParameterResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): ParameterResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise; + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise; + excludeFromManifest(): ParameterResourcePromise; + withExplicitStart(): ParameterResourcePromise; + withHealthCheck(key: string): ParameterResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise; + withParentRelationship(parent: HandleReference): ParameterResourcePromise; + withChildRelationship(child: HandleReference): ParameterResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise; + excludeFromMcp(): ParameterResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ParameterResourcePromise; + withConfig(config: TestConfigDto): ParameterResourcePromise; + withCreatedAt(createdAt: string): ParameterResourcePromise; + withModifiedAt(modifiedAt: string): ParameterResourcePromise; + withCorrelationId(correlationId: string): ParameterResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ParameterResourcePromise; + withStatus(status: TestResourceStatus): ParameterResourcePromise; + withNestedConfig(config: TestNestedDto): ParameterResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ParameterResourcePromise; + testWaitFor(dependency: HandleReference): ParameterResourcePromise; + withDependency(dependency: HandleReference): ParameterResourcePromise; + withEndpoints(endpoints: string[]): ParameterResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ParameterResourcePromise; + withMergeLabel(label: string): ParameterResourcePromise; + withMergeLabelCategorized(label: string, category: string): ParameterResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ParameterResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ParameterResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ParameterResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ParameterResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ParameterResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ParameterResourcePromise; +} + +export interface ParameterResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ParameterResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise; + withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise; + excludeFromManifest(): ParameterResourcePromise; + withExplicitStart(): ParameterResourcePromise; + withHealthCheck(key: string): ParameterResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise; + withParentRelationship(parent: HandleReference): ParameterResourcePromise; + withChildRelationship(child: HandleReference): ParameterResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise; + excludeFromMcp(): ParameterResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ParameterResourcePromise; + withConfig(config: TestConfigDto): ParameterResourcePromise; + withCreatedAt(createdAt: string): ParameterResourcePromise; + withModifiedAt(modifiedAt: string): ParameterResourcePromise; + withCorrelationId(correlationId: string): ParameterResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ParameterResourcePromise; + withStatus(status: TestResourceStatus): ParameterResourcePromise; + withNestedConfig(config: TestNestedDto): ParameterResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ParameterResourcePromise; + testWaitFor(dependency: HandleReference): ParameterResourcePromise; + withDependency(dependency: HandleReference): ParameterResourcePromise; + withEndpoints(endpoints: string[]): ParameterResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ParameterResourcePromise; + withMergeLabel(label: string): ParameterResourcePromise; + withMergeLabelCategorized(label: string, category: string): ParameterResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ParameterResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ParameterResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ParameterResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ParameterResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ParameterResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ParameterResourcePromise; +} + +// ============================================================================ +// ParameterResourceImpl +// ============================================================================ + +class ParameterResourceImpl extends ResourceBuilderBase implements ParameterResource { constructor(handle: ParameterResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -17045,14 +17950,14 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -17101,32 +18006,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -17137,30 +18022,30 @@ export class ParameterResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { const displayText = options?.displayText; - return new ParameterResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ParameterResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -17174,12 +18059,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ParameterResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ @@ -17189,12 +18074,12 @@ export class ParameterResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -17240,43 +18125,43 @@ export class ParameterResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): ParameterResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { const commandOptions = options?.commandOptions; - return new ParameterResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ParameterResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: IHandleReference): Promise { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -17287,13 +18172,13 @@ export class ParameterResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -17327,43 +18212,23 @@ export class ParameterResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new ParameterResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -17371,12 +18236,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -17389,10 +18254,10 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -17400,19 +18265,19 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -17420,19 +18285,19 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -17440,19 +18305,19 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -17460,12 +18325,12 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -17477,14 +18342,14 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -17560,13 +18425,13 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -17611,42 +18476,42 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new ParameterResource(result, this._client); + return new ParameterResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -17656,16 +18521,16 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -17675,12 +18540,140 @@ export class ParameterResource extends ResourceBuilderBase Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ParameterResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ParameterResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ParameterResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ParameterResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new ParameterResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -17690,7 +18683,7 @@ export class ParameterResource extends ResourceBuilderBase { +class ParameterResourcePromiseImpl implements ParameterResourcePromise { constructor(private _promise: Promise) {} then( @@ -17701,103 +18694,93 @@ export class ParameterResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Sets a parameter description */ withDescription(description: string, options?: WithDescriptionOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withDescription(description, options))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withDescription(description, options))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ withExplicitStart(): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ withHealthCheck(key: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -17806,283 +18789,335 @@ export class ParameterResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// IProjectResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ParameterResourcePromise { + return new ParameterResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface IProjectResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IProjectResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; - withOtlpExporter(): IProjectResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; - withReplicas(replicas: number): IProjectResourcePromise; - disableForwardedHeaders(): IProjectResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IProjectResourcePromise; - withArgs(args: string[]): IProjectResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IProjectResourcePromise; - withReferenceUri(name: string, uri: string): IProjectResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; - withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; - withExternalHttpEndpoints(): IProjectResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IProjectResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; - publishWithContainerFiles(source: IHandleReference, destinationPath: string): IProjectResourcePromise; - excludeFromManifest(): IProjectResourcePromise; - waitFor(dependency: IHandleReference): IProjectResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; - waitForStart(dependency: IHandleReference): IProjectResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; - withExplicitStart(): IProjectResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IProjectResourcePromise; - withHealthCheck(key: string): IProjectResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; - withoutHttpsCertificate(): IProjectResourcePromise; - withParentRelationship(parent: IHandleReference): IProjectResourcePromise; - withChildRelationship(child: IHandleReference): IProjectResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; - excludeFromMcp(): IProjectResourcePromise; - withRemoteImageName(remoteImageName: string): IProjectResourcePromise; - withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IProjectResourcePromise; - withConfig(config: TestConfigDto): IProjectResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IProjectResourcePromise; - withCreatedAt(createdAt: string): IProjectResourcePromise; - withModifiedAt(modifiedAt: string): IProjectResourcePromise; - withCorrelationId(correlationId: string): IProjectResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IProjectResourcePromise; - withStatus(status: TestResourceStatus): IProjectResourcePromise; - withNestedConfig(config: TestNestedDto): IProjectResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IProjectResourcePromise; - testWaitFor(dependency: IHandleReference): IProjectResourcePromise; - withDependency(dependency: IHandleReference): IProjectResourcePromise; - withEndpoints(endpoints: string[]): IProjectResourcePromise; - withEnvironmentVariables(variables: Record): IProjectResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IProjectResourcePromise; -} - -export interface IProjectResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IProjectResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IProjectResourcePromise; - withMcpServer(options?: WithMcpServerOptions): IProjectResourcePromise; - withOtlpExporter(): IProjectResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IProjectResourcePromise; - withReplicas(replicas: number): IProjectResourcePromise; - disableForwardedHeaders(): IProjectResourcePromise; - publishAsDockerFile(options?: PublishAsDockerFileOptions): IProjectResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IProjectResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IProjectResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IProjectResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IProjectResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IProjectResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IProjectResourcePromise; - withArgs(args: string[]): IProjectResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IProjectResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IProjectResourcePromise; - withReferenceUri(name: string, uri: string): IProjectResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): IProjectResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IProjectResourcePromise; - withEndpoint(options?: WithEndpointOptions): IProjectResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IProjectResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IProjectResourcePromise; - withExternalHttpEndpoints(): IProjectResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IProjectResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IProjectResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IProjectResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IProjectResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IProjectResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IProjectResourcePromise; - publishWithContainerFiles(source: IHandleReference, destinationPath: string): IProjectResourcePromise; - excludeFromManifest(): IProjectResourcePromise; - waitFor(dependency: IHandleReference): IProjectResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; - waitForStart(dependency: IHandleReference): IProjectResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IProjectResourcePromise; - withExplicitStart(): IProjectResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IProjectResourcePromise; - withHealthCheck(key: string): IProjectResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IProjectResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IProjectResourcePromise; - withDeveloperCertificateTrust(trust: boolean): IProjectResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): IProjectResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IProjectResourcePromise; - withoutHttpsCertificate(): IProjectResourcePromise; - withParentRelationship(parent: IHandleReference): IProjectResourcePromise; - withChildRelationship(child: IHandleReference): IProjectResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IProjectResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IProjectResourcePromise; - excludeFromMcp(): IProjectResourcePromise; - withRemoteImageName(remoteImageName: string): IProjectResourcePromise; - withRemoteImageTag(remoteImageTag: string): IProjectResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IProjectResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IProjectResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IProjectResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IProjectResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IProjectResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IProjectResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IProjectResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IProjectResourcePromise; - withConfig(config: TestConfigDto): IProjectResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IProjectResourcePromise; - withCreatedAt(createdAt: string): IProjectResourcePromise; - withModifiedAt(modifiedAt: string): IProjectResourcePromise; - withCorrelationId(correlationId: string): IProjectResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IProjectResourcePromise; - withStatus(status: TestResourceStatus): IProjectResourcePromise; - withNestedConfig(config: TestNestedDto): IProjectResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IProjectResourcePromise; - testWaitFor(dependency: IHandleReference): IProjectResourcePromise; - withDependency(dependency: IHandleReference): IProjectResourcePromise; - withEndpoints(endpoints: string[]): IProjectResourcePromise; - withEnvironmentVariables(variables: Record): IProjectResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IProjectResourcePromise; } // ============================================================================ // ProjectResource // ============================================================================ -export class ProjectResource extends ResourceBuilderBase { +export interface ProjectResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): ProjectResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise; + withOtlpExporter(): ProjectResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise; + withReplicas(replicas: number): ProjectResourcePromise; + disableForwardedHeaders(): ProjectResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise; + withEnvironment(name: string, value: string): ProjectResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ProjectResourcePromise; + withArgs(args: string[]): ProjectResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ProjectResourcePromise; + withReferenceUri(name: string, uri: string): ProjectResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise; + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise; + withExternalHttpEndpoints(): ProjectResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ProjectResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ProjectResourcePromise; + publishWithContainerFiles(source: HandleReference, destinationPath: string): ProjectResourcePromise; + excludeFromManifest(): ProjectResourcePromise; + waitFor(dependency: HandleReference): ProjectResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise; + waitForStart(dependency: HandleReference): ProjectResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise; + withExplicitStart(): ProjectResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise; + withHealthCheck(key: string): ProjectResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise; + withoutHttpsCertificate(): ProjectResourcePromise; + withParentRelationship(parent: HandleReference): ProjectResourcePromise; + withChildRelationship(child: HandleReference): ProjectResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise; + excludeFromMcp(): ProjectResourcePromise; + withRemoteImageName(remoteImageName: string): ProjectResourcePromise; + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ProjectResourcePromise; + withConfig(config: TestConfigDto): ProjectResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ProjectResourcePromise; + withCreatedAt(createdAt: string): ProjectResourcePromise; + withModifiedAt(modifiedAt: string): ProjectResourcePromise; + withCorrelationId(correlationId: string): ProjectResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ProjectResourcePromise; + withStatus(status: TestResourceStatus): ProjectResourcePromise; + withNestedConfig(config: TestNestedDto): ProjectResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ProjectResourcePromise; + testWaitFor(dependency: HandleReference): ProjectResourcePromise; + withDependency(dependency: HandleReference): ProjectResourcePromise; + withEndpoints(endpoints: string[]): ProjectResourcePromise; + withEnvironmentVariables(variables: Record): ProjectResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ProjectResourcePromise; + withMergeLabel(label: string): ProjectResourcePromise; + withMergeLabelCategorized(label: string, category: string): ProjectResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ProjectResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ProjectResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ProjectResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ProjectResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ProjectResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ProjectResourcePromise; +} + +export interface ProjectResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ProjectResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise; + withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise; + withOtlpExporter(): ProjectResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise; + withReplicas(replicas: number): ProjectResourcePromise; + disableForwardedHeaders(): ProjectResourcePromise; + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise; + withEnvironment(name: string, value: string): ProjectResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ProjectResourcePromise; + withArgs(args: string[]): ProjectResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ProjectResourcePromise; + withReferenceUri(name: string, uri: string): ProjectResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise; + withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise; + withExternalHttpEndpoints(): ProjectResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ProjectResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ProjectResourcePromise; + publishWithContainerFiles(source: HandleReference, destinationPath: string): ProjectResourcePromise; + excludeFromManifest(): ProjectResourcePromise; + waitFor(dependency: HandleReference): ProjectResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise; + waitForStart(dependency: HandleReference): ProjectResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise; + withExplicitStart(): ProjectResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise; + withHealthCheck(key: string): ProjectResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise; + withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise; + withoutHttpsCertificate(): ProjectResourcePromise; + withParentRelationship(parent: HandleReference): ProjectResourcePromise; + withChildRelationship(child: HandleReference): ProjectResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise; + excludeFromMcp(): ProjectResourcePromise; + withRemoteImageName(remoteImageName: string): ProjectResourcePromise; + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ProjectResourcePromise; + withConfig(config: TestConfigDto): ProjectResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ProjectResourcePromise; + withCreatedAt(createdAt: string): ProjectResourcePromise; + withModifiedAt(modifiedAt: string): ProjectResourcePromise; + withCorrelationId(correlationId: string): ProjectResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ProjectResourcePromise; + withStatus(status: TestResourceStatus): ProjectResourcePromise; + withNestedConfig(config: TestNestedDto): ProjectResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ProjectResourcePromise; + testWaitFor(dependency: HandleReference): ProjectResourcePromise; + withDependency(dependency: HandleReference): ProjectResourcePromise; + withEndpoints(endpoints: string[]): ProjectResourcePromise; + withEnvironmentVariables(variables: Record): ProjectResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ProjectResourcePromise; + withMergeLabel(label: string): ProjectResourcePromise; + withMergeLabelCategorized(label: string, category: string): ProjectResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ProjectResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ProjectResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ProjectResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ProjectResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ProjectResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ProjectResourcePromise; +} + +// ============================================================================ +// ProjectResourceImpl +// ============================================================================ + +class ProjectResourceImpl extends ResourceBuilderBase implements ProjectResource { constructor(handle: ProjectResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -18094,14 +19129,14 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new ProjectResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new ProjectResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ @@ -18113,14 +19148,14 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withMcpServer', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { const path = options?.path; const endpointName = options?.endpointName; - return new ProjectResourcePromise(this._withMcpServerInternal(path, endpointName)); + return new ProjectResourcePromiseImpl(this._withMcpServerInternal(path, endpointName)); } /** @internal */ @@ -18130,12 +19165,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withOtlpExporter', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures OTLP telemetry export */ withOtlpExporter(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withOtlpExporterInternal()); + return new ProjectResourcePromiseImpl(this._withOtlpExporterInternal()); } /** @internal */ @@ -18145,12 +19180,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withOtlpExporterProtocol', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { - return new ProjectResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + return new ProjectResourcePromiseImpl(this._withOtlpExporterProtocolInternal(protocol)); } /** @internal */ @@ -18160,12 +19195,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withReplicas', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the number of replicas */ withReplicas(replicas: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReplicasInternal(replicas)); + return new ProjectResourcePromiseImpl(this._withReplicasInternal(replicas)); } /** @internal */ @@ -18175,19 +19210,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Disables forwarded headers for the project */ disableForwardedHeaders(): ProjectResourcePromise { - return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); + return new ProjectResourcePromiseImpl(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _publishAsDockerFileInternal(configure?: (obj: IContainerResource) => Promise): Promise { + 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); + const obj = new ContainerResourceImpl(objHandle, this._client); await configure(obj); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -18196,13 +19231,13 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** 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)); + return new ProjectResourcePromiseImpl(this._publishAsDockerFileInternal(configure)); } /** @internal */ @@ -18213,93 +19248,108 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(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)); + return new ProjectResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (arg: IEnvironmentCallbackContext) => 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -18309,19 +19359,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withArgs', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds arguments */ withArgs(args: string[]): ProjectResourcePromise { - return new ProjectResourcePromise(this._withArgsInternal(args)); + return new ProjectResourcePromiseImpl(this._withArgsInternal(args)); } /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: ICommandLineArgsCallbackContext) => Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -18329,36 +19379,16 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withArgsCallback', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -18367,15 +19397,15 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withReference', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): ProjectResourcePromise { + withReference(source: HandleReference, options?: WithReferenceOptions): ProjectResourcePromise { const connectionName = options?.connectionName; const optional = options?.optional; const name = options?.name; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + return new ProjectResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -18385,42 +19415,42 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withReferenceUri', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReferenceUriInternal(name, uri)); + return new ProjectResourcePromiseImpl(this._withReferenceUriInternal(name, uri)); } /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: IExternalServiceResource): Promise { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -18438,7 +19468,7 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withEndpoint', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a network endpoint */ @@ -18451,7 +19481,7 @@ export class ProjectResource extends ResourceBuilderBase const isProxied = options?.isProxied; const isExternal = options?.isExternal; const protocol = options?.protocol; - return new ProjectResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + return new ProjectResourcePromiseImpl(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); } /** @internal */ @@ -18466,7 +19496,7 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withHttpEndpoint', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds an HTTP endpoint */ @@ -18476,7 +19506,7 @@ export class ProjectResource extends ResourceBuilderBase const name = options?.name; const env = options?.env; const isProxied = options?.isProxied; - return new ProjectResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + return new ProjectResourcePromiseImpl(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ @@ -18491,7 +19521,7 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withHttpsEndpoint', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds an HTTPS endpoint */ @@ -18501,7 +19531,7 @@ export class ProjectResource extends ResourceBuilderBase const name = options?.name; const env = options?.env; const isProxied = options?.isProxied; - return new ProjectResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + return new ProjectResourcePromiseImpl(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ @@ -18511,18 +19541,18 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withExternalHttpEndpoints', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withExternalHttpEndpointsInternal()); + return new ProjectResourcePromiseImpl(this._withExternalHttpEndpointsInternal()); } /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -18535,19 +19565,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/asHttp2Service', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures resource for HTTP/2 */ asHttp2Service(): ProjectResourcePromise { - return new ProjectResourcePromise(this._asHttp2ServiceInternal()); + return new ProjectResourcePromiseImpl(this._asHttp2ServiceInternal()); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -18555,32 +19585,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -18591,30 +19601,30 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withUrl', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise { const displayText = options?.displayText; - return new ProjectResourcePromise(this._withUrlInternal(url, displayText)); + return new ProjectResourcePromiseImpl(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { const displayText = options?.displayText; - return new ProjectResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ProjectResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -18628,19 +19638,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ProjectResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -18648,27 +19658,27 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withUrlForEndpointFactory', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ - private async _publishWithContainerFilesInternal(source: IHandleReference, destinationPath: string): Promise { + private async _publishWithContainerFilesInternal(source: HandleReference, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFilesFromResource', + 'Aspire.Hosting/publishWithContainerFiles', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IHandleReference, destinationPath: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + publishWithContainerFiles(source: HandleReference, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._publishWithContainerFilesInternal(source, destinationPath)); } /** @internal */ @@ -18678,72 +19688,72 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ProjectResourcePromise { - return new ProjectResourcePromise(this._excludeFromManifestInternal()); + return new ProjectResourcePromiseImpl(this._excludeFromManifestInternal()); } /** @internal */ - private async _waitForInternal(dependency: IHandleReference): Promise { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -18753,29 +19763,29 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Prevents resource from starting automatically */ withExplicitStart(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withExplicitStartInternal()); + return new ProjectResourcePromiseImpl(this._withExplicitStartInternal()); } /** @internal */ - private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise { const exitCode = options?.exitCode; - return new ProjectResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new ProjectResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -18785,12 +19795,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a health check by key */ withHealthCheck(key: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withHealthCheckInternal(key)); + return new ProjectResourcePromiseImpl(this._withHealthCheckInternal(key)); } /** @internal */ @@ -18803,7 +19813,7 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withHttpHealthCheck', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds an HTTP health check */ @@ -18811,14 +19821,14 @@ export class ProjectResource extends ResourceBuilderBase const path = options?.path; const statusCode = options?.statusCode; const endpointName = options?.endpointName; - return new ProjectResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + return new ProjectResourcePromiseImpl(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -18827,13 +19837,13 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withCommand', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { const commandOptions = options?.commandOptions; - return new ProjectResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ProjectResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -18843,12 +19853,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withDeveloperCertificateTrust', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { - return new ProjectResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + return new ProjectResourcePromiseImpl(this._withDeveloperCertificateTrustInternal(trust)); } /** @internal */ @@ -18858,29 +19868,29 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withCertificateTrustScope', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { - return new ProjectResourcePromise(this._withCertificateTrustScopeInternal(scope)); + return new ProjectResourcePromiseImpl(this._withCertificateTrustScopeInternal(scope)); } /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: IParameterResource): Promise { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { const password = options?.password; - return new ProjectResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new ProjectResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -18890,42 +19900,42 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withoutHttpsCertificate', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): ProjectResourcePromise { - return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); + return new ProjectResourcePromiseImpl(this._withoutHttpsCertificateInternal()); } /** @internal */ - private async _withParentRelationshipInternal(parent: IHandleReference): Promise { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -18936,13 +19946,13 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withIconName', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { const iconVariant = options?.iconVariant; - return new ProjectResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + return new ProjectResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ @@ -18959,7 +19969,7 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withHttpProbe', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds an HTTP health probe to the resource */ @@ -18971,7 +19981,7 @@ export class ProjectResource extends ResourceBuilderBase const failureThreshold = options?.failureThreshold; const successThreshold = options?.successThreshold; const endpointName = options?.endpointName; - return new ProjectResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + return new ProjectResourcePromiseImpl(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ @@ -18981,12 +19991,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ProjectResourcePromise { - return new ProjectResourcePromise(this._excludeFromMcpInternal()); + return new ProjectResourcePromiseImpl(this._excludeFromMcpInternal()); } /** @internal */ @@ -18996,12 +20006,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withRemoteImageName', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + return new ProjectResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ @@ -19011,19 +20021,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + return new ProjectResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -19035,43 +20045,23 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + return new ProjectResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -19079,12 +20069,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -19097,10 +20087,10 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -19108,19 +20098,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -19128,19 +20118,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/onResourceStopped', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -19148,19 +20138,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/onInitializeResource', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -19168,19 +20158,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -19188,12 +20178,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting/onResourceReady', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -19205,14 +20195,14 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalString', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ProjectResourcePromise { const value = options?.value; const enabled = options?.enabled; - return new ProjectResourcePromise(this._withOptionalStringInternal(value, enabled)); + return new ProjectResourcePromiseImpl(this._withOptionalStringInternal(value, enabled)); } /** @internal */ @@ -19222,19 +20212,19 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConfig', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ProjectResourcePromise { - return new ProjectResourcePromise(this._withConfigInternal(config)); + return new ProjectResourcePromiseImpl(this._withConfigInternal(config)); } /** @internal */ - private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -19242,12 +20232,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWithEnvironmentCallback', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -19257,12 +20247,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCreatedAt', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withCreatedAtInternal(createdAt)); + return new ProjectResourcePromiseImpl(this._withCreatedAtInternal(createdAt)); } /** @internal */ @@ -19272,12 +20262,12 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withModifiedAt', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withModifiedAtInternal(modifiedAt)); + return new ProjectResourcePromiseImpl(this._withModifiedAtInternal(modifiedAt)); } /** @internal */ @@ -19287,163 +20277,291 @@ export class ProjectResource extends ResourceBuilderBase 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCorrelationId', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withCorrelationIdInternal(correlationId)); + return new ProjectResourcePromiseImpl(this._withCorrelationIdInternal(correlationId)); } /** @internal */ - private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; if (callback !== undefined) rpcArgs.callback = callbackId; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalCallback', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalCallback', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Configures with optional callback */ + withOptionalCallback(options?: WithOptionalCallbackOptions): ProjectResourcePromise { + const callback = options?.callback; + return new ProjectResourcePromiseImpl(this._withOptionalCallbackInternal(callback)); + } + + /** @internal */ + private async _withStatusInternal(status: TestResourceStatus): Promise { + const rpcArgs: Record = { builder: this._handle, status }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Sets the resource status */ + withStatus(status: TestResourceStatus): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withStatusInternal(status)); + } + + /** @internal */ + private async _withNestedConfigInternal(config: TestNestedDto): Promise { + const rpcArgs: Record = { builder: this._handle, config }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Configures with nested DTO */ + withNestedConfig(config: TestNestedDto): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withNestedConfigInternal(config)); + } + + /** @internal */ + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { + const validatorId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; + const arg = new TestResourceContextImpl(argHandle, this._client); + return await validator(arg); + }); + const rpcArgs: Record = { builder: this._handle, validator: validatorId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Adds validation callback */ + withValidator(validator: (arg: TestResourceContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withValidatorInternal(validator)); + } + + /** @internal */ + private async _testWaitForInternal(dependency: HandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Waits for another resource (test version) */ + testWaitFor(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._testWaitForInternal(dependency)); + } + + /** @internal */ + private async _withDependencyInternal(dependency: HandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Adds a dependency on another resource */ + withDependency(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withDependencyInternal(dependency)); + } + + /** @internal */ + private async _withEndpointsInternal(endpoints: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, endpoints }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Sets the endpoints */ + withEndpoints(endpoints: string[]): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEndpointsInternal(endpoints)); + } + + /** @internal */ + private async _withEnvironmentVariablesInternal(variables: Record): Promise { + const rpcArgs: Record = { builder: this._handle, variables }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + rpcArgs + ); + return new ProjectResourceImpl(result, this._client); + } + + /** Sets environment variables */ + withEnvironmentVariables(variables: Record): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); + } + + /** @internal */ + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { + const operationId = registerCallback(async (argData: unknown) => { + const arg = CancellationToken.fromValue(argData); + await operation(arg); + }); + const rpcArgs: Record = { builder: this._handle, operation: operationId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Configures with optional callback */ - withOptionalCallback(options?: WithOptionalCallbackOptions): ProjectResourcePromise { - const callback = options?.callback; - return new ProjectResourcePromise(this._withOptionalCallbackInternal(callback)); + /** Performs a cancellable operation */ + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } /** @internal */ - private async _withStatusInternal(status: TestResourceStatus): Promise { - const rpcArgs: Record = { builder: this._handle, status }; + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Sets the resource status */ - withStatus(status: TestResourceStatus): ProjectResourcePromise { - return new ProjectResourcePromise(this._withStatusInternal(status)); + /** Adds a label to the resource */ + withMergeLabel(label: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withMergeLabelInternal(label)); } /** @internal */ - private async _withNestedConfigInternal(config: TestNestedDto): Promise { - const rpcArgs: Record = { builder: this._handle, config }; + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Configures with nested DTO */ - withNestedConfig(config: TestNestedDto): ProjectResourcePromise { - return new ProjectResourcePromise(this._withNestedConfigInternal(config)); + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); } /** @internal */ - private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { - const validatorId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); - return await validator(arg); - }); - const rpcArgs: Record = { builder: this._handle, validator: validatorId }; + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withValidatorInternal(validator)); + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._testWaitForInternal(dependency)); + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withDependencyInternal(dependency)); + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ProjectResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ProjectResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); } /** @internal */ - private async _withEndpointsInternal(endpoints: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, endpoints }; + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Sets the endpoints */ - withEndpoints(endpoints: string[]): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEndpointsInternal(endpoints)); + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ProjectResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ProjectResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); } /** @internal */ - private async _withEnvironmentVariablesInternal(variables: Record): Promise { - const rpcArgs: Record = { builder: this._handle, variables }; + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Sets environment variables */ - withEnvironmentVariables(variables: Record): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentVariablesInternal(variables)); + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { - const operationId = registerCallback(async (argData: unknown) => { - const arg = CancellationToken.fromValue(argData); - await operation(arg); - }); - const rpcArgs: Record = { builder: this._handle, operation: operationId }; + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', rpcArgs ); - return new ProjectResource(result, this._client); + return new ProjectResourceImpl(result, this._client); } - /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withCancellableOperationInternal(operation)); + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -19453,7 +20571,7 @@ export class ProjectResource extends ResourceBuilderBase * @example * await builder.addSomething().withX().withY(); */ -export class ProjectResourcePromise implements PromiseLike { +class ProjectResourcePromiseImpl implements ProjectResourcePromise { constructor(private _promise: Promise) {} then( @@ -19464,293 +20582,283 @@ export class ProjectResourcePromise implements PromiseLike { } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } /** Sets the number of replicas */ withReplicas(replicas: number): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReplicas(replicas))); } /** Disables forwarded headers for the project */ disableForwardedHeaders(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.disableForwardedHeaders())); } /** 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))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.publishAsDockerFile(options))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ withArgs(args: string[]): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IHandleReference, destinationPath: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); + publishWithContainerFiles(source: HandleReference, destinationPath: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -19759,326 +20867,378 @@ export class ProjectResourcePromise implements PromiseLike { } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// ITestDatabaseResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ProjectResourcePromise { + return new ProjectResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface ITestDatabaseResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): ITestDatabaseResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestDatabaseResourcePromise; - withEntrypoint(entrypoint: string): ITestDatabaseResourcePromise; - withImageTag(tag: string): ITestDatabaseResourcePromise; - withImageRegistry(registry: string): ITestDatabaseResourcePromise; - withImage(image: string, options?: WithImageOptions): ITestDatabaseResourcePromise; - withImageSHA256(sha256: string): ITestDatabaseResourcePromise; - withContainerRuntimeArgs(args: string[]): ITestDatabaseResourcePromise; - withLifetime(lifetime: ContainerLifetime): ITestDatabaseResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestDatabaseResourcePromise; - publishAsContainer(): ITestDatabaseResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestDatabaseResourcePromise; - withContainerName(name: string): ITestDatabaseResourcePromise; - withBuildArg(name: string, value: IParameterResource): ITestDatabaseResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ITestDatabaseResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ITestDatabaseResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestDatabaseResourcePromise; - withContainerNetworkAlias(alias: string): ITestDatabaseResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ITestDatabaseResourcePromise; - withOtlpExporter(): ITestDatabaseResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ITestDatabaseResourcePromise; - publishAsConnectionString(): ITestDatabaseResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestDatabaseResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestDatabaseResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestDatabaseResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestDatabaseResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ITestDatabaseResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestDatabaseResourcePromise; - withArgs(args: string[]): ITestDatabaseResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ITestDatabaseResourcePromise; - withReferenceUri(name: string, uri: string): ITestDatabaseResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ITestDatabaseResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ITestDatabaseResourcePromise; - withEndpoint(options?: WithEndpointOptions): ITestDatabaseResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ITestDatabaseResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestDatabaseResourcePromise; - withExternalHttpEndpoints(): ITestDatabaseResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ITestDatabaseResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ITestDatabaseResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestDatabaseResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestDatabaseResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestDatabaseResourcePromise; - excludeFromManifest(): ITestDatabaseResourcePromise; - waitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; - waitForStart(dependency: IHandleReference): ITestDatabaseResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; - withExplicitStart(): ITestDatabaseResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestDatabaseResourcePromise; - withHealthCheck(key: string): ITestDatabaseResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestDatabaseResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestDatabaseResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ITestDatabaseResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ITestDatabaseResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestDatabaseResourcePromise; - withoutHttpsCertificate(): ITestDatabaseResourcePromise; - withParentRelationship(parent: IHandleReference): ITestDatabaseResourcePromise; - withChildRelationship(child: IHandleReference): ITestDatabaseResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ITestDatabaseResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestDatabaseResourcePromise; - excludeFromMcp(): ITestDatabaseResourcePromise; - withRemoteImageName(remoteImageName: string): ITestDatabaseResourcePromise; - withRemoteImageTag(remoteImageTag: string): ITestDatabaseResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestDatabaseResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ITestDatabaseResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestDatabaseResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestDatabaseResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestDatabaseResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestDatabaseResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestDatabaseResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestDatabaseResourcePromise; - withConfig(config: TestConfigDto): ITestDatabaseResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestDatabaseResourcePromise; - withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; - withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; - withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; - withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; - withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; - testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; - withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; - withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; - withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; -} - -export interface ITestDatabaseResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): ITestDatabaseResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestDatabaseResourcePromise; - withEntrypoint(entrypoint: string): ITestDatabaseResourcePromise; - withImageTag(tag: string): ITestDatabaseResourcePromise; - withImageRegistry(registry: string): ITestDatabaseResourcePromise; - withImage(image: string, options?: WithImageOptions): ITestDatabaseResourcePromise; - withImageSHA256(sha256: string): ITestDatabaseResourcePromise; - withContainerRuntimeArgs(args: string[]): ITestDatabaseResourcePromise; - withLifetime(lifetime: ContainerLifetime): ITestDatabaseResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestDatabaseResourcePromise; - publishAsContainer(): ITestDatabaseResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestDatabaseResourcePromise; - withContainerName(name: string): ITestDatabaseResourcePromise; - withBuildArg(name: string, value: IParameterResource): ITestDatabaseResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ITestDatabaseResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ITestDatabaseResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestDatabaseResourcePromise; - withContainerNetworkAlias(alias: string): ITestDatabaseResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ITestDatabaseResourcePromise; - withOtlpExporter(): ITestDatabaseResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ITestDatabaseResourcePromise; - publishAsConnectionString(): ITestDatabaseResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestDatabaseResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestDatabaseResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestDatabaseResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestDatabaseResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ITestDatabaseResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestDatabaseResourcePromise; - withArgs(args: string[]): ITestDatabaseResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ITestDatabaseResourcePromise; - withReferenceUri(name: string, uri: string): ITestDatabaseResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ITestDatabaseResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ITestDatabaseResourcePromise; - withEndpoint(options?: WithEndpointOptions): ITestDatabaseResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ITestDatabaseResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestDatabaseResourcePromise; - withExternalHttpEndpoints(): ITestDatabaseResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ITestDatabaseResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestDatabaseResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ITestDatabaseResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestDatabaseResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestDatabaseResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestDatabaseResourcePromise; - excludeFromManifest(): ITestDatabaseResourcePromise; - waitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; - waitForStart(dependency: IHandleReference): ITestDatabaseResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestDatabaseResourcePromise; - withExplicitStart(): ITestDatabaseResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestDatabaseResourcePromise; - withHealthCheck(key: string): ITestDatabaseResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestDatabaseResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestDatabaseResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ITestDatabaseResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ITestDatabaseResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestDatabaseResourcePromise; - withoutHttpsCertificate(): ITestDatabaseResourcePromise; - withParentRelationship(parent: IHandleReference): ITestDatabaseResourcePromise; - withChildRelationship(child: IHandleReference): ITestDatabaseResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ITestDatabaseResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestDatabaseResourcePromise; - excludeFromMcp(): ITestDatabaseResourcePromise; - withRemoteImageName(remoteImageName: string): ITestDatabaseResourcePromise; - withRemoteImageTag(remoteImageTag: string): ITestDatabaseResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestDatabaseResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestDatabaseResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ITestDatabaseResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestDatabaseResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestDatabaseResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestDatabaseResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestDatabaseResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestDatabaseResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestDatabaseResourcePromise; - withConfig(config: TestConfigDto): ITestDatabaseResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestDatabaseResourcePromise; - withCreatedAt(createdAt: string): ITestDatabaseResourcePromise; - withModifiedAt(modifiedAt: string): ITestDatabaseResourcePromise; - withCorrelationId(correlationId: string): ITestDatabaseResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestDatabaseResourcePromise; - withStatus(status: TestResourceStatus): ITestDatabaseResourcePromise; - withNestedConfig(config: TestNestedDto): ITestDatabaseResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestDatabaseResourcePromise; - testWaitFor(dependency: IHandleReference): ITestDatabaseResourcePromise; - withDependency(dependency: IHandleReference): ITestDatabaseResourcePromise; - withEndpoints(endpoints: string[]): ITestDatabaseResourcePromise; - withEnvironmentVariables(variables: Record): ITestDatabaseResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestDatabaseResourcePromise; } // ============================================================================ // TestDatabaseResource // ============================================================================ -export class TestDatabaseResource extends ResourceBuilderBase { +export interface TestDatabaseResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): TestDatabaseResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): TestDatabaseResourcePromise; + withEntrypoint(entrypoint: string): TestDatabaseResourcePromise; + withImageTag(tag: string): TestDatabaseResourcePromise; + withImageRegistry(registry: string): TestDatabaseResourcePromise; + withImage(image: string, options?: WithImageOptions): TestDatabaseResourcePromise; + withImageSHA256(sha256: string): TestDatabaseResourcePromise; + withContainerRuntimeArgs(args: string[]): TestDatabaseResourcePromise; + withLifetime(lifetime: ContainerLifetime): TestDatabaseResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): TestDatabaseResourcePromise; + publishAsContainer(): TestDatabaseResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestDatabaseResourcePromise; + withContainerName(name: string): TestDatabaseResourcePromise; + withBuildArg(name: string, value: ParameterResource): TestDatabaseResourcePromise; + withBuildSecret(name: string, value: ParameterResource): TestDatabaseResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): TestDatabaseResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestDatabaseResourcePromise; + withContainerNetworkAlias(alias: string): TestDatabaseResourcePromise; + withMcpServer(options?: WithMcpServerOptions): TestDatabaseResourcePromise; + withOtlpExporter(): TestDatabaseResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): TestDatabaseResourcePromise; + publishAsConnectionString(): TestDatabaseResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestDatabaseResourcePromise; + withEnvironment(name: string, value: string): TestDatabaseResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): TestDatabaseResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestDatabaseResourcePromise; + withArgs(args: string[]): TestDatabaseResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): TestDatabaseResourcePromise; + withReferenceUri(name: string, uri: string): TestDatabaseResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): TestDatabaseResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): TestDatabaseResourcePromise; + withEndpoint(options?: WithEndpointOptions): TestDatabaseResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): TestDatabaseResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestDatabaseResourcePromise; + withExternalHttpEndpoints(): TestDatabaseResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): TestDatabaseResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise; + withUrl(url: string, options?: WithUrlOptions): TestDatabaseResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestDatabaseResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestDatabaseResourcePromise; + excludeFromManifest(): TestDatabaseResourcePromise; + waitFor(dependency: HandleReference): TestDatabaseResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise; + waitForStart(dependency: HandleReference): TestDatabaseResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise; + withExplicitStart(): TestDatabaseResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestDatabaseResourcePromise; + withHealthCheck(key: string): TestDatabaseResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestDatabaseResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestDatabaseResourcePromise; + withDeveloperCertificateTrust(trust: boolean): TestDatabaseResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): TestDatabaseResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestDatabaseResourcePromise; + withoutHttpsCertificate(): TestDatabaseResourcePromise; + withParentRelationship(parent: HandleReference): TestDatabaseResourcePromise; + withChildRelationship(child: HandleReference): TestDatabaseResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): TestDatabaseResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestDatabaseResourcePromise; + excludeFromMcp(): TestDatabaseResourcePromise; + withRemoteImageName(remoteImageName: string): TestDatabaseResourcePromise; + withRemoteImageTag(remoteImageTag: string): TestDatabaseResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestDatabaseResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): TestDatabaseResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestDatabaseResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestDatabaseResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestDatabaseResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestDatabaseResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestDatabaseResourcePromise; + withConfig(config: TestConfigDto): TestDatabaseResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise; + withCreatedAt(createdAt: string): TestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): TestDatabaseResourcePromise; + withCorrelationId(correlationId: string): TestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): TestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise; + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise; + withDependency(dependency: HandleReference): TestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): TestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise; + withMergeLabel(label: string): TestDatabaseResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise; +} + +export interface TestDatabaseResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): TestDatabaseResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): TestDatabaseResourcePromise; + withEntrypoint(entrypoint: string): TestDatabaseResourcePromise; + withImageTag(tag: string): TestDatabaseResourcePromise; + withImageRegistry(registry: string): TestDatabaseResourcePromise; + withImage(image: string, options?: WithImageOptions): TestDatabaseResourcePromise; + withImageSHA256(sha256: string): TestDatabaseResourcePromise; + withContainerRuntimeArgs(args: string[]): TestDatabaseResourcePromise; + withLifetime(lifetime: ContainerLifetime): TestDatabaseResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): TestDatabaseResourcePromise; + publishAsContainer(): TestDatabaseResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestDatabaseResourcePromise; + withContainerName(name: string): TestDatabaseResourcePromise; + withBuildArg(name: string, value: ParameterResource): TestDatabaseResourcePromise; + withBuildSecret(name: string, value: ParameterResource): TestDatabaseResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): TestDatabaseResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestDatabaseResourcePromise; + withContainerNetworkAlias(alias: string): TestDatabaseResourcePromise; + withMcpServer(options?: WithMcpServerOptions): TestDatabaseResourcePromise; + withOtlpExporter(): TestDatabaseResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): TestDatabaseResourcePromise; + publishAsConnectionString(): TestDatabaseResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestDatabaseResourcePromise; + withEnvironment(name: string, value: string): TestDatabaseResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): TestDatabaseResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestDatabaseResourcePromise; + withArgs(args: string[]): TestDatabaseResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): TestDatabaseResourcePromise; + withReferenceUri(name: string, uri: string): TestDatabaseResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): TestDatabaseResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): TestDatabaseResourcePromise; + withEndpoint(options?: WithEndpointOptions): TestDatabaseResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): TestDatabaseResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestDatabaseResourcePromise; + withExternalHttpEndpoints(): TestDatabaseResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): TestDatabaseResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise; + withUrl(url: string, options?: WithUrlOptions): TestDatabaseResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestDatabaseResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestDatabaseResourcePromise; + excludeFromManifest(): TestDatabaseResourcePromise; + waitFor(dependency: HandleReference): TestDatabaseResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise; + waitForStart(dependency: HandleReference): TestDatabaseResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise; + withExplicitStart(): TestDatabaseResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestDatabaseResourcePromise; + withHealthCheck(key: string): TestDatabaseResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestDatabaseResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestDatabaseResourcePromise; + withDeveloperCertificateTrust(trust: boolean): TestDatabaseResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): TestDatabaseResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestDatabaseResourcePromise; + withoutHttpsCertificate(): TestDatabaseResourcePromise; + withParentRelationship(parent: HandleReference): TestDatabaseResourcePromise; + withChildRelationship(child: HandleReference): TestDatabaseResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): TestDatabaseResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestDatabaseResourcePromise; + excludeFromMcp(): TestDatabaseResourcePromise; + withRemoteImageName(remoteImageName: string): TestDatabaseResourcePromise; + withRemoteImageTag(remoteImageTag: string): TestDatabaseResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestDatabaseResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): TestDatabaseResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestDatabaseResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestDatabaseResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestDatabaseResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestDatabaseResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestDatabaseResourcePromise; + withConfig(config: TestConfigDto): TestDatabaseResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise; + withCreatedAt(createdAt: string): TestDatabaseResourcePromise; + withModifiedAt(modifiedAt: string): TestDatabaseResourcePromise; + withCorrelationId(correlationId: string): TestDatabaseResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise; + withStatus(status: TestResourceStatus): TestDatabaseResourcePromise; + withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise; + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise; + withDependency(dependency: HandleReference): TestDatabaseResourcePromise; + withEndpoints(endpoints: string[]): TestDatabaseResourcePromise; + withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise; + withMergeLabel(label: string): TestDatabaseResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise; +} + +// ============================================================================ +// TestDatabaseResourceImpl +// ============================================================================ + +class TestDatabaseResourceImpl extends ResourceBuilderBase implements TestDatabaseResource { constructor(handle: TestDatabaseResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -20089,13 +21249,13 @@ export class TestDatabaseResource extends ResourceBuilderBase { + 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', + 'Aspire.Hosting/withBuildArg', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withBuildArgInternal(name, value)); + withBuildArg(name: string, value: ParameterResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { + 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', + 'Aspire.Hosting/withBuildSecret', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withBuildSecretInternal(name, value)); + withBuildSecret(name: string, value: ParameterResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withBuildSecretInternal(name, value)); } /** @internal */ @@ -20306,12 +21466,12 @@ export class TestDatabaseResource extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -20516,19 +21691,19 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -20536,36 +21711,16 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -20574,15 +21729,15 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -20645,7 +21800,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -20742,19 +21897,19 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -20762,32 +21917,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -20798,30 +21933,30 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise { const displayText = options?.displayText; - return new TestDatabaseResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new TestDatabaseResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -20835,19 +21970,19 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new TestDatabaseResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -20855,12 +21990,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ @@ -20870,72 +22005,72 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -20945,29 +22080,29 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestDatabaseResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestDatabaseResourcePromise { const exitCode = options?.exitCode; - return new TestDatabaseResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new TestDatabaseResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -20977,12 +22112,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -21019,13 +22154,13 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { const commandOptions = options?.commandOptions; - return new TestDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new TestDatabaseResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -21035,12 +22170,12 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestDatabaseResourcePromise { const password = options?.password; - return new TestDatabaseResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new TestDatabaseResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -21082,42 +22217,42 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -21128,13 +22263,13 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -21227,43 +22362,23 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new TestDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new TestDatabaseResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -21271,12 +22386,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -21288,14 +22403,14 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -21319,19 +22434,19 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -21339,19 +22454,19 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -21359,19 +22474,19 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -21379,19 +22494,19 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -21399,12 +22514,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -21416,14 +22531,14 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -21453,12 +22568,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -21468,12 +22583,12 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; if (callback !== undefined) rpcArgs.callback = callbackId; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalCallback', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalCallback', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Configures with optional callback */ + withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise { + const callback = options?.callback; + return new TestDatabaseResourcePromiseImpl(this._withOptionalCallbackInternal(callback)); + } + + /** @internal */ + private async _withStatusInternal(status: TestResourceStatus): Promise { + const rpcArgs: Record = { builder: this._handle, status }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Sets the resource status */ + withStatus(status: TestResourceStatus): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withStatusInternal(status)); + } + + /** @internal */ + private async _withNestedConfigInternal(config: TestNestedDto): Promise { + const rpcArgs: Record = { builder: this._handle, config }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Configures with nested DTO */ + withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withNestedConfigInternal(config)); + } + + /** @internal */ + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { + const validatorId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; + const arg = new TestResourceContextImpl(argHandle, this._client); + return await validator(arg); + }); + const rpcArgs: Record = { builder: this._handle, validator: validatorId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Adds validation callback */ + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withValidatorInternal(validator)); + } + + /** @internal */ + private async _testWaitForInternal(dependency: HandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Waits for another resource (test version) */ + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._testWaitForInternal(dependency)); + } + + /** @internal */ + private async _withDependencyInternal(dependency: HandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Adds a dependency on another resource */ + withDependency(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withDependencyInternal(dependency)); + } + + /** @internal */ + private async _withEndpointsInternal(endpoints: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, endpoints }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Sets the endpoints */ + withEndpoints(endpoints: string[]): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEndpointsInternal(endpoints)); + } + + /** @internal */ + private async _withEnvironmentVariablesInternal(variables: Record): Promise { + const rpcArgs: Record = { builder: this._handle, variables }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + rpcArgs + ); + return new TestDatabaseResourceImpl(result, this._client); + } + + /** Sets environment variables */ + withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); + } + + /** @internal */ + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { + const operationId = registerCallback(async (argData: unknown) => { + const arg = CancellationToken.fromValue(argData); + await operation(arg); + }); + const rpcArgs: Record = { builder: this._handle, operation: operationId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Configures with optional callback */ - withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise { - const callback = options?.callback; - return new TestDatabaseResourcePromise(this._withOptionalCallbackInternal(callback)); + /** Performs a cancellable operation */ + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withCancellableOperationInternal(operation)); } /** @internal */ - private async _withStatusInternal(status: TestResourceStatus): Promise { - const rpcArgs: Record = { builder: this._handle, status }; + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Sets the resource status */ - withStatus(status: TestResourceStatus): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withStatusInternal(status)); + /** Adds a label to the resource */ + withMergeLabel(label: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withMergeLabelInternal(label)); } /** @internal */ - private async _withNestedConfigInternal(config: TestNestedDto): Promise { - const rpcArgs: Record = { builder: this._handle, config }; + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Configures with nested DTO */ - withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withNestedConfigInternal(config)); + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); } /** @internal */ - private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { - const validatorId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); - return await validator(arg); - }); - const rpcArgs: Record = { builder: this._handle, validator: validatorId }; + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withValidatorInternal(validator)); + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._testWaitForInternal(dependency)); + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withDependencyInternal(dependency)); + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new TestDatabaseResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); } /** @internal */ - private async _withEndpointsInternal(endpoints: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, endpoints }; + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Sets the endpoints */ - withEndpoints(endpoints: string[]): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEndpointsInternal(endpoints)); + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new TestDatabaseResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); } /** @internal */ - private async _withEnvironmentVariablesInternal(variables: Record): Promise { - const rpcArgs: Record = { builder: this._handle, variables }; + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Sets environment variables */ - withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentVariablesInternal(variables)); + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { - const operationId = registerCallback(async (argData: unknown) => { - const arg = CancellationToken.fromValue(argData); - await operation(arg); - }); - const rpcArgs: Record = { builder: this._handle, operation: operationId }; + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', rpcArgs ); - return new TestDatabaseResource(result, this._client); + return new TestDatabaseResourceImpl(result, this._client); } - /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withCancellableOperationInternal(operation)); + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -21664,7 +22907,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { +class TestDatabaseResourcePromiseImpl implements TestDatabaseResourcePromise { constructor(private _promise: Promise) {} then( @@ -21675,363 +22918,353 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options))); } /** Sets the container entrypoint */ withEntrypoint(entrypoint: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint))); } /** Sets the container image tag */ withImageTag(tag: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag))); } /** Sets the container image registry */ withImageRegistry(registry: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry))); } /** Sets the container image */ withImage(image: string, options?: WithImageOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options))); } /** Sets the image SHA256 digest */ withImageSHA256(sha256: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256))); } /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); } /** Sets the lifetime behavior of the container resource */ withLifetime(lifetime: ContainerLifetime): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime))); } /** Sets the container image pull policy */ withImagePullPolicy(pullPolicy: ImagePullPolicy): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); } /** Configures the resource to be published as a container */ publishAsContainer(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer())); } /** Configures the resource to use a Dockerfile */ withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options))); } /** Sets the container name */ withContainerName(name: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name))); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + withBuildArg(name: string, value: ParameterResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value))); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + withBuildSecret(name: string, value: ParameterResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value))); } /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a network alias for the container */ withContainerNetworkAlias(alias: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); } /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } /** Publishes the resource as a connection string */ publishAsConnectionString(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString())); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ withArgs(args: string[]): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Adds a volume */ withVolume(target: string, options?: WithVolumeOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options))); } /** Gets the resource name */ @@ -22040,358 +23273,408 @@ export class TestDatabaseResourcePromise implements PromiseLike Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// ITestRedisResource +// TestRedisResource // ============================================================================ -export interface ITestRedisResource { +export interface TestRedisResource { toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): ITestRedisResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestRedisResourcePromise; - withEntrypoint(entrypoint: string): ITestRedisResourcePromise; - withImageTag(tag: string): ITestRedisResourcePromise; - withImageRegistry(registry: string): ITestRedisResourcePromise; - withImage(image: string, options?: WithImageOptions): ITestRedisResourcePromise; - withImageSHA256(sha256: string): ITestRedisResourcePromise; - withContainerRuntimeArgs(args: string[]): ITestRedisResourcePromise; - withLifetime(lifetime: ContainerLifetime): ITestRedisResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestRedisResourcePromise; - publishAsContainer(): ITestRedisResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestRedisResourcePromise; - withContainerName(name: string): ITestRedisResourcePromise; - withBuildArg(name: string, value: IParameterResource): ITestRedisResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ITestRedisResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ITestRedisResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestRedisResourcePromise; - withContainerNetworkAlias(alias: string): ITestRedisResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ITestRedisResourcePromise; - withOtlpExporter(): ITestRedisResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ITestRedisResourcePromise; - publishAsConnectionString(): ITestRedisResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestRedisResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestRedisResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestRedisResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestRedisResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ITestRedisResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestRedisResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): ITestRedisResourcePromise; - withConnectionPropertyValue(name: string, value: string): ITestRedisResourcePromise; - withArgs(args: string[]): ITestRedisResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ITestRedisResourcePromise; - getConnectionProperty(key: string): Promise; - withReferenceUri(name: string, uri: string): ITestRedisResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ITestRedisResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ITestRedisResourcePromise; - withEndpoint(options?: WithEndpointOptions): ITestRedisResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ITestRedisResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestRedisResourcePromise; - withExternalHttpEndpoints(): ITestRedisResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ITestRedisResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ITestRedisResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestRedisResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestRedisResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestRedisResourcePromise; - excludeFromManifest(): ITestRedisResourcePromise; - waitFor(dependency: IHandleReference): ITestRedisResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; - waitForStart(dependency: IHandleReference): ITestRedisResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; - withExplicitStart(): ITestRedisResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestRedisResourcePromise; - withHealthCheck(key: string): ITestRedisResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestRedisResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestRedisResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ITestRedisResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ITestRedisResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestRedisResourcePromise; - withoutHttpsCertificate(): ITestRedisResourcePromise; - withParentRelationship(parent: IHandleReference): ITestRedisResourcePromise; - withChildRelationship(child: IHandleReference): ITestRedisResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ITestRedisResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestRedisResourcePromise; - excludeFromMcp(): ITestRedisResourcePromise; - withRemoteImageName(remoteImageName: string): ITestRedisResourcePromise; - withRemoteImageTag(remoteImageTag: string): ITestRedisResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestRedisResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ITestRedisResourcePromise; + withContainerRegistry(registry: HandleReference): TestRedisResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): TestRedisResourcePromise; + withEntrypoint(entrypoint: string): TestRedisResourcePromise; + withImageTag(tag: string): TestRedisResourcePromise; + withImageRegistry(registry: string): TestRedisResourcePromise; + withImage(image: string, options?: WithImageOptions): TestRedisResourcePromise; + withImageSHA256(sha256: string): TestRedisResourcePromise; + withContainerRuntimeArgs(args: string[]): TestRedisResourcePromise; + withLifetime(lifetime: ContainerLifetime): TestRedisResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): TestRedisResourcePromise; + publishAsContainer(): TestRedisResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestRedisResourcePromise; + withContainerName(name: string): TestRedisResourcePromise; + withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise; + withBuildSecret(name: string, value: ParameterResource): TestRedisResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): TestRedisResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestRedisResourcePromise; + withContainerNetworkAlias(alias: string): TestRedisResourcePromise; + withMcpServer(options?: WithMcpServerOptions): TestRedisResourcePromise; + withOtlpExporter(): TestRedisResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): TestRedisResourcePromise; + publishAsConnectionString(): TestRedisResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestRedisResourcePromise; + withEnvironment(name: string, value: string): TestRedisResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): TestRedisResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestRedisResourcePromise; + withConnectionProperty(name: string, value: ReferenceExpression): TestRedisResourcePromise; + withConnectionPropertyValue(name: string, value: string): TestRedisResourcePromise; + withArgs(args: string[]): TestRedisResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): TestRedisResourcePromise; + withReferenceUri(name: string, uri: string): TestRedisResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): TestRedisResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): TestRedisResourcePromise; + withEndpoint(options?: WithEndpointOptions): TestRedisResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): TestRedisResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestRedisResourcePromise; + withExternalHttpEndpoints(): TestRedisResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): TestRedisResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise; + withUrl(url: string, options?: WithUrlOptions): TestRedisResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestRedisResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestRedisResourcePromise; + excludeFromManifest(): TestRedisResourcePromise; + waitFor(dependency: HandleReference): TestRedisResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise; + waitForStart(dependency: HandleReference): TestRedisResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise; + withExplicitStart(): TestRedisResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise; + withHealthCheck(key: string): TestRedisResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestRedisResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise; + withDeveloperCertificateTrust(trust: boolean): TestRedisResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): TestRedisResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestRedisResourcePromise; + withoutHttpsCertificate(): TestRedisResourcePromise; + withParentRelationship(parent: HandleReference): TestRedisResourcePromise; + withChildRelationship(child: HandleReference): TestRedisResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): TestRedisResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestRedisResourcePromise; + excludeFromMcp(): TestRedisResourcePromise; + withRemoteImageName(remoteImageName: string): TestRedisResourcePromise; + withRemoteImageTag(remoteImageTag: string): TestRedisResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestRedisResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): TestRedisResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestRedisResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestRedisResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ITestRedisResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestRedisResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestRedisResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestRedisResourcePromise; - addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): ITestDatabaseResourcePromise; - withPersistence(options?: WithPersistenceOptions): ITestRedisResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestRedisResourcePromise; - withConfig(config: TestConfigDto): ITestRedisResourcePromise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestRedisResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestRedisResourcePromise; + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestRedisResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestRedisResourcePromise; + addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): TestDatabaseResourcePromise; + withPersistence(options?: WithPersistenceOptions): TestRedisResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestRedisResourcePromise; + withConfig(config: TestConfigDto): TestRedisResourcePromise; getTags(): Promise>; getMetadata(): Promise>; - withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withCreatedAt(createdAt: string): ITestRedisResourcePromise; - withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; - withCorrelationId(correlationId: string): ITestRedisResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; - withStatus(status: TestResourceStatus): ITestRedisResourcePromise; - withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; - testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withCreatedAt(createdAt: string): TestRedisResourcePromise; + withModifiedAt(modifiedAt: string): TestRedisResourcePromise; + withCorrelationId(correlationId: string): TestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestRedisResourcePromise; + withStatus(status: TestResourceStatus): TestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): TestRedisResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise; + testWaitFor(dependency: HandleReference): TestRedisResourcePromise; getEndpoints(): Promise; - withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; - withRedisSpecific(option: string): ITestRedisResourcePromise; - withDependency(dependency: IHandleReference): ITestRedisResourcePromise; - withEndpoints(endpoints: string[]): ITestRedisResourcePromise; - withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + withConnectionStringDirect(connectionString: string): TestRedisResourcePromise; + withRedisSpecific(option: string): TestRedisResourcePromise; + withDependency(dependency: HandleReference): TestRedisResourcePromise; + withEndpoints(endpoints: string[]): TestRedisResourcePromise; + withEnvironmentVariables(variables: Record): TestRedisResourcePromise; getStatusAsync(options?: GetStatusAsyncOptions): Promise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise; waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; - withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; -} - -export interface ITestRedisResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): ITestRedisResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestRedisResourcePromise; - withEntrypoint(entrypoint: string): ITestRedisResourcePromise; - withImageTag(tag: string): ITestRedisResourcePromise; - withImageRegistry(registry: string): ITestRedisResourcePromise; - withImage(image: string, options?: WithImageOptions): ITestRedisResourcePromise; - withImageSHA256(sha256: string): ITestRedisResourcePromise; - withContainerRuntimeArgs(args: string[]): ITestRedisResourcePromise; - withLifetime(lifetime: ContainerLifetime): ITestRedisResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestRedisResourcePromise; - publishAsContainer(): ITestRedisResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestRedisResourcePromise; - withContainerName(name: string): ITestRedisResourcePromise; - withBuildArg(name: string, value: IParameterResource): ITestRedisResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ITestRedisResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ITestRedisResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestRedisResourcePromise; - withContainerNetworkAlias(alias: string): ITestRedisResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ITestRedisResourcePromise; - withOtlpExporter(): ITestRedisResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ITestRedisResourcePromise; - publishAsConnectionString(): ITestRedisResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestRedisResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestRedisResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestRedisResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestRedisResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ITestRedisResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestRedisResourcePromise; - withConnectionProperty(name: string, value: IReferenceExpression): ITestRedisResourcePromise; - withConnectionPropertyValue(name: string, value: string): ITestRedisResourcePromise; - withArgs(args: string[]): ITestRedisResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestRedisResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ITestRedisResourcePromise; - getConnectionProperty(key: string): Promise; - withReferenceUri(name: string, uri: string): ITestRedisResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ITestRedisResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ITestRedisResourcePromise; - withEndpoint(options?: WithEndpointOptions): ITestRedisResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ITestRedisResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestRedisResourcePromise; - withExternalHttpEndpoints(): ITestRedisResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ITestRedisResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestRedisResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ITestRedisResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestRedisResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestRedisResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestRedisResourcePromise; - excludeFromManifest(): ITestRedisResourcePromise; - waitFor(dependency: IHandleReference): ITestRedisResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; - waitForStart(dependency: IHandleReference): ITestRedisResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestRedisResourcePromise; - withExplicitStart(): ITestRedisResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestRedisResourcePromise; - withHealthCheck(key: string): ITestRedisResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestRedisResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestRedisResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ITestRedisResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ITestRedisResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestRedisResourcePromise; - withoutHttpsCertificate(): ITestRedisResourcePromise; - withParentRelationship(parent: IHandleReference): ITestRedisResourcePromise; - withChildRelationship(child: IHandleReference): ITestRedisResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ITestRedisResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestRedisResourcePromise; - excludeFromMcp(): ITestRedisResourcePromise; - withRemoteImageName(remoteImageName: string): ITestRedisResourcePromise; - withRemoteImageTag(remoteImageTag: string): ITestRedisResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestRedisResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestRedisResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ITestRedisResourcePromise; + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise; + withMergeLabel(label: string): TestRedisResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise; +} + +export interface TestRedisResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): TestRedisResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): TestRedisResourcePromise; + withEntrypoint(entrypoint: string): TestRedisResourcePromise; + withImageTag(tag: string): TestRedisResourcePromise; + withImageRegistry(registry: string): TestRedisResourcePromise; + withImage(image: string, options?: WithImageOptions): TestRedisResourcePromise; + withImageSHA256(sha256: string): TestRedisResourcePromise; + withContainerRuntimeArgs(args: string[]): TestRedisResourcePromise; + withLifetime(lifetime: ContainerLifetime): TestRedisResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): TestRedisResourcePromise; + publishAsContainer(): TestRedisResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestRedisResourcePromise; + withContainerName(name: string): TestRedisResourcePromise; + withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise; + withBuildSecret(name: string, value: ParameterResource): TestRedisResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): TestRedisResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestRedisResourcePromise; + withContainerNetworkAlias(alias: string): TestRedisResourcePromise; + withMcpServer(options?: WithMcpServerOptions): TestRedisResourcePromise; + withOtlpExporter(): TestRedisResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): TestRedisResourcePromise; + publishAsConnectionString(): TestRedisResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestRedisResourcePromise; + withEnvironment(name: string, value: string): TestRedisResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): TestRedisResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestRedisResourcePromise; + withConnectionProperty(name: string, value: ReferenceExpression): TestRedisResourcePromise; + withConnectionPropertyValue(name: string, value: string): TestRedisResourcePromise; + withArgs(args: string[]): TestRedisResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): TestRedisResourcePromise; + withReferenceUri(name: string, uri: string): TestRedisResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): TestRedisResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): TestRedisResourcePromise; + withEndpoint(options?: WithEndpointOptions): TestRedisResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): TestRedisResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestRedisResourcePromise; + withExternalHttpEndpoints(): TestRedisResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): TestRedisResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise; + withUrl(url: string, options?: WithUrlOptions): TestRedisResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestRedisResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestRedisResourcePromise; + excludeFromManifest(): TestRedisResourcePromise; + waitFor(dependency: HandleReference): TestRedisResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise; + waitForStart(dependency: HandleReference): TestRedisResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise; + withExplicitStart(): TestRedisResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise; + withHealthCheck(key: string): TestRedisResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestRedisResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise; + withDeveloperCertificateTrust(trust: boolean): TestRedisResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): TestRedisResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestRedisResourcePromise; + withoutHttpsCertificate(): TestRedisResourcePromise; + withParentRelationship(parent: HandleReference): TestRedisResourcePromise; + withChildRelationship(child: HandleReference): TestRedisResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): TestRedisResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestRedisResourcePromise; + excludeFromMcp(): TestRedisResourcePromise; + withRemoteImageName(remoteImageName: string): TestRedisResourcePromise; + withRemoteImageTag(remoteImageTag: string): TestRedisResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestRedisResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): TestRedisResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestRedisResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestRedisResourcePromise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ITestRedisResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestRedisResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestRedisResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestRedisResourcePromise; - addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): ITestDatabaseResourcePromise; - withPersistence(options?: WithPersistenceOptions): ITestRedisResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestRedisResourcePromise; - withConfig(config: TestConfigDto): ITestRedisResourcePromise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestRedisResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestRedisResourcePromise; + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestRedisResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestRedisResourcePromise; + addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): TestDatabaseResourcePromise; + withPersistence(options?: WithPersistenceOptions): TestRedisResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestRedisResourcePromise; + withConfig(config: TestConfigDto): TestRedisResourcePromise; getTags(): Promise>; getMetadata(): Promise>; - withConnectionString(connectionString: IReferenceExpression): ITestRedisResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withCreatedAt(createdAt: string): ITestRedisResourcePromise; - withModifiedAt(modifiedAt: string): ITestRedisResourcePromise; - withCorrelationId(correlationId: string): ITestRedisResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestRedisResourcePromise; - withStatus(status: TestResourceStatus): ITestRedisResourcePromise; - withNestedConfig(config: TestNestedDto): ITestRedisResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestRedisResourcePromise; - testWaitFor(dependency: IHandleReference): ITestRedisResourcePromise; + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withCreatedAt(createdAt: string): TestRedisResourcePromise; + withModifiedAt(modifiedAt: string): TestRedisResourcePromise; + withCorrelationId(correlationId: string): TestRedisResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestRedisResourcePromise; + withStatus(status: TestResourceStatus): TestRedisResourcePromise; + withNestedConfig(config: TestNestedDto): TestRedisResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise; + testWaitFor(dependency: HandleReference): TestRedisResourcePromise; getEndpoints(): Promise; - withConnectionStringDirect(connectionString: string): ITestRedisResourcePromise; - withRedisSpecific(option: string): ITestRedisResourcePromise; - withDependency(dependency: IHandleReference): ITestRedisResourcePromise; - withEndpoints(endpoints: string[]): ITestRedisResourcePromise; - withEnvironmentVariables(variables: Record): ITestRedisResourcePromise; + withConnectionStringDirect(connectionString: string): TestRedisResourcePromise; + withRedisSpecific(option: string): TestRedisResourcePromise; + withDependency(dependency: HandleReference): TestRedisResourcePromise; + withEndpoints(endpoints: string[]): TestRedisResourcePromise; + withEnvironmentVariables(variables: Record): TestRedisResourcePromise; getStatusAsync(options?: GetStatusAsyncOptions): Promise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestRedisResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise; waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise; - withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): ITestRedisResourcePromise; - withDataVolume(options?: WithDataVolumeOptions): ITestRedisResourcePromise; + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise; + withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise; + withMergeLabel(label: string): TestRedisResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise; } // ============================================================================ -// TestRedisResource +// TestRedisResourceImpl // ============================================================================ -export class TestRedisResource extends ResourceBuilderBase { +class TestRedisResourceImpl extends ResourceBuilderBase implements TestRedisResource { constructor(handle: TestRedisResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -22402,13 +23685,13 @@ export class TestRedisResource extends ResourceBuilderBase { + 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', + 'Aspire.Hosting/withBuildArg', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withBuildArgInternal(name, value)); + withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { + 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', + 'Aspire.Hosting/withBuildSecret', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withBuildSecretInternal(name, value)); + withBuildSecret(name: string, value: ParameterResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withBuildSecretInternal(name, value)); } /** @internal */ @@ -22619,12 +23902,12 @@ export class TestRedisResource extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withConnectionPropertyInternal(name, value)); + withConnectionProperty(name: string, value: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withConnectionPropertyInternal(name, value)); } /** @internal */ @@ -22844,12 +24142,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -22879,36 +24177,16 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -22917,24 +24195,15 @@ export class TestRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { resource: this._handle, key }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getConnectionProperty', - rpcArgs - ); + return new TestRedisResourcePromiseImpl(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -22944,42 +24213,42 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -22997,7 +24266,7 @@ export class TestRedisResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -23094,19 +24363,19 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23114,32 +24383,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -23150,30 +24399,30 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise { const displayText = options?.displayText; - return new TestRedisResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new TestRedisResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -23187,19 +24436,19 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new TestRedisResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -23207,12 +24456,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ @@ -23222,72 +24471,72 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -23297,29 +24546,29 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise { const exitCode = options?.exitCode; - return new TestRedisResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new TestRedisResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -23329,12 +24578,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -23371,13 +24620,13 @@ export class TestRedisResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): TestRedisResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise { const commandOptions = options?.commandOptions; - return new TestRedisResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new TestRedisResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -23387,12 +24636,12 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestRedisResourcePromise { const password = options?.password; - return new TestRedisResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new TestRedisResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -23434,42 +24683,42 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -23480,13 +24729,13 @@ export class TestRedisResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -23579,43 +24828,23 @@ export class TestRedisResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new TestRedisResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new TestRedisResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23623,12 +24852,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -23640,14 +24869,14 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23671,19 +24900,19 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23691,19 +24920,19 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => Promise): Promise { + 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); + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23711,19 +24940,19 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._onConnectionStringAvailableInternal(callback)); + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23731,19 +24960,19 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23751,19 +24980,19 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23771,12 +25000,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -23787,13 +25016,13 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withConnectionStringInternal(connectionString: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withConnectionStringInternal(connectionString)); + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withConnectionStringInternal(connectionString)); } /** @internal */ - private async _testWithEnvironmentCallbackInternal(callback: (arg: ITestEnvironmentContext) => Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -23892,12 +25121,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -23907,12 +25136,12 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -23958,13 +25187,13 @@ export class TestRedisResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -24009,27 +25238,27 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** Gets the endpoints */ @@ -24048,12 +25277,12 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + rpcArgs + ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Adds a dependency on another resource */ + withDependency(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withDependencyInternal(dependency)); + } + + /** @internal */ + private async _withEndpointsInternal(endpoints: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, endpoints }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + rpcArgs + ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Sets the endpoints */ + withEndpoints(endpoints: string[]): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEndpointsInternal(endpoints)); + } + + /** @internal */ + private async _withEnvironmentVariablesInternal(variables: Record): Promise { + const rpcArgs: Record = { builder: this._handle, variables }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + rpcArgs + ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Sets environment variables */ + withEnvironmentVariables(variables: Record): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); + } + + /** Gets the status of the resource asynchronously */ + async getStatusAsync(options?: GetStatusAsyncOptions): Promise { + const cancellationToken = options?.cancellationToken; + const rpcArgs: Record = { builder: this._handle }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + return await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/getStatusAsync', + rpcArgs + ); + } + + /** @internal */ + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { + const operationId = registerCallback(async (argData: unknown) => { + const arg = CancellationToken.fromValue(argData); + await operation(arg); + }); + const rpcArgs: Record = { builder: this._handle, operation: operationId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', + rpcArgs + ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Performs a cancellable operation */ + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** Waits for the resource to be ready */ + async waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise { + const cancellationToken = options?.cancellationToken; + const rpcArgs: Record = { builder: this._handle, timeout }; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); + return await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/waitForReadyAsync', + rpcArgs + ); + } + + /** @internal */ + private async _withMultiParamHandleCallbackInternal(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): Promise { + const callbackId = registerCallback(async (arg1Data: unknown, arg2Data: unknown) => { + const arg1Handle = wrapIfHandle(arg1Data) as TestCallbackContextHandle; + const arg1 = new TestCallbackContextImpl(arg1Handle, this._client); + const arg2Handle = wrapIfHandle(arg2Data) as TestEnvironmentContextHandle; + const arg2 = new TestEnvironmentContextImpl(arg2Handle, this._client); + await callback(arg1, arg2); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMultiParamHandleCallback', + rpcArgs + ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Tests multi-param callback destructuring */ + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMultiParamHandleCallbackInternal(callback)); + } + + /** @internal */ + private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (name !== undefined) rpcArgs.name = name; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDataVolume', + rpcArgs + ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Adds a data volume with persistence */ + withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new TestRedisResourcePromiseImpl(this._withDataVolumeInternal(name, isReadOnly)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withDependencyInternal(dependency)); + /** Adds a label to the resource */ + withMergeLabel(label: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMergeLabelInternal(label)); } /** @internal */ - private async _withEndpointsInternal(endpoints: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, endpoints }; + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Sets the endpoints */ - withEndpoints(endpoints: string[]): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEndpointsInternal(endpoints)); + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); } /** @internal */ - private async _withEnvironmentVariablesInternal(variables: Record): Promise { - const rpcArgs: Record = { builder: this._handle, variables }; + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Sets environment variables */ - withEnvironmentVariables(variables: Record): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentVariablesInternal(variables)); + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); } - /** Gets the status of the resource asynchronously */ - async getStatusAsync(options?: GetStatusAsyncOptions): Promise { - const cancellationToken = options?.cancellationToken; - const rpcArgs: Record = { builder: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); - return await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/getStatusAsync', + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', rpcArgs ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { - const operationId = registerCallback(async (argData: unknown) => { - const arg = CancellationToken.fromValue(argData); - await operation(arg); - }); - const rpcArgs: Record = { builder: this._handle, operation: operationId }; + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withCancellableOperationInternal(operation)); + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new TestRedisResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); } - /** Waits for the resource to be ready */ - async waitForReadyAsync(timeout: number, options?: WaitForReadyAsyncOptions): Promise { - const cancellationToken = options?.cancellationToken; - const rpcArgs: Record = { builder: this._handle, timeout }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); - return await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/waitForReadyAsync', + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', rpcArgs ); + return new TestRedisResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new TestRedisResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); } /** @internal */ - private async _withMultiParamHandleCallbackInternal(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): Promise { - const callbackId = registerCallback(async (arg1Data: unknown, arg2Data: unknown) => { - const arg1Handle = wrapIfHandle(arg1Data) as TestCallbackContextHandle; - const arg1 = new TestCallbackContext(arg1Handle, this._client); - const arg2Handle = wrapIfHandle(arg2Data) as TestEnvironmentContextHandle; - const arg2 = new TestEnvironmentContext(arg2Handle, this._client); - await callback(arg1, arg2); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMultiParamHandleCallback', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Tests multi-param callback destructuring */ - withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withMultiParamHandleCallbackInternal(callback)); + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); } /** @internal */ - private async _withDataVolumeInternal(name?: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (name !== undefined) rpcArgs.name = name; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDataVolume', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', rpcArgs ); - return new TestRedisResource(result, this._client); + return new TestRedisResourceImpl(result, this._client); } - /** Adds a data volume with persistence */ - withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new TestRedisResourcePromise(this._withDataVolumeInternal(name, isReadOnly)); + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -24205,7 +25562,7 @@ export class TestRedisResource extends ResourceBuilderBase { +class TestRedisResourcePromiseImpl implements TestRedisResourcePromise { constructor(private _promise: Promise) {} then( @@ -24216,378 +25573,363 @@ export class TestRedisResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options))); } /** Sets the container entrypoint */ withEntrypoint(entrypoint: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint))); } /** Sets the container image tag */ withImageTag(tag: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag))); } /** Sets the container image registry */ withImageRegistry(registry: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry))); } /** Sets the container image */ withImage(image: string, options?: WithImageOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options))); } /** Sets the image SHA256 digest */ withImageSHA256(sha256: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256))); } /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); } /** Sets the lifetime behavior of the container resource */ withLifetime(lifetime: ContainerLifetime): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime))); } /** Sets the container image pull policy */ withImagePullPolicy(pullPolicy: ImagePullPolicy): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); } /** Configures the resource to be published as a container */ publishAsContainer(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer())); } /** Configures the resource to use a Dockerfile */ withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options))); } /** Sets the container name */ withContainerName(name: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name))); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value))); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + withBuildSecret(name: string, value: ParameterResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value))); } /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a network alias for the container */ withContainerNetworkAlias(alias: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); } /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } /** Publishes the resource as a connection string */ publishAsConnectionString(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString())); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + withConnectionProperty(name: string, value: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value))); } /** Adds a connection property with a string value */ withConnectionPropertyValue(name: string, value: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } /** Adds arguments */ withArgs(args: string[]): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withReference(source, options))); - } - - /** Gets a connection property by key */ - getConnectionProperty(key: string): Promise { - return this._promise.then(obj => obj.getConnectionProperty(key)); + withReference(source: HandleReference, options?: WithReferenceOptions): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Adds a volume */ withVolume(target: string, options?: WithVolumeOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options))); } /** Gets the resource name */ @@ -24596,53 +25938,53 @@ export class TestRedisResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds a child database to a test Redis resource */ addTestChildDatabase(name: string, options?: AddTestChildDatabaseOptions): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.addTestChildDatabase(name, options))); + return new TestDatabaseResourcePromiseImpl(this._promise.then(obj => obj.addTestChildDatabase(name, options))); } /** Configures the Redis resource with persistence */ withPersistence(options?: WithPersistenceOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withPersistence(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withPersistence(options))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Gets the tags for the resource */ @@ -24656,53 +25998,53 @@ export class TestRedisResourcePromise implements PromiseLike } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionString(connectionString))); + withConnectionString(connectionString: ReferenceExpression): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionString(connectionString))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Gets the endpoints */ @@ -24712,27 +26054,27 @@ export class TestRedisResourcePromise implements PromiseLike /** Sets connection string using direct interface target */ withConnectionStringDirect(connectionString: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); } /** Redis-specific configuration */ withRedisSpecific(option: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withRedisSpecific(option))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withRedisSpecific(option))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Gets the status of the resource asynchronously */ @@ -24741,8 +26083,8 @@ export class TestRedisResourcePromise implements PromiseLike } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } /** Waits for the resource to be ready */ @@ -24751,238 +26093,290 @@ export class TestRedisResourcePromise implements PromiseLike } /** Tests multi-param callback destructuring */ - withMultiParamHandleCallback(callback: (arg1: ITestCallbackContext, arg2: ITestEnvironmentContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withMultiParamHandleCallback(callback))); + withMultiParamHandleCallback(callback: (arg1: TestCallbackContext, arg2: TestEnvironmentContext) => Promise): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMultiParamHandleCallback(callback))); } /** Adds a data volume with persistence */ withDataVolume(options?: WithDataVolumeOptions): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withDataVolume(options))); } -} + /** Adds a label to the resource */ + withMergeLabel(label: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } -// ============================================================================ -// ITestVaultResource -// ============================================================================ + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestRedisResourcePromise { + return new TestRedisResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); + } -export interface ITestVaultResource { - toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): ITestVaultResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestVaultResourcePromise; - withEntrypoint(entrypoint: string): ITestVaultResourcePromise; - withImageTag(tag: string): ITestVaultResourcePromise; - withImageRegistry(registry: string): ITestVaultResourcePromise; - withImage(image: string, options?: WithImageOptions): ITestVaultResourcePromise; - withImageSHA256(sha256: string): ITestVaultResourcePromise; - withContainerRuntimeArgs(args: string[]): ITestVaultResourcePromise; - withLifetime(lifetime: ContainerLifetime): ITestVaultResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestVaultResourcePromise; - publishAsContainer(): ITestVaultResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestVaultResourcePromise; - withContainerName(name: string): ITestVaultResourcePromise; - withBuildArg(name: string, value: IParameterResource): ITestVaultResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ITestVaultResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ITestVaultResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestVaultResourcePromise; - withContainerNetworkAlias(alias: string): ITestVaultResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ITestVaultResourcePromise; - withOtlpExporter(): ITestVaultResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ITestVaultResourcePromise; - publishAsConnectionString(): ITestVaultResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestVaultResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestVaultResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestVaultResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestVaultResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ITestVaultResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestVaultResourcePromise; - withArgs(args: string[]): ITestVaultResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ITestVaultResourcePromise; - withReferenceUri(name: string, uri: string): ITestVaultResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ITestVaultResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ITestVaultResourcePromise; - withEndpoint(options?: WithEndpointOptions): ITestVaultResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ITestVaultResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestVaultResourcePromise; - withExternalHttpEndpoints(): ITestVaultResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ITestVaultResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ITestVaultResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestVaultResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestVaultResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestVaultResourcePromise; - excludeFromManifest(): ITestVaultResourcePromise; - waitFor(dependency: IHandleReference): ITestVaultResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; - waitForStart(dependency: IHandleReference): ITestVaultResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; - withExplicitStart(): ITestVaultResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestVaultResourcePromise; - withHealthCheck(key: string): ITestVaultResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestVaultResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestVaultResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ITestVaultResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ITestVaultResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestVaultResourcePromise; - withoutHttpsCertificate(): ITestVaultResourcePromise; - withParentRelationship(parent: IHandleReference): ITestVaultResourcePromise; - withChildRelationship(child: IHandleReference): ITestVaultResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ITestVaultResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestVaultResourcePromise; - excludeFromMcp(): ITestVaultResourcePromise; - withRemoteImageName(remoteImageName: string): ITestVaultResourcePromise; - withRemoteImageTag(remoteImageTag: string): ITestVaultResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestVaultResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ITestVaultResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestVaultResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestVaultResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestVaultResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestVaultResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestVaultResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; - withConfig(config: TestConfigDto): ITestVaultResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; - withCreatedAt(createdAt: string): ITestVaultResourcePromise; - withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; - withCorrelationId(correlationId: string): ITestVaultResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; - withStatus(status: TestResourceStatus): ITestVaultResourcePromise; - withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; - testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; - withDependency(dependency: IHandleReference): ITestVaultResourcePromise; - withEndpoints(endpoints: string[]): ITestVaultResourcePromise; - withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; - withVaultDirect(option: string): ITestVaultResourcePromise; -} - -export interface ITestVaultResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): ITestVaultResourcePromise; - withBindMount(source: string, target: string, options?: WithBindMountOptions): ITestVaultResourcePromise; - withEntrypoint(entrypoint: string): ITestVaultResourcePromise; - withImageTag(tag: string): ITestVaultResourcePromise; - withImageRegistry(registry: string): ITestVaultResourcePromise; - withImage(image: string, options?: WithImageOptions): ITestVaultResourcePromise; - withImageSHA256(sha256: string): ITestVaultResourcePromise; - withContainerRuntimeArgs(args: string[]): ITestVaultResourcePromise; - withLifetime(lifetime: ContainerLifetime): ITestVaultResourcePromise; - withImagePullPolicy(pullPolicy: ImagePullPolicy): ITestVaultResourcePromise; - publishAsContainer(): ITestVaultResourcePromise; - withDockerfile(contextPath: string, options?: WithDockerfileOptions): ITestVaultResourcePromise; - withContainerName(name: string): ITestVaultResourcePromise; - withBuildArg(name: string, value: IParameterResource): ITestVaultResourcePromise; - withBuildSecret(name: string, value: IParameterResource): ITestVaultResourcePromise; - withEndpointProxySupport(proxyEnabled: boolean): ITestVaultResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ITestVaultResourcePromise; - withContainerNetworkAlias(alias: string): ITestVaultResourcePromise; - withMcpServer(options?: WithMcpServerOptions): ITestVaultResourcePromise; - withOtlpExporter(): ITestVaultResourcePromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): ITestVaultResourcePromise; - publishAsConnectionString(): ITestVaultResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ITestVaultResourcePromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ITestVaultResourcePromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ITestVaultResourcePromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ITestVaultResourcePromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): ITestVaultResourcePromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ITestVaultResourcePromise; - withArgs(args: string[]): ITestVaultResourcePromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ITestVaultResourcePromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): ITestVaultResourcePromise; - withReferenceUri(name: string, uri: string): ITestVaultResourcePromise; - withReferenceExternalService(externalService: IExternalServiceResource): ITestVaultResourcePromise; - withReferenceEndpoint(endpointReference: IEndpointReference): ITestVaultResourcePromise; - withEndpoint(options?: WithEndpointOptions): ITestVaultResourcePromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): ITestVaultResourcePromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): ITestVaultResourcePromise; - withExternalHttpEndpoints(): ITestVaultResourcePromise; - getEndpoint(name: string): Promise; - asHttp2Service(): ITestVaultResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ITestVaultResourcePromise; - withUrl(url: string, options?: WithUrlOptions): ITestVaultResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ITestVaultResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ITestVaultResourcePromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ITestVaultResourcePromise; - excludeFromManifest(): ITestVaultResourcePromise; - waitFor(dependency: IHandleReference): ITestVaultResourcePromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; - waitForStart(dependency: IHandleReference): ITestVaultResourcePromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ITestVaultResourcePromise; - withExplicitStart(): ITestVaultResourcePromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ITestVaultResourcePromise; - withHealthCheck(key: string): ITestVaultResourcePromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ITestVaultResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ITestVaultResourcePromise; - withDeveloperCertificateTrust(trust: boolean): ITestVaultResourcePromise; - withCertificateTrustScope(scope: CertificateTrustScope): ITestVaultResourcePromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ITestVaultResourcePromise; - withoutHttpsCertificate(): ITestVaultResourcePromise; - withParentRelationship(parent: IHandleReference): ITestVaultResourcePromise; - withChildRelationship(child: IHandleReference): ITestVaultResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): ITestVaultResourcePromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ITestVaultResourcePromise; - excludeFromMcp(): ITestVaultResourcePromise; - withRemoteImageName(remoteImageName: string): ITestVaultResourcePromise; - withRemoteImageTag(remoteImageTag: string): ITestVaultResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ITestVaultResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ITestVaultResourcePromise; - withVolume(target: string, options?: WithVolumeOptions): ITestVaultResourcePromise; - getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ITestVaultResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ITestVaultResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ITestVaultResourcePromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ITestVaultResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ITestVaultResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): ITestVaultResourcePromise; - withConfig(config: TestConfigDto): ITestVaultResourcePromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ITestVaultResourcePromise; - withCreatedAt(createdAt: string): ITestVaultResourcePromise; - withModifiedAt(modifiedAt: string): ITestVaultResourcePromise; - withCorrelationId(correlationId: string): ITestVaultResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): ITestVaultResourcePromise; - withStatus(status: TestResourceStatus): ITestVaultResourcePromise; - withNestedConfig(config: TestNestedDto): ITestVaultResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): ITestVaultResourcePromise; - testWaitFor(dependency: IHandleReference): ITestVaultResourcePromise; - withDependency(dependency: IHandleReference): ITestVaultResourcePromise; - withEndpoints(endpoints: string[]): ITestVaultResourcePromise; - withEnvironmentVariables(variables: Record): ITestVaultResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ITestVaultResourcePromise; - withVaultDirect(option: string): ITestVaultResourcePromise; } // ============================================================================ // TestVaultResource // ============================================================================ -export class TestVaultResource extends ResourceBuilderBase { +export interface TestVaultResource { + toJSON(): MarshalledHandle; + withContainerRegistry(registry: HandleReference): TestVaultResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): TestVaultResourcePromise; + withEntrypoint(entrypoint: string): TestVaultResourcePromise; + withImageTag(tag: string): TestVaultResourcePromise; + withImageRegistry(registry: string): TestVaultResourcePromise; + withImage(image: string, options?: WithImageOptions): TestVaultResourcePromise; + withImageSHA256(sha256: string): TestVaultResourcePromise; + withContainerRuntimeArgs(args: string[]): TestVaultResourcePromise; + withLifetime(lifetime: ContainerLifetime): TestVaultResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): TestVaultResourcePromise; + publishAsContainer(): TestVaultResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestVaultResourcePromise; + withContainerName(name: string): TestVaultResourcePromise; + withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise; + withBuildSecret(name: string, value: ParameterResource): TestVaultResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): TestVaultResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestVaultResourcePromise; + withContainerNetworkAlias(alias: string): TestVaultResourcePromise; + withMcpServer(options?: WithMcpServerOptions): TestVaultResourcePromise; + withOtlpExporter(): TestVaultResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): TestVaultResourcePromise; + publishAsConnectionString(): TestVaultResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestVaultResourcePromise; + withEnvironment(name: string, value: string): TestVaultResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): TestVaultResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestVaultResourcePromise; + withArgs(args: string[]): TestVaultResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): TestVaultResourcePromise; + withReferenceUri(name: string, uri: string): TestVaultResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): TestVaultResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): TestVaultResourcePromise; + withEndpoint(options?: WithEndpointOptions): TestVaultResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): TestVaultResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestVaultResourcePromise; + withExternalHttpEndpoints(): TestVaultResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): TestVaultResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise; + withUrl(url: string, options?: WithUrlOptions): TestVaultResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestVaultResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestVaultResourcePromise; + excludeFromManifest(): TestVaultResourcePromise; + waitFor(dependency: HandleReference): TestVaultResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise; + waitForStart(dependency: HandleReference): TestVaultResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise; + withExplicitStart(): TestVaultResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise; + withHealthCheck(key: string): TestVaultResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestVaultResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise; + withDeveloperCertificateTrust(trust: boolean): TestVaultResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): TestVaultResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestVaultResourcePromise; + withoutHttpsCertificate(): TestVaultResourcePromise; + withParentRelationship(parent: HandleReference): TestVaultResourcePromise; + withChildRelationship(child: HandleReference): TestVaultResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): TestVaultResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestVaultResourcePromise; + excludeFromMcp(): TestVaultResourcePromise; + withRemoteImageName(remoteImageName: string): TestVaultResourcePromise; + withRemoteImageTag(remoteImageTag: string): TestVaultResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestVaultResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): TestVaultResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestVaultResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestVaultResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestVaultResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestVaultResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestVaultResourcePromise; + withConfig(config: TestConfigDto): TestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise; + withCreatedAt(createdAt: string): TestVaultResourcePromise; + withModifiedAt(modifiedAt: string): TestVaultResourcePromise; + withCorrelationId(correlationId: string): TestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestVaultResourcePromise; + withStatus(status: TestResourceStatus): TestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): TestVaultResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise; + testWaitFor(dependency: HandleReference): TestVaultResourcePromise; + withDependency(dependency: HandleReference): TestVaultResourcePromise; + withEndpoints(endpoints: string[]): TestVaultResourcePromise; + withEnvironmentVariables(variables: Record): TestVaultResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise; + withVaultDirect(option: string): TestVaultResourcePromise; + withMergeLabel(label: string): TestVaultResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise; +} + +export interface TestVaultResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): TestVaultResourcePromise; + withBindMount(source: string, target: string, options?: WithBindMountOptions): TestVaultResourcePromise; + withEntrypoint(entrypoint: string): TestVaultResourcePromise; + withImageTag(tag: string): TestVaultResourcePromise; + withImageRegistry(registry: string): TestVaultResourcePromise; + withImage(image: string, options?: WithImageOptions): TestVaultResourcePromise; + withImageSHA256(sha256: string): TestVaultResourcePromise; + withContainerRuntimeArgs(args: string[]): TestVaultResourcePromise; + withLifetime(lifetime: ContainerLifetime): TestVaultResourcePromise; + withImagePullPolicy(pullPolicy: ImagePullPolicy): TestVaultResourcePromise; + publishAsContainer(): TestVaultResourcePromise; + withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestVaultResourcePromise; + withContainerName(name: string): TestVaultResourcePromise; + withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise; + withBuildSecret(name: string, value: ParameterResource): TestVaultResourcePromise; + withEndpointProxySupport(proxyEnabled: boolean): TestVaultResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestVaultResourcePromise; + withContainerNetworkAlias(alias: string): TestVaultResourcePromise; + withMcpServer(options?: WithMcpServerOptions): TestVaultResourcePromise; + withOtlpExporter(): TestVaultResourcePromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): TestVaultResourcePromise; + publishAsConnectionString(): TestVaultResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestVaultResourcePromise; + withEnvironment(name: string, value: string): TestVaultResourcePromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): TestVaultResourcePromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestVaultResourcePromise; + withArgs(args: string[]): TestVaultResourcePromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise; + withReference(source: HandleReference, options?: WithReferenceOptions): TestVaultResourcePromise; + withReferenceUri(name: string, uri: string): TestVaultResourcePromise; + withReferenceExternalService(externalService: ExternalServiceResource): TestVaultResourcePromise; + withReferenceEndpoint(endpointReference: EndpointReference): TestVaultResourcePromise; + withEndpoint(options?: WithEndpointOptions): TestVaultResourcePromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): TestVaultResourcePromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestVaultResourcePromise; + withExternalHttpEndpoints(): TestVaultResourcePromise; + getEndpoint(name: string): Promise; + asHttp2Service(): TestVaultResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise; + withUrl(url: string, options?: WithUrlOptions): TestVaultResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestVaultResourcePromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestVaultResourcePromise; + excludeFromManifest(): TestVaultResourcePromise; + waitFor(dependency: HandleReference): TestVaultResourcePromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise; + waitForStart(dependency: HandleReference): TestVaultResourcePromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise; + withExplicitStart(): TestVaultResourcePromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise; + withHealthCheck(key: string): TestVaultResourcePromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestVaultResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise; + withDeveloperCertificateTrust(trust: boolean): TestVaultResourcePromise; + withCertificateTrustScope(scope: CertificateTrustScope): TestVaultResourcePromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestVaultResourcePromise; + withoutHttpsCertificate(): TestVaultResourcePromise; + withParentRelationship(parent: HandleReference): TestVaultResourcePromise; + withChildRelationship(child: HandleReference): TestVaultResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): TestVaultResourcePromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestVaultResourcePromise; + excludeFromMcp(): TestVaultResourcePromise; + withRemoteImageName(remoteImageName: string): TestVaultResourcePromise; + withRemoteImageTag(remoteImageTag: string): TestVaultResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestVaultResourcePromise; + withVolume(target: string, options?: WithVolumeOptions): TestVaultResourcePromise; + getResourceName(): Promise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestVaultResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestVaultResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestVaultResourcePromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestVaultResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): TestVaultResourcePromise; + withConfig(config: TestConfigDto): TestVaultResourcePromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise; + withCreatedAt(createdAt: string): TestVaultResourcePromise; + withModifiedAt(modifiedAt: string): TestVaultResourcePromise; + withCorrelationId(correlationId: string): TestVaultResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): TestVaultResourcePromise; + withStatus(status: TestResourceStatus): TestVaultResourcePromise; + withNestedConfig(config: TestNestedDto): TestVaultResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise; + testWaitFor(dependency: HandleReference): TestVaultResourcePromise; + withDependency(dependency: HandleReference): TestVaultResourcePromise; + withEndpoints(endpoints: string[]): TestVaultResourcePromise; + withEnvironmentVariables(variables: Record): TestVaultResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise; + withVaultDirect(option: string): TestVaultResourcePromise; + withMergeLabel(label: string): TestVaultResourcePromise; + withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise; + withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise; +} + +// ============================================================================ +// TestVaultResourceImpl +// ============================================================================ + +class TestVaultResourceImpl extends ResourceBuilderBase implements TestVaultResource { constructor(handle: TestVaultResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -24993,13 +26387,13 @@ export class TestVaultResource extends ResourceBuilderBase { + 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', + 'Aspire.Hosting/withBuildArg', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withBuildArgInternal(name, value)); + withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withBuildSecretInternal(name: string, value: IParameterResource): Promise { + 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', + 'Aspire.Hosting/withBuildSecret', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withBuildSecretInternal(name, value)); + withBuildSecret(name: string, value: ParameterResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withBuildSecretInternal(name, value)); } /** @internal */ @@ -25210,12 +26604,12 @@ export class TestVaultResource extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ @@ -25420,19 +26829,19 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -25440,36 +26849,16 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withArgsCallbackInternal(callback)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -25478,15 +26867,15 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -25549,7 +26938,7 @@ export class TestVaultResource extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -25646,19 +27035,19 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -25666,32 +27055,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -25702,30 +27071,30 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise { const displayText = options?.displayText; - return new TestVaultResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new TestVaultResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -25739,19 +27108,19 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new TestVaultResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: IEndpointReference) => Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -25759,12 +27128,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ @@ -25774,72 +27143,72 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ @@ -25849,29 +27218,29 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise { const exitCode = options?.exitCode; - return new TestVaultResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + return new TestVaultResourcePromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } /** @internal */ @@ -25881,12 +27250,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -25923,13 +27292,13 @@ export class TestVaultResource extends ResourceBuilderBase Promise, options?: WithCommandOptions): TestVaultResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise { const commandOptions = options?.commandOptions; - return new TestVaultResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new TestVaultResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ @@ -25939,12 +27308,12 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestVaultResourcePromise { const password = options?.password; - return new TestVaultResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + return new TestVaultResourcePromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -25986,42 +27355,42 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -26032,13 +27401,13 @@ export class TestVaultResource extends ResourceBuilderBase Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -26131,43 +27500,23 @@ export class TestVaultResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new TestVaultResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new TestVaultResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -26175,12 +27524,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** @internal */ @@ -26192,14 +27541,14 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -26223,19 +27572,19 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -26243,19 +27592,19 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -26263,19 +27612,19 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceEndpointsAllocatedInternal(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -26283,19 +27632,19 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -26303,12 +27652,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -26320,14 +27669,14 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -26357,12 +27706,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -26372,12 +27721,12 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -26423,13 +27772,13 @@ export class TestVaultResource extends ResourceBuilderBase Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Adds validation callback */ + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withValidatorInternal(validator)); + } + + /** @internal */ + private async _testWaitForInternal(dependency: HandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Waits for another resource (test version) */ + testWaitFor(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._testWaitForInternal(dependency)); + } + + /** @internal */ + private async _withDependencyInternal(dependency: HandleReference): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Adds a dependency on another resource */ + withDependency(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withDependencyInternal(dependency)); + } + + /** @internal */ + private async _withEndpointsInternal(endpoints: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, endpoints }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Sets the endpoints */ + withEndpoints(endpoints: string[]): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEndpointsInternal(endpoints)); + } + + /** @internal */ + private async _withEnvironmentVariablesInternal(variables: Record): Promise { + const rpcArgs: Record = { builder: this._handle, variables }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Sets environment variables */ + withEnvironmentVariables(variables: Record): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withEnvironmentVariablesInternal(variables)); + } + + /** @internal */ + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { + const operationId = registerCallback(async (argData: unknown) => { + const arg = CancellationToken.fromValue(argData); + await operation(arg); + }); + const rpcArgs: Record = { builder: this._handle, operation: operationId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Performs a cancellable operation */ + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withVaultDirectInternal(option: string): Promise { + const rpcArgs: Record = { builder: this._handle, option }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withVaultDirect', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Configures vault using direct interface target */ + withVaultDirect(option: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withVaultDirectInternal(option)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new TestVaultResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withValidatorInternal(validator)); + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._testWaitForInternal(dependency)); + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withDependencyInternal(dependency)); + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); } /** @internal */ - private async _withEndpointsInternal(endpoints: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, endpoints }; + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Sets the endpoints */ - withEndpoints(endpoints: string[]): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEndpointsInternal(endpoints)); + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new TestVaultResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); } /** @internal */ - private async _withEnvironmentVariablesInternal(variables: Record): Promise { - const rpcArgs: Record = { builder: this._handle, variables }; + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEnvironmentVariables', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Sets environment variables */ - withEnvironmentVariables(variables: Record): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentVariablesInternal(variables)); + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new TestVaultResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { - const operationId = registerCallback(async (argData: unknown) => { - const arg = CancellationToken.fromValue(argData); - await operation(arg); - }); - const rpcArgs: Record = { builder: this._handle, operation: operationId }; + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withCancellableOperationInternal(operation)); + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); } /** @internal */ - private async _withVaultDirectInternal(option: string): Promise { - const rpcArgs: Record = { builder: this._handle, option }; + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withVaultDirect', + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', rpcArgs ); - return new TestVaultResource(result, this._client); + return new TestVaultResourceImpl(result, this._client); } - /** Configures vault using direct interface target */ - withVaultDirect(option: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withVaultDirectInternal(option)); + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -26583,7 +28060,7 @@ export class TestVaultResource extends ResourceBuilderBase { +class TestVaultResourcePromiseImpl implements TestVaultResourcePromise { constructor(private _promise: Promise) {} then( @@ -26594,363 +28071,353 @@ export class TestVaultResourcePromise implements PromiseLike } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Adds a bind mount */ withBindMount(source: string, target: string, options?: WithBindMountOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withBindMount(source, target, options))); } /** Sets the container entrypoint */ withEntrypoint(entrypoint: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEntrypoint(entrypoint))); } /** Sets the container image tag */ withImageTag(tag: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withImageTag(tag))); } /** Sets the container image registry */ withImageRegistry(registry: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withImageRegistry(registry))); } /** Sets the container image */ withImage(image: string, options?: WithImageOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withImage(image, options))); } /** Sets the image SHA256 digest */ withImageSHA256(sha256: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withImageSHA256(sha256))); } /** Adds runtime arguments for the container */ withContainerRuntimeArgs(args: string[]): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); } /** Sets the lifetime behavior of the container resource */ withLifetime(lifetime: ContainerLifetime): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withLifetime(lifetime))); } /** Sets the container image pull policy */ withImagePullPolicy(pullPolicy: ImagePullPolicy): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); } /** Configures the resource to be published as a container */ publishAsContainer(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.publishAsContainer())); } /** Configures the resource to use a Dockerfile */ withDockerfile(contextPath: string, options?: WithDockerfileOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withDockerfile(contextPath, options))); } /** Sets the container name */ withContainerName(name: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withContainerName(name))); } /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: IParameterResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withBuildArg(name, value))); } /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: IParameterResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + withBuildSecret(name: string, value: ParameterResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withBuildSecret(name, value))); } /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a network alias for the container */ withContainerNetworkAlias(alias: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); } /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Configures OTLP telemetry export */ withOtlpExporter(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } /** Publishes the resource as a connection string */ publishAsConnectionString(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.publishAsConnectionString())); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + } + + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds arguments */ withArgs(args: string[]): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withArgs(args))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + waitFor(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Prevents resource from starting automatically */ withExplicitStart(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } /** Adds a health check by key */ withHealthCheck(key: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Adds a volume */ withVolume(target: string, options?: WithVolumeOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withVolume(target, options))); } /** Gets the resource name */ @@ -26959,132 +28426,172 @@ export class TestVaultResourcePromise implements PromiseLike } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); } /** Configures vault using direct interface target */ withVaultDirect(option: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withVaultDirect(option))); + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withVaultDirect(option))); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): TestVaultResourcePromise { + return new TestVaultResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// IComputeResource +// ComputeResource // ============================================================================ -export interface IComputeResource { +export interface ComputeResource { toJSON(): MarshalledHandle; - withRemoteImageName(remoteImageName: string): IComputeResourcePromise; - withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; + withRemoteImageName(remoteImageName: string): ComputeResourcePromise; + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise; } -export interface IComputeResourcePromise extends PromiseLike { - withRemoteImageName(remoteImageName: string): IComputeResourcePromise; - withRemoteImageTag(remoteImageTag: string): IComputeResourcePromise; +export interface ComputeResourcePromise extends PromiseLike { + withRemoteImageName(remoteImageName: string): ComputeResourcePromise; + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise; } // ============================================================================ -// ComputeResource +// ComputeResourceImpl // ============================================================================ -export class ComputeResource extends ResourceBuilderBase { +class ComputeResourceImpl extends ResourceBuilderBase implements ComputeResource { constructor(handle: IComputeResourceHandle, client: AspireClientRpc) { super(handle, client); } @@ -27096,12 +28603,12 @@ export class ComputeResource extends ResourceBuilderBase 'Aspire.Hosting/withRemoteImageName', rpcArgs ); - return new ComputeResource(result, this._client); + return new ComputeResourceImpl(result, this._client); } /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + return new ComputeResourcePromiseImpl(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ @@ -27111,12 +28618,12 @@ export class ComputeResource extends ResourceBuilderBase 'Aspire.Hosting/withRemoteImageTag', rpcArgs ); - return new ComputeResource(result, this._client); + return new ComputeResourceImpl(result, this._client); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + return new ComputeResourcePromiseImpl(this._withRemoteImageTagInternal(remoteImageTag)); } } @@ -27126,7 +28633,7 @@ export class ComputeResource extends ResourceBuilderBase * @example * await builder.addSomething().withX().withY(); */ -export class ComputeResourcePromise implements PromiseLike { +class ComputeResourcePromiseImpl implements ComputeResourcePromise { constructor(private _promise: Promise) {} then( @@ -27138,51 +28645,51 @@ export class ComputeResourcePromise implements PromiseLike { /** Sets the remote image name for publishing */ withRemoteImageName(remoteImageName: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + return new ComputeResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } /** Sets the remote image tag for publishing */ withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { - return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + return new ComputeResourcePromiseImpl(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } } // ============================================================================ -// IContainerFilesDestinationResource +// ContainerFilesDestinationResource // ============================================================================ -export interface IContainerFilesDestinationResource { +export interface ContainerFilesDestinationResource { toJSON(): MarshalledHandle; - publishWithContainerFiles(source: IHandleReference, destinationPath: string): IContainerFilesDestinationResourcePromise; + publishWithContainerFiles(source: HandleReference, destinationPath: string): ContainerFilesDestinationResourcePromise; } -export interface IContainerFilesDestinationResourcePromise extends PromiseLike { - publishWithContainerFiles(source: IHandleReference, destinationPath: string): IContainerFilesDestinationResourcePromise; +export interface ContainerFilesDestinationResourcePromise extends PromiseLike { + publishWithContainerFiles(source: HandleReference, destinationPath: string): ContainerFilesDestinationResourcePromise; } // ============================================================================ -// ContainerFilesDestinationResource +// ContainerFilesDestinationResourceImpl // ============================================================================ -export class ContainerFilesDestinationResource extends ResourceBuilderBase { +class ContainerFilesDestinationResourceImpl extends ResourceBuilderBase implements ContainerFilesDestinationResource { constructor(handle: IContainerFilesDestinationResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _publishWithContainerFilesInternal(source: IHandleReference, destinationPath: string): Promise { + private async _publishWithContainerFilesInternal(source: HandleReference, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFilesFromResource', + 'Aspire.Hosting/publishWithContainerFiles', rpcArgs ); - return new ContainerFilesDestinationResource(result, this._client); + return new ContainerFilesDestinationResourceImpl(result, this._client); } /** Configures the resource to copy container files from the specified source during publishing */ - publishWithContainerFiles(source: IHandleReference, destinationPath: string): ContainerFilesDestinationResourcePromise { - return new ContainerFilesDestinationResourcePromise(this._publishWithContainerFilesInternal(source, destinationPath)); + publishWithContainerFiles(source: HandleReference, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromiseImpl(this._publishWithContainerFilesInternal(source, destinationPath)); } } @@ -27192,7 +28699,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { +class ContainerFilesDestinationResourcePromiseImpl implements ContainerFilesDestinationResourcePromise { constructor(private _promise: Promise) {} then( @@ -27203,119 +28710,131 @@ export class ContainerFilesDestinationResourcePromise implements PromiseLike obj.publishWithContainerFiles(source, destinationPath))); + publishWithContainerFiles(source: HandleReference, destinationPath: string): ContainerFilesDestinationResourcePromise { + return new ContainerFilesDestinationResourcePromiseImpl(this._promise.then(obj => obj.publishWithContainerFiles(source, destinationPath))); } } // ============================================================================ -// IResource +// Resource // ============================================================================ -export interface IResource { +export interface Resource { toJSON(): MarshalledHandle; - withContainerRegistry(registry: IHandleReference): IResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; - excludeFromManifest(): IResourcePromise; - withExplicitStart(): IResourcePromise; - withHealthCheck(key: string): IResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; - withParentRelationship(parent: IHandleReference): IResourcePromise; - withChildRelationship(child: IHandleReference): IResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; - excludeFromMcp(): IResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; + withContainerRegistry(registry: HandleReference): ResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise; + excludeFromManifest(): ResourcePromise; + withExplicitStart(): ResourcePromise; + withHealthCheck(key: string): ResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise; + withParentRelationship(parent: HandleReference): ResourcePromise; + withChildRelationship(child: HandleReference): ResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise; + excludeFromMcp(): ResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; - withConfig(config: TestConfigDto): IResourcePromise; - withCreatedAt(createdAt: string): IResourcePromise; - withModifiedAt(modifiedAt: string): IResourcePromise; - withCorrelationId(correlationId: string): IResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; - withStatus(status: TestResourceStatus): IResourcePromise; - withNestedConfig(config: TestNestedDto): IResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; - testWaitFor(dependency: IHandleReference): IResourcePromise; - withDependency(dependency: IHandleReference): IResourcePromise; - withEndpoints(endpoints: string[]): IResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; -} - -export interface IResourcePromise extends PromiseLike { - withContainerRegistry(registry: IHandleReference): IResourcePromise; - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): IResourcePromise; - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): IResourcePromise; - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): IResourcePromise; - withUrl(url: string, options?: WithUrlOptions): IResourcePromise; - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): IResourcePromise; - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): IResourcePromise; - excludeFromManifest(): IResourcePromise; - withExplicitStart(): IResourcePromise; - withHealthCheck(key: string): IResourcePromise; - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): IResourcePromise; - withParentRelationship(parent: IHandleReference): IResourcePromise; - withChildRelationship(child: IHandleReference): IResourcePromise; - withIconName(iconName: string, options?: WithIconNameOptions): IResourcePromise; - excludeFromMcp(): IResourcePromise; - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): IResourcePromise; - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): IResourcePromise; - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): IResourcePromise; + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ResourcePromise; + withConfig(config: TestConfigDto): ResourcePromise; + withCreatedAt(createdAt: string): ResourcePromise; + withModifiedAt(modifiedAt: string): ResourcePromise; + withCorrelationId(correlationId: string): ResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise; + withStatus(status: TestResourceStatus): ResourcePromise; + withNestedConfig(config: TestNestedDto): ResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise; + testWaitFor(dependency: HandleReference): ResourcePromise; + withDependency(dependency: HandleReference): ResourcePromise; + withEndpoints(endpoints: string[]): ResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise; + withMergeLabel(label: string): ResourcePromise; + withMergeLabelCategorized(label: string, category: string): ResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise; +} + +export interface ResourcePromise extends PromiseLike { + withContainerRegistry(registry: HandleReference): ResourcePromise; + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise; + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise; + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise; + withUrl(url: string, options?: WithUrlOptions): ResourcePromise; + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise; + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise; + excludeFromManifest(): ResourcePromise; + withExplicitStart(): ResourcePromise; + withHealthCheck(key: string): ResourcePromise; + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise; + withParentRelationship(parent: HandleReference): ResourcePromise; + withChildRelationship(child: HandleReference): ResourcePromise; + withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise; + excludeFromMcp(): ResourcePromise; + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise; + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise; getResourceName(): Promise; - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): IResourcePromise; - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): IResourcePromise; - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): IResourcePromise; - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): IResourcePromise; - withOptionalString(options?: WithOptionalStringOptions): IResourcePromise; - withConfig(config: TestConfigDto): IResourcePromise; - withCreatedAt(createdAt: string): IResourcePromise; - withModifiedAt(modifiedAt: string): IResourcePromise; - withCorrelationId(correlationId: string): IResourcePromise; - withOptionalCallback(options?: WithOptionalCallbackOptions): IResourcePromise; - withStatus(status: TestResourceStatus): IResourcePromise; - withNestedConfig(config: TestNestedDto): IResourcePromise; - withValidator(validator: (arg: ITestResourceContext) => Promise): IResourcePromise; - testWaitFor(dependency: IHandleReference): IResourcePromise; - withDependency(dependency: IHandleReference): IResourcePromise; - withEndpoints(endpoints: string[]): IResourcePromise; - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): IResourcePromise; -} - -// ============================================================================ -// Resource -// ============================================================================ - -export class Resource extends ResourceBuilderBase { + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise; + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise; + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise; + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise; + withOptionalString(options?: WithOptionalStringOptions): ResourcePromise; + withConfig(config: TestConfigDto): ResourcePromise; + withCreatedAt(createdAt: string): ResourcePromise; + withModifiedAt(modifiedAt: string): ResourcePromise; + withCorrelationId(correlationId: string): ResourcePromise; + withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise; + withStatus(status: TestResourceStatus): ResourcePromise; + withNestedConfig(config: TestNestedDto): ResourcePromise; + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise; + testWaitFor(dependency: HandleReference): ResourcePromise; + withDependency(dependency: HandleReference): ResourcePromise; + withEndpoints(endpoints: string[]): ResourcePromise; + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise; + withMergeLabel(label: string): ResourcePromise; + withMergeLabelCategorized(label: string, category: string): ResourcePromise; + withMergeEndpoint(endpointName: string, port: number): ResourcePromise; + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise; + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise; + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise; + withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise; + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise; +} + +// ============================================================================ +// ResourceImpl +// ============================================================================ + +class ResourceImpl extends ResourceBuilderBase implements Resource { constructor(handle: IResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: IHandleReference): Promise { + private async _withContainerRegistryInternal(registry: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, registry }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ResourcePromise { - return new ResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._withContainerRegistryInternal(registry)); } /** @internal */ @@ -27327,14 +28846,14 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new ResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new ResourcePromiseImpl(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ @@ -27345,20 +28864,20 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { const helpLink = options?.helpLink; - return new ResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + return new ResourcePromiseImpl(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: IResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const obj = new ResourceUrlsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -27366,32 +28885,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withUrlsCallbackInternal(callback)); - } - - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: IResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withUrlsCallbackInternal(callback)); } /** @internal */ @@ -27402,30 +28901,30 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withUrl', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ResourcePromise { const displayText = options?.displayText; - return new ResourcePromise(this._withUrlInternal(url, displayText)); + return new ResourcePromiseImpl(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: IReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { const displayText = options?.displayText; - return new ResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new ResourcePromiseImpl(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ @@ -27439,12 +28938,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { - return new ResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + return new ResourcePromiseImpl(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ @@ -27454,12 +28953,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ResourcePromise { - return new ResourcePromise(this._excludeFromManifestInternal()); + return new ResourcePromiseImpl(this._excludeFromManifestInternal()); } /** @internal */ @@ -27469,12 +28968,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Prevents resource from starting automatically */ withExplicitStart(): ResourcePromise { - return new ResourcePromise(this._withExplicitStartInternal()); + return new ResourcePromiseImpl(this._withExplicitStartInternal()); } /** @internal */ @@ -27484,19 +28983,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a health check by key */ withHealthCheck(key: string): ResourcePromise { - return new ResourcePromise(this._withHealthCheckInternal(key)); + return new ResourcePromiseImpl(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { const executeCommandId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ExecuteCommandContextHandle; - const arg = new ExecuteCommandContext(argHandle, this._client); + const arg = new ExecuteCommandContextImpl(argHandle, this._client); return await executeCommand(arg); }); const rpcArgs: Record = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; @@ -27505,43 +29004,43 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withCommand', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { const commandOptions = options?.commandOptions; - return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new ResourcePromiseImpl(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: IHandleReference): Promise { + private async _withParentRelationshipInternal(parent: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderParentRelationship', + 'Aspire.Hosting/withParentRelationship', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ResourcePromise { - return new ResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: IHandleReference): Promise { + private async _withChildRelationshipInternal(child: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuilderChildRelationship', + 'Aspire.Hosting/withChildRelationship', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ResourcePromise { - return new ResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._withChildRelationshipInternal(child)); } /** @internal */ @@ -27552,13 +29051,13 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withIconName', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { const iconVariant = options?.iconVariant; - return new ResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + return new ResourcePromiseImpl(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ @@ -27568,19 +29067,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ResourcePromise { - return new ResourcePromise(this._excludeFromMcpInternal()); + return new ResourcePromiseImpl(this._excludeFromMcpInternal()); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: IPipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const arg = new PipelineStepContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, stepName, callback: callbackId }; @@ -27592,43 +29091,23 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new ResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: IPipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new Resource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + return new ResourcePromiseImpl(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: IPipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = new PipelineConfigurationContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -27636,12 +29115,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -27654,10 +29133,10 @@ export class Resource extends ResourceBuilderBase { } /** @internal */ - private async _onBeforeResourceStartedInternal(callback: (arg: IBeforeResourceStartedEvent) => Promise): Promise { + 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); + const arg = new BeforeResourceStartedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -27665,19 +29144,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _onResourceStoppedInternal(callback: (arg: IResourceStoppedEvent) => Promise): Promise { + 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); + const arg = new ResourceStoppedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -27685,19 +29164,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/onResourceStopped', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onResourceStoppedInternal(callback)); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _onInitializeResourceInternal(callback: (arg: IInitializeResourceEvent) => Promise): Promise { + 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); + const arg = new InitializeResourceEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -27705,19 +29184,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/onInitializeResource', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onInitializeResourceInternal(callback)); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _onResourceReadyInternal(callback: (arg: IResourceReadyEvent) => Promise): Promise { + 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); + const arg = new ResourceReadyEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -27725,12 +29204,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting/onResourceReady', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._onResourceReadyInternal(callback)); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -27742,14 +29221,14 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalString', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ResourcePromise { const value = options?.value; const enabled = options?.enabled; - return new ResourcePromise(this._withOptionalStringInternal(value, enabled)); + return new ResourcePromiseImpl(this._withOptionalStringInternal(value, enabled)); } /** @internal */ @@ -27759,12 +29238,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConfig', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ResourcePromise { - return new ResourcePromise(this._withConfigInternal(config)); + return new ResourcePromiseImpl(this._withConfigInternal(config)); } /** @internal */ @@ -27774,12 +29253,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCreatedAt', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ResourcePromise { - return new ResourcePromise(this._withCreatedAtInternal(createdAt)); + return new ResourcePromiseImpl(this._withCreatedAtInternal(createdAt)); } /** @internal */ @@ -27789,12 +29268,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withModifiedAt', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ResourcePromise { - return new ResourcePromise(this._withModifiedAtInternal(modifiedAt)); + return new ResourcePromiseImpl(this._withModifiedAtInternal(modifiedAt)); } /** @internal */ @@ -27804,19 +29283,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCorrelationId', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ResourcePromise { - return new ResourcePromise(this._withCorrelationIdInternal(correlationId)); + return new ResourcePromiseImpl(this._withCorrelationIdInternal(correlationId)); } /** @internal */ - private async _withOptionalCallbackInternal(callback?: (arg: ITestCallbackContext) => Promise): Promise { + private async _withOptionalCallbackInternal(callback?: (arg: TestCallbackContext) => Promise): Promise { const callbackId = callback ? registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestCallbackContextHandle; - const arg = new TestCallbackContext(argHandle, this._client); + const arg = new TestCallbackContextImpl(argHandle, this._client); await callback(arg); }) : undefined; const rpcArgs: Record = { builder: this._handle }; @@ -27825,13 +29304,13 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withOptionalCallback', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise { const callback = options?.callback; - return new ResourcePromise(this._withOptionalCallbackInternal(callback)); + return new ResourcePromiseImpl(this._withOptionalCallbackInternal(callback)); } /** @internal */ @@ -27841,12 +29320,12 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withStatus', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ResourcePromise { - return new ResourcePromise(this._withStatusInternal(status)); + return new ResourcePromiseImpl(this._withStatusInternal(status)); } /** @internal */ @@ -27856,19 +29335,19 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withNestedConfig', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ResourcePromise { - return new ResourcePromise(this._withNestedConfigInternal(config)); + return new ResourcePromiseImpl(this._withNestedConfigInternal(config)); } /** @internal */ - private async _withValidatorInternal(validator: (arg: ITestResourceContext) => Promise): Promise { + private async _withValidatorInternal(validator: (arg: TestResourceContext) => Promise): Promise { const validatorId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestResourceContextHandle; - const arg = new TestResourceContext(argHandle, this._client); + const arg = new TestResourceContextImpl(argHandle, this._client); return await validator(arg); }); const rpcArgs: Record = { builder: this._handle, validator: validatorId }; @@ -27876,42 +29355,42 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withValidator', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { - return new ResourcePromise(this._withValidatorInternal(validator)); + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withValidatorInternal(validator)); } /** @internal */ - private async _testWaitForInternal(dependency: IHandleReference): Promise { + private async _testWaitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/testWaitFor', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._testWaitForInternal(dependency)); + testWaitFor(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._testWaitForInternal(dependency)); } /** @internal */ - private async _withDependencyInternal(dependency: IHandleReference): Promise { + private async _withDependencyInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withDependency', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._withDependencyInternal(dependency)); + withDependency(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._withDependencyInternal(dependency)); } /** @internal */ @@ -27921,16 +29400,16 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withEndpoints', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ResourcePromise { - return new ResourcePromise(this._withEndpointsInternal(endpoints)); + return new ResourcePromiseImpl(this._withEndpointsInternal(endpoints)); } /** @internal */ - private async _withCancellableOperationInternal(operation: (arg: ICancellationToken) => Promise): Promise { + private async _withCancellableOperationInternal(operation: (arg: CancellationToken) => Promise): Promise { const operationId = registerCallback(async (argData: unknown) => { const arg = CancellationToken.fromValue(argData); await operation(arg); @@ -27940,12 +29419,140 @@ export class Resource extends ResourceBuilderBase { 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withCancellableOperation', rpcArgs ); - return new Resource(result, this._client); + return new ResourceImpl(result, this._client); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { - return new ResourcePromise(this._withCancellableOperationInternal(operation)); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._withCancellableOperationInternal(operation)); + } + + /** @internal */ + private async _withMergeLabelInternal(label: string): Promise { + const rpcArgs: Record = { builder: this._handle, label }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabel', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ResourcePromise { + return new ResourcePromiseImpl(this._withMergeLabelInternal(label)); + } + + /** @internal */ + private async _withMergeLabelCategorizedInternal(label: string, category: string): Promise { + const rpcArgs: Record = { builder: this._handle, label, category }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLabelCategorized', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ResourcePromise { + return new ResourcePromiseImpl(this._withMergeLabelCategorizedInternal(label, category)); + } + + /** @internal */ + private async _withMergeEndpointInternal(endpointName: string, port: number): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpoint', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ResourcePromise { + return new ResourcePromiseImpl(this._withMergeEndpointInternal(endpointName, port)); + } + + /** @internal */ + private async _withMergeEndpointSchemeInternal(endpointName: string, port: number, scheme: string): Promise { + const rpcArgs: Record = { builder: this._handle, endpointName, port, scheme }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeEndpointScheme', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise { + return new ResourcePromiseImpl(this._withMergeEndpointSchemeInternal(endpointName, port, scheme)); + } + + /** @internal */ + private async _withMergeLoggingInternal(logLevel: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLogging', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ResourcePromiseImpl(this._withMergeLoggingInternal(logLevel, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeLoggingPathInternal(logLevel: string, logPath: string, enableConsole?: boolean, maxFiles?: number): Promise { + const rpcArgs: Record = { builder: this._handle, logLevel, logPath }; + if (enableConsole !== undefined) rpcArgs.enableConsole = enableConsole; + if (maxFiles !== undefined) rpcArgs.maxFiles = maxFiles; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeLoggingPath', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise { + const enableConsole = options?.enableConsole; + const maxFiles = options?.maxFiles; + return new ResourcePromiseImpl(this._withMergeLoggingPathInternal(logLevel, logPath, enableConsole, maxFiles)); + } + + /** @internal */ + private async _withMergeRouteInternal(path: string, method: string, handler: string, priority: number): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRoute', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise { + return new ResourcePromiseImpl(this._withMergeRouteInternal(path, method, handler, priority)); + } + + /** @internal */ + private async _withMergeRouteMiddlewareInternal(path: string, method: string, handler: string, priority: number, middleware: string): Promise { + const rpcArgs: Record = { builder: this._handle, path, method, handler, priority, middleware }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withMergeRouteMiddleware', + rpcArgs + ); + return new ResourceImpl(result, this._client); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise { + return new ResourcePromiseImpl(this._withMergeRouteMiddlewareInternal(path, method, handler, priority, middleware)); } } @@ -27955,7 +29562,7 @@ export class Resource extends ResourceBuilderBase { * @example * await builder.addSomething().withX().withY(); */ -export class ResourcePromise implements PromiseLike { +class ResourcePromiseImpl implements ResourcePromise { constructor(private _promise: Promise) {} then( @@ -27966,98 +29573,88 @@ export class ResourcePromise implements PromiseLike { } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: IHandleReference): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: IResourceUrlsCallbackContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Adds or modifies displayed URLs */ withUrl(url: string, options?: WithUrlOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: IReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ excludeFromManifest(): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + return new ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ withExplicitStart(): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ withHealthCheck(key: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: IExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } /** Sets the parent relationship */ - withParentRelationship(parent: IHandleReference): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: IHandleReference): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ withIconName(iconName: string, options?: WithIconNameOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ excludeFromMcp(): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + return new ResourcePromiseImpl(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: IPipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: IPipelineConfigurationContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -28066,114 +29663,152 @@ export class ResourcePromise implements PromiseLike { } /** Subscribes to the BeforeResourceStarted event */ - onBeforeResourceStarted(callback: (arg: IBeforeResourceStartedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } /** Subscribes to the ResourceStopped event */ - onResourceStopped(callback: (arg: IResourceStoppedEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onResourceStopped(callback))); } /** Subscribes to the InitializeResource event */ - onInitializeResource(callback: (arg: IInitializeResourceEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onInitializeResource(callback))); } /** Subscribes to the ResourceReady event */ - onResourceReady(callback: (arg: IResourceReadyEvent) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.onResourceReady(callback))); } /** Adds an optional string parameter */ withOptionalString(options?: WithOptionalStringOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withOptionalString(options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withOptionalString(options))); } /** Configures the resource with a DTO */ withConfig(config: TestConfigDto): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withConfig(config))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withConfig(config))); } /** Sets the created timestamp */ withCreatedAt(createdAt: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCreatedAt(createdAt))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCreatedAt(createdAt))); } /** Sets the modified timestamp */ withModifiedAt(modifiedAt: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withModifiedAt(modifiedAt))); } /** Sets the correlation ID */ withCorrelationId(correlationId: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCorrelationId(correlationId))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCorrelationId(correlationId))); } /** Configures with optional callback */ withOptionalCallback(options?: WithOptionalCallbackOptions): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withOptionalCallback(options))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withOptionalCallback(options))); } /** Sets the resource status */ withStatus(status: TestResourceStatus): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withStatus(status))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withStatus(status))); } /** Configures with nested DTO */ withNestedConfig(config: TestNestedDto): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withNestedConfig(config))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withNestedConfig(config))); } /** Adds validation callback */ - withValidator(validator: (arg: ITestResourceContext) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withValidator(validator))); + withValidator(validator: (arg: TestResourceContext) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withValidator(validator))); } /** Waits for another resource (test version) */ - testWaitFor(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.testWaitFor(dependency))); + testWaitFor(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.testWaitFor(dependency))); } /** Adds a dependency on another resource */ - withDependency(dependency: IHandleReference): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withDependency(dependency))); + withDependency(dependency: HandleReference): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withDependency(dependency))); } /** Sets the endpoints */ withEndpoints(endpoints: string[]): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withEndpoints(endpoints))); + return new ResourcePromiseImpl(this._promise.then(obj => obj.withEndpoints(endpoints))); } /** Performs a cancellable operation */ - withCancellableOperation(operation: (arg: ICancellationToken) => Promise): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withCancellableOperation(operation))); + withCancellableOperation(operation: (arg: CancellationToken) => Promise): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withCancellableOperation(operation))); + } + + /** Adds a label to the resource */ + withMergeLabel(label: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabel(label))); + } + + /** Adds a categorized label to the resource */ + withMergeLabelCategorized(label: string, category: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLabelCategorized(label, category))); + } + + /** Configures a named endpoint */ + withMergeEndpoint(endpointName: string, port: number): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpoint(endpointName, port))); + } + + /** Configures a named endpoint with scheme */ + withMergeEndpointScheme(endpointName: string, port: number, scheme: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeEndpointScheme(endpointName, port, scheme))); + } + + /** Configures resource logging */ + withMergeLogging(logLevel: string, options?: WithMergeLoggingOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLogging(logLevel, options))); + } + + /** Configures resource logging with file path */ + withMergeLoggingPath(logLevel: string, logPath: string, options?: WithMergeLoggingPathOptions): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeLoggingPath(logLevel, logPath, options))); + } + + /** Configures a route */ + withMergeRoute(path: string, method: string, handler: string, priority: number): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeRoute(path, method, handler, priority))); + } + + /** Configures a route with middleware */ + withMergeRouteMiddleware(path: string, method: string, handler: string, priority: number, middleware: string): ResourcePromise { + return new ResourcePromiseImpl(this._promise.then(obj => obj.withMergeRouteMiddleware(path, method, handler, priority, middleware))); } } // ============================================================================ -// IResourceWithArgs +// ResourceWithArgs // ============================================================================ -export interface IResourceWithArgs { +export interface ResourceWithArgs { toJSON(): MarshalledHandle; - withArgs(args: string[]): IResourceWithArgsPromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; + withArgs(args: string[]): ResourceWithArgsPromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise; } -export interface IResourceWithArgsPromise extends PromiseLike { - withArgs(args: string[]): IResourceWithArgsPromise; - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): IResourceWithArgsPromise; +export interface ResourceWithArgsPromise extends PromiseLike { + withArgs(args: string[]): ResourceWithArgsPromise; + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise; } // ============================================================================ -// ResourceWithArgs +// ResourceWithArgsImpl // ============================================================================ -export class ResourceWithArgs extends ResourceBuilderBase { +class ResourceWithArgsImpl extends ResourceBuilderBase implements ResourceWithArgs { constructor(handle: IResourceWithArgsHandle, client: AspireClientRpc) { super(handle, client); } @@ -28185,19 +29820,19 @@ export class ResourceWithArgs extends ResourceBuilderBase Promise): Promise { + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(objHandle, this._client); + const obj = new CommandLineArgsCallbackContextImpl(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -28205,32 +29840,12 @@ export class ResourceWithArgs extends ResourceBuilderBase Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._withArgsCallbackInternal(callback)); - } - - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: ICommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new ResourceWithArgs(result, this._client); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._withArgsCallbackAsyncInternal(callback)); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromiseImpl(this._withArgsCallbackInternal(callback)); } } @@ -28240,7 +29855,7 @@ export class ResourceWithArgs extends ResourceBuilderBase { +class ResourceWithArgsPromiseImpl implements ResourceWithArgsPromise { constructor(private _promise: Promise) {} then( @@ -28252,66 +29867,59 @@ export class ResourceWithArgsPromise implements PromiseLike { /** Adds arguments */ withArgs(args: string[]): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgs(args))); + return new ResourceWithArgsPromiseImpl(this._promise.then(obj => obj.withArgs(args))); } /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallback(callback))); - } - - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: ICommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { - return new ResourceWithArgsPromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): ResourceWithArgsPromise { + return new ResourceWithArgsPromiseImpl(this._promise.then(obj => obj.withArgsCallback(callback))); } } // ============================================================================ -// IResourceWithConnectionString +// ResourceWithConnectionString // ============================================================================ -export interface IResourceWithConnectionString { +export interface ResourceWithConnectionString { toJSON(): MarshalledHandle; - withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; - getConnectionProperty(key: string): Promise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; - withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; + withConnectionProperty(name: string, value: ReferenceExpression): ResourceWithConnectionStringPromise; + withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise; + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise; + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): ResourceWithConnectionStringPromise; } -export interface IResourceWithConnectionStringPromise extends PromiseLike { - withConnectionProperty(name: string, value: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionStringPromise; - getConnectionProperty(key: string): Promise; - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): IResourceWithConnectionStringPromise; - withConnectionString(connectionString: IReferenceExpression): IResourceWithConnectionStringPromise; - withConnectionStringDirect(connectionString: string): IResourceWithConnectionStringPromise; +export interface ResourceWithConnectionStringPromise extends PromiseLike { + withConnectionProperty(name: string, value: ReferenceExpression): ResourceWithConnectionStringPromise; + withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise; + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise; + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise; + withConnectionStringDirect(connectionString: string): ResourceWithConnectionStringPromise; } // ============================================================================ -// ResourceWithConnectionString +// ResourceWithConnectionStringImpl // ============================================================================ -export class ResourceWithConnectionString extends ResourceBuilderBase { +class ResourceWithConnectionStringImpl extends ResourceBuilderBase implements ResourceWithConnectionString { constructor(handle: IResourceWithConnectionStringHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: IReferenceExpression): Promise { + private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', rpcArgs ); - return new ResourceWithConnectionString(result, this._client); + return new ResourceWithConnectionStringImpl(result, this._client); } /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: IReferenceExpression): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._withConnectionPropertyInternal(name, value)); + withConnectionProperty(name: string, value: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._withConnectionPropertyInternal(name, value)); } /** @internal */ @@ -28321,28 +29929,19 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { - const rpcArgs: Record = { resource: this._handle, key }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getConnectionProperty', - rpcArgs - ); + return new ResourceWithConnectionStringPromiseImpl(this._withConnectionPropertyValueInternal(name, value)); } /** @internal */ - private async _onConnectionStringAvailableInternal(callback: (arg: IConnectionStringAvailableEvent) => Promise): Promise { + 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); + const arg = new ConnectionStringAvailableEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -28350,27 +29949,27 @@ export class ResourceWithConnectionString extends ResourceBuilderBase Promise): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _withConnectionStringInternal(connectionString: IReferenceExpression): Promise { + private async _withConnectionStringInternal(connectionString: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, connectionString }; const result = await this._client.invokeCapability( 'Aspire.Hosting.CodeGeneration.TypeScript.Tests/withConnectionString', rpcArgs ); - return new ResourceWithConnectionString(result, this._client); + return new ResourceWithConnectionStringImpl(result, this._client); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._withConnectionStringInternal(connectionString)); + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._withConnectionStringInternal(connectionString)); } /** @internal */ @@ -28380,12 +29979,12 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { +class ResourceWithConnectionStringPromiseImpl implements ResourceWithConnectionStringPromise { constructor(private _promise: Promise) {} then( @@ -28406,57 +30005,52 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); + withConnectionProperty(name: string, value: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.withConnectionProperty(name, value))); } /** Adds a connection property with a string value */ withConnectionPropertyValue(name: string, value: string): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** Gets a connection property by key */ - getConnectionProperty(key: string): Promise { - return this._promise.then(obj => obj.getConnectionProperty(key)); + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } /** Subscribes to the ConnectionStringAvailable event */ - onConnectionStringAvailable(callback: (arg: IConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } /** Sets the connection string using a reference expression */ - withConnectionString(connectionString: IReferenceExpression): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionString(connectionString))); + withConnectionString(connectionString: ReferenceExpression): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.withConnectionString(connectionString))); } /** Sets connection string using direct interface target */ withConnectionStringDirect(connectionString: string): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); + return new ResourceWithConnectionStringPromiseImpl(this._promise.then(obj => obj.withConnectionStringDirect(connectionString))); } } // ============================================================================ -// IResourceWithContainerFiles +// ResourceWithContainerFiles // ============================================================================ -export interface IResourceWithContainerFiles { +export interface ResourceWithContainerFiles { toJSON(): MarshalledHandle; - withContainerFilesSource(sourcePath: string): IResourceWithContainerFilesPromise; - clearContainerFilesSources(): IResourceWithContainerFilesPromise; + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise; + clearContainerFilesSources(): ResourceWithContainerFilesPromise; } -export interface IResourceWithContainerFilesPromise extends PromiseLike { - withContainerFilesSource(sourcePath: string): IResourceWithContainerFilesPromise; - clearContainerFilesSources(): IResourceWithContainerFilesPromise; +export interface ResourceWithContainerFilesPromise extends PromiseLike { + withContainerFilesSource(sourcePath: string): ResourceWithContainerFilesPromise; + clearContainerFilesSources(): ResourceWithContainerFilesPromise; } // ============================================================================ -// ResourceWithContainerFiles +// ResourceWithContainerFilesImpl // ============================================================================ -export class ResourceWithContainerFiles extends ResourceBuilderBase { +class ResourceWithContainerFilesImpl extends ResourceBuilderBase implements ResourceWithContainerFiles { constructor(handle: IResourceWithContainerFilesHandle, client: AspireClientRpc) { super(handle, client); } @@ -28468,12 +30062,12 @@ export class ResourceWithContainerFiles extends ResourceBuilderBase { +class ResourceWithContainerFilesPromiseImpl implements ResourceWithContainerFilesPromise { constructor(private _promise: Promise) {} then( @@ -28510,54 +30104,54 @@ export class ResourceWithContainerFilesPromise implements PromiseLike obj.withContainerFilesSource(sourcePath))); + return new ResourceWithContainerFilesPromiseImpl(this._promise.then(obj => obj.withContainerFilesSource(sourcePath))); } /** Clears all container file sources */ clearContainerFilesSources(): ResourceWithContainerFilesPromise { - return new ResourceWithContainerFilesPromise(this._promise.then(obj => obj.clearContainerFilesSources())); + return new ResourceWithContainerFilesPromiseImpl(this._promise.then(obj => obj.clearContainerFilesSources())); } } -// ============================================================================ -// IResourceWithEndpoints -// ============================================================================ - -export interface IResourceWithEndpoints { - toJSON(): MarshalledHandle; - withMcpServer(options?: WithMcpServerOptions): IResourceWithEndpointsPromise; - withEndpoint(options?: WithEndpointOptions): IResourceWithEndpointsPromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IResourceWithEndpointsPromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IResourceWithEndpointsPromise; - withExternalHttpEndpoints(): IResourceWithEndpointsPromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IResourceWithEndpointsPromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; -} - -export interface IResourceWithEndpointsPromise extends PromiseLike { - withMcpServer(options?: WithMcpServerOptions): IResourceWithEndpointsPromise; - withEndpoint(options?: WithEndpointOptions): IResourceWithEndpointsPromise; - withHttpEndpoint(options?: WithHttpEndpointOptions): IResourceWithEndpointsPromise; - withHttpsEndpoint(options?: WithHttpsEndpointOptions): IResourceWithEndpointsPromise; - withExternalHttpEndpoints(): IResourceWithEndpointsPromise; - getEndpoint(name: string): Promise; - asHttp2Service(): IResourceWithEndpointsPromise; - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): IResourceWithEndpointsPromise; - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): IResourceWithEndpointsPromise; - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): IResourceWithEndpointsPromise; - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): IResourceWithEndpointsPromise; -} - // ============================================================================ // ResourceWithEndpoints // ============================================================================ -export class ResourceWithEndpoints extends ResourceBuilderBase { +export interface ResourceWithEndpoints { + toJSON(): MarshalledHandle; + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise; + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise; + withExternalHttpEndpoints(): ResourceWithEndpointsPromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ResourceWithEndpointsPromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ResourceWithEndpointsPromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise; +} + +export interface ResourceWithEndpointsPromise extends PromiseLike { + withMcpServer(options?: WithMcpServerOptions): ResourceWithEndpointsPromise; + withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise; + withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise; + withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise; + withExternalHttpEndpoints(): ResourceWithEndpointsPromise; + getEndpoint(name: string): Promise; + asHttp2Service(): ResourceWithEndpointsPromise; + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ResourceWithEndpointsPromise; + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise; + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise; + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise; +} + +// ============================================================================ +// ResourceWithEndpointsImpl +// ============================================================================ + +class ResourceWithEndpointsImpl extends ResourceBuilderBase implements ResourceWithEndpoints { constructor(handle: IResourceWithEndpointsHandle, client: AspireClientRpc) { super(handle, client); } @@ -28571,14 +30165,14 @@ export class ResourceWithEndpoints extends ResourceBuilderBase { + async getEndpoint(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( + return await this._client.invokeCapability( 'Aspire.Hosting/getEndpoint', rpcArgs ); @@ -28693,19 +30287,19 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); + const arg = new EndpointReferenceImpl(argHandle, this._client); return await callback(arg); }); const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; @@ -28713,12 +30307,12 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @internal */ @@ -28731,7 +30325,7 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + 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); + const arg = new ResourceEndpointsAllocatedEventImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -28783,12 +30377,12 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._onResourceEndpointsAllocatedInternal(callback)); } } @@ -28798,7 +30392,7 @@ export class ResourceWithEndpoints extends ResourceBuilderBase { +class ResourceWithEndpointsPromiseImpl implements ResourceWithEndpointsPromise { constructor(private _promise: Promise) {} then( @@ -28810,111 +30404,113 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withMcpServer(options))); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withMcpServer(options))); } /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withEndpoint(options))); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withEndpoint(options))); } /** Adds an HTTP endpoint */ withHttpEndpoint(options?: WithHttpEndpointOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpEndpoint(options))); } /** Adds an HTTPS endpoint */ withHttpsEndpoint(options?: WithHttpsEndpointOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpsEndpoint(options))); } /** Makes HTTP endpoints externally accessible */ withExternalHttpEndpoints(): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withExternalHttpEndpoints())); } /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { + getEndpoint(name: string): Promise { return this._promise.then(obj => obj.getEndpoint(name)); } /** Configures resource for HTTP/2 */ asHttp2Service(): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.asHttp2Service())); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.asHttp2Service())); } /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: IEndpointReference) => Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } /** Adds an HTTP health check */ withHttpHealthCheck(options?: WithHttpHealthCheckOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpHealthCheck(options))); } /** Adds an HTTP health probe to the resource */ withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } /** Subscribes to the ResourceEndpointsAllocated event */ - onResourceEndpointsAllocated(callback: (arg: IResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { - return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromiseImpl(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } } -// ============================================================================ -// IResourceWithEnvironment -// ============================================================================ - -export interface IResourceWithEnvironment { - toJSON(): MarshalledHandle; - withOtlpExporter(): IResourceWithEnvironmentPromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IResourceWithEnvironmentPromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; - withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; - withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; - withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; - withoutHttpsCertificate(): IResourceWithEnvironmentPromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; -} - -export interface IResourceWithEnvironmentPromise extends PromiseLike { - withOtlpExporter(): IResourceWithEnvironmentPromise; - withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironmentPromise; - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): IResourceWithEnvironmentPromise; - withEnvironmentParameter(name: string, parameter: IParameterResource): IResourceWithEnvironmentPromise; - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): IResourceWithEnvironmentPromise; - withReference(source: IHandleReference, options?: WithReferenceOptions): IResourceWithEnvironmentPromise; - withReferenceUri(name: string, uri: string): IResourceWithEnvironmentPromise; - withReferenceExternalService(externalService: IExternalServiceResource): IResourceWithEnvironmentPromise; - withReferenceEndpoint(endpointReference: IEndpointReference): IResourceWithEnvironmentPromise; - withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironmentPromise; - withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironmentPromise; - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): IResourceWithEnvironmentPromise; - withoutHttpsCertificate(): IResourceWithEnvironmentPromise; - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): IResourceWithEnvironmentPromise; - withEnvironmentVariables(variables: Record): IResourceWithEnvironmentPromise; -} - // ============================================================================ // ResourceWithEnvironment // ============================================================================ -export class ResourceWithEnvironment extends ResourceBuilderBase { +export interface ResourceWithEnvironment { + toJSON(): MarshalledHandle; + withOtlpExporter(): ResourceWithEnvironmentPromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise; + withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ResourceWithEnvironmentPromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ResourceWithEnvironmentPromise; + withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise; + withReferenceExternalService(externalService: ExternalServiceResource): ResourceWithEnvironmentPromise; + withReferenceEndpoint(endpointReference: EndpointReference): ResourceWithEnvironmentPromise; + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise; + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise; + withoutHttpsCertificate(): ResourceWithEnvironmentPromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): ResourceWithEnvironmentPromise; +} + +export interface ResourceWithEnvironmentPromise extends PromiseLike { + withOtlpExporter(): ResourceWithEnvironmentPromise; + withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise; + withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise; + withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise; + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise; + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise; + withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise; + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ResourceWithEnvironmentPromise; + withReference(source: HandleReference, options?: WithReferenceOptions): ResourceWithEnvironmentPromise; + withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise; + withReferenceExternalService(externalService: ExternalServiceResource): ResourceWithEnvironmentPromise; + withReferenceEndpoint(endpointReference: EndpointReference): ResourceWithEnvironmentPromise; + withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise; + withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise; + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise; + withoutHttpsCertificate(): ResourceWithEnvironmentPromise; + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise; + withEnvironmentVariables(variables: Record): ResourceWithEnvironmentPromise; +} + +// ============================================================================ +// ResourceWithEnvironmentImpl +// ============================================================================ + +class ResourceWithEnvironmentImpl extends ResourceBuilderBase implements ResourceWithEnvironment { constructor(handle: IResourceWithEnvironmentHandle, client: AspireClientRpc) { super(handle, client); } @@ -28926,12 +30522,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase 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 _withEnvironmentInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withEnvironment', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentInternal(name, value)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: IEndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironmentExpression', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentExpressionInternal(name, value)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; + const obj = new EnvironmentCallbackContextImpl(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withEnvironmentCallback', + rpcArgs + ); + return new ResourceWithEnvironmentImpl(result, this._client); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentCallbackInternal(callback)); + } + + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: IParameterResource): Promise { + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentParameter', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentParameterInternal(name, parameter)); + withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentParameterInternal(name, parameter)); } /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: IHandleReference): Promise { + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, envVarName, resource }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentConnectionString', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } /** @internal */ - private async _withReferenceInternal(source: IHandleReference, connectionName?: string, optional?: boolean, name?: string): Promise { + private async _withReferenceInternal(source: HandleReference, 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; @@ -29039,15 +30650,15 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { const rpcArgs: Record = { builder: this._handle, externalService }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceExternalService', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withReferenceExternalServiceInternal(externalService)); + withReferenceExternalService(externalService: ExternalServiceResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withReferenceExternalServiceInternal(externalService)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: IEndpointReference): Promise { + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, endpointReference }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withReferenceEndpoint', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withReferenceEndpointInternal(endpointReference)); + withReferenceEndpoint(endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._withReferenceEndpointInternal(endpointReference)); } /** @internal */ @@ -29102,12 +30713,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', + 'Aspire.Hosting/withHttpsDeveloperCertificate', rpcArgs ); - return new ResourceWithEnvironment(result, this._client); + return new ResourceWithEnvironmentImpl(result, this._client); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { const password = options?.password; - return new ResourceWithEnvironmentPromise(this._withHttpsDeveloperCertificateInternal(password)); + return new ResourceWithEnvironmentPromiseImpl(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ @@ -29149,19 +30760,19 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): Promise { + private async _testWithEnvironmentCallbackInternal(callback: (arg: TestEnvironmentContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as TestEnvironmentContextHandle; - const arg = new TestEnvironmentContext(argHandle, this._client); + const arg = new TestEnvironmentContextImpl(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; @@ -29169,12 +30780,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._testWithEnvironmentCallbackInternal(callback)); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._testWithEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -29184,12 +30795,12 @@ export class ResourceWithEnvironment extends ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentVariablesInternal(variables)); + return new ResourceWithEnvironmentPromiseImpl(this._withEnvironmentVariablesInternal(variables)); } } @@ -29199,7 +30810,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { +class ResourceWithEnvironmentPromiseImpl implements ResourceWithEnvironmentPromise { constructor(private _promise: Promise) {} then( @@ -29211,196 +30822,201 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporter())); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withOtlpExporter())); } /** Configures OTLP telemetry export with specific protocol */ withOtlpExporterProtocol(protocol: OtlpProtocol): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (arg: IEnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Sets an environment variable */ + withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds an environment variable with a reference expression */ + withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + } + + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets an environment variable on the resource */ - withEnvironment(name: string, value: string | IReferenceExpression | IEndpointReference | IParameterResource | IResourceWithConnectionString): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: IParameterResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: IHandleReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + withEnvironmentConnectionString(envVarName: string, resource: HandleReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } /** Adds a reference to another resource */ - withReference(source: IHandleReference, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); + withReference(source: HandleReference, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withReference(source, options))); } /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withReferenceUri(name, uri))); } /** Adds a reference to an external service */ - withReferenceExternalService(externalService: IExternalServiceResource): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); + withReferenceExternalService(externalService: ExternalServiceResource): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: IEndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + withReferenceEndpoint(endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } /** Configures developer certificate trust */ withDeveloperCertificateTrust(trust: boolean): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } /** Sets the certificate trust scope */ withCertificateTrustScope(scope: CertificateTrustScope): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } /** Configures HTTPS with a developer certificate */ withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withoutHttpsCertificate())); } /** Configures environment with callback (test version) */ - testWithEnvironmentCallback(callback: (arg: ITestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); + testWithEnvironmentCallback(callback: (arg: TestEnvironmentContext) => Promise): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.testWithEnvironmentCallback(callback))); } /** Sets environment variables */ withEnvironmentVariables(variables: Record): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentVariables(variables))); + return new ResourceWithEnvironmentPromiseImpl(this._promise.then(obj => obj.withEnvironmentVariables(variables))); } } // ============================================================================ -// IResourceWithWaitSupport +// ResourceWithWaitSupport // ============================================================================ -export interface IResourceWithWaitSupport { +export interface ResourceWithWaitSupport { toJSON(): MarshalledHandle; - waitFor(dependency: IHandleReference): IResourceWithWaitSupportPromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForStart(dependency: IHandleReference): IResourceWithWaitSupportPromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IResourceWithWaitSupportPromise; + waitFor(dependency: HandleReference): ResourceWithWaitSupportPromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise; + waitForStart(dependency: HandleReference): ResourceWithWaitSupportPromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise; } -export interface IResourceWithWaitSupportPromise extends PromiseLike { - waitFor(dependency: IHandleReference): IResourceWithWaitSupportPromise; - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForStart(dependency: IHandleReference): IResourceWithWaitSupportPromise; - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): IResourceWithWaitSupportPromise; - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): IResourceWithWaitSupportPromise; +export interface ResourceWithWaitSupportPromise extends PromiseLike { + waitFor(dependency: HandleReference): ResourceWithWaitSupportPromise; + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise; + waitForStart(dependency: HandleReference): ResourceWithWaitSupportPromise; + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise; + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise; } // ============================================================================ -// ResourceWithWaitSupport +// ResourceWithWaitSupportImpl // ============================================================================ -export class ResourceWithWaitSupport extends ResourceBuilderBase { +class ResourceWithWaitSupportImpl extends ResourceBuilderBase implements ResourceWithWaitSupport { constructor(handle: IResourceWithWaitSupportHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _waitForInternal(dependency: IHandleReference): Promise { + private async _waitForInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResource', + 'Aspire.Hosting/waitFor', rpcArgs ); - return new ResourceWithWaitSupport(result, this._client); + return new ResourceWithWaitSupportImpl(result, this._client); } /** Waits for another resource to be ready */ - waitFor(dependency: IHandleReference): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForInternal(dependency)); + waitFor(dependency: HandleReference): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._waitForInternal(dependency)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new ResourceWithWaitSupport(result, this._client); + return new ResourceWithWaitSupportImpl(result, this._client); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForStartInternal(dependency: IHandleReference): Promise { + private async _waitForStartInternal(dependency: HandleReference): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceStart', + 'Aspire.Hosting/waitForStart', rpcArgs ); - return new ResourceWithWaitSupport(result, this._client); + return new ResourceWithWaitSupportImpl(result, this._client); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForStartInternal(dependency)); + waitForStart(dependency: HandleReference): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._waitForStartInternal(dependency)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: IHandleReference, waitBehavior: WaitBehavior): Promise { + private async _waitForStartWithBehaviorInternal(dependency: HandleReference, waitBehavior: WaitBehavior): Promise { const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; const result = await this._client.invokeCapability( 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new ResourceWithWaitSupport(result, this._client); + return new ResourceWithWaitSupportImpl(result, this._client); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _waitForCompletionInternal(dependency: IHandleReference, exitCode?: number): Promise { + private async _waitForCompletionInternal(dependency: HandleReference, exitCode?: number): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForResourceCompletion', + 'Aspire.Hosting/waitForCompletion', rpcArgs ); - return new ResourceWithWaitSupport(result, this._client); + return new ResourceWithWaitSupportImpl(result, this._client); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { const exitCode = options?.exitCode; - return new ResourceWithWaitSupportPromise(this._waitForCompletionInternal(dependency, exitCode)); + return new ResourceWithWaitSupportPromiseImpl(this._waitForCompletionInternal(dependency, exitCode)); } } @@ -29410,7 +31026,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { +class ResourceWithWaitSupportPromiseImpl implements ResourceWithWaitSupportPromise { constructor(private _promise: Promise) {} then( @@ -29421,28 +31037,28 @@ export class ResourceWithWaitSupportPromise implements PromiseLike obj.waitFor(dependency))); + waitFor(dependency: HandleReference): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitFor(dependency))); } /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + waitForWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } /** Waits for another resource to start */ - waitForStart(dependency: IHandleReference): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStart(dependency))); + waitForStart(dependency: HandleReference): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitForStart(dependency))); } /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: IHandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + waitForStartWithBehavior(dependency: HandleReference, waitBehavior: WaitBehavior): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } /** Waits for resource completion */ - waitForCompletion(dependency: IHandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { - return new ResourceWithWaitSupportPromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + waitForCompletion(dependency: HandleReference, options?: WaitForCompletionOptions): ResourceWithWaitSupportPromise { + return new ResourceWithWaitSupportPromiseImpl(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } } @@ -29506,13 +31122,13 @@ 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/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/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.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCallbackContext', (handle, client) => new TestCallbackContext(handle as TestCallbackContextHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCollectionContext', (handle, client) => new TestCollectionContext(handle as TestCollectionContextHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestEnvironmentContext', (handle, client) => new TestEnvironmentContext(handle as TestEnvironmentContextHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestResourceContext', (handle, client) => new TestResourceContext(handle as TestResourceContextHandle, 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/Aspire.Hosting.ConnectionStringResource', (handle, client) => new ConnectionStringResource(handle as ConnectionStringResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource', (handle, client) => new ContainerRegistryResource(handle as ContainerRegistryResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource', (handle, client) => new ContainerResource(handle as ContainerResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource', (handle, client) => new CSharpAppResource(handle as CSharpAppResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource', (handle, client) => new DotnetToolResource(handle as DotnetToolResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource', (handle, client) => new ExecutableResource(handle as ExecutableResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ExternalServiceResource', (handle, client) => new ExternalServiceResource(handle as ExternalServiceResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource', (handle, client) => new ParameterResource(handle as ParameterResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource', (handle, client) => new ProjectResource(handle as ProjectResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestDatabaseResource', (handle, client) => new TestDatabaseResource(handle as TestDatabaseResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestRedisResource', (handle, client) => new TestRedisResource(handle as TestRedisResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestVaultResource', (handle, client) => new TestVaultResource(handle as TestVaultResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource', (handle, client) => new ComputeResource(handle as IComputeResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource', (handle, client) => new ContainerFilesDestinationResource(handle as IContainerFilesDestinationResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new Resource(handle as IResourceHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs', (handle, client) => new ResourceWithArgs(handle as IResourceWithArgsHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionString(handle as IResourceWithConnectionStringHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEventImpl(handle as AfterResourcesCreatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEventImpl(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEventImpl(handle as BeforeStartEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContextImpl(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEventImpl(handle as ConnectionStringAvailableEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplicationImpl(handle as DistributedApplicationHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContextImpl(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModelImpl(handle as DistributedApplicationModelHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReferenceImpl(handle as EndpointReferenceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpressionImpl(handle as EndpointReferenceExpressionHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContextImpl(handle as EnvironmentCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContextImpl(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEventImpl(handle as InitializeResourceEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContextImpl(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContextImpl(handle as PipelineContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStepImpl(handle as PipelineStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContextImpl(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContextImpl(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummaryImpl(handle as PipelineSummaryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptionsImpl(handle as ProjectResourceOptionsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilderImpl(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEventImpl(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerServiceImpl(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationServiceImpl(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEventImpl(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEventImpl(handle as ResourceStoppedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContextImpl(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCallbackContext', (handle, client) => new TestCallbackContextImpl(handle as TestCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCollectionContext', (handle, client) => new TestCollectionContextImpl(handle as TestCollectionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestEnvironmentContext', (handle, client) => new TestEnvironmentContextImpl(handle as TestEnvironmentContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestResourceContext', (handle, client) => new TestResourceContextImpl(handle as TestResourceContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContextImpl(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new ConfigurationImpl(handle as IConfigurationHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilderImpl(handle as IDistributedApplicationBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventingImpl(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironmentImpl(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new LoggerImpl(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactoryImpl(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStepImpl(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTaskImpl(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProviderImpl(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManagerImpl(handle as IUserSecretsManagerHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ConnectionStringResource', (handle, client) => new ConnectionStringResourceImpl(handle as ConnectionStringResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource', (handle, client) => new ContainerRegistryResourceImpl(handle as ContainerRegistryResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource', (handle, client) => new ContainerResourceImpl(handle as ContainerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CSharpAppResource', (handle, client) => new CSharpAppResourceImpl(handle as CSharpAppResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource', (handle, client) => new DotnetToolResourceImpl(handle as DotnetToolResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecutableResource', (handle, client) => new ExecutableResourceImpl(handle as ExecutableResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ExternalServiceResource', (handle, client) => new ExternalServiceResourceImpl(handle as ExternalServiceResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterResource', (handle, client) => new ParameterResourceImpl(handle as ParameterResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource', (handle, client) => new ProjectResourceImpl(handle as ProjectResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestDatabaseResource', (handle, client) => new TestDatabaseResourceImpl(handle as TestDatabaseResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestRedisResource', (handle, client) => new TestRedisResourceImpl(handle as TestRedisResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestVaultResource', (handle, client) => new TestVaultResourceImpl(handle as TestVaultResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource', (handle, client) => new ComputeResourceImpl(handle as IComputeResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource', (handle, client) => new ContainerFilesDestinationResourceImpl(handle as IContainerFilesDestinationResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource', (handle, client) => new ResourceImpl(handle as IResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithArgs', (handle, client) => new ResourceWithArgsImpl(handle as IResourceWithArgsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithConnectionString', (handle, client) => new ResourceWithConnectionStringImpl(handle as IResourceWithConnectionStringHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFilesImpl(handle as IResourceWithContainerFilesHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpointsImpl(handle as IResourceWithEndpointsHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironmentImpl(handle as IResourceWithEnvironmentHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupportImpl(handle as IResourceWithWaitSupportHandle, client)); diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts index 6eba4421328..64e4c50a7db 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/base.verified.ts @@ -1,10 +1,9 @@ -// base.ts - Core Aspire types: base classes, ReferenceExpression -import type { ICancellationToken } 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, CancellationToken, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; -export type { ICancellationToken, MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; +export type { MarshalledHandle, AtsError, AtsErrorDetails, CallbackFunction } from './transport.js'; export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './transport.js'; // ============================================================================ @@ -39,22 +38,22 @@ export { AtsErrorCodes, isMarshalledHandle, isAtsError, wrapIfHandle } from './t * await api.withEnvironment("REDIS_URL", expr); * ``` */ -export interface IReferenceExpression { +export interface ReferenceExpression { readonly isConditional: boolean; toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle; - getValue(cancellationToken?: AbortSignal | ICancellationToken): Promise; + getValue(cancellationToken?: AbortSignal | CancellationToken): Promise; toString(): string; } -export class ReferenceExpression implements IReferenceExpression { +class ReferenceExpressionImpl implements ReferenceExpression { // Expression mode fields private readonly _format?: string; private readonly _valueProviders?: unknown[]; // Conditional mode fields private readonly _condition?: unknown; - private readonly _whenTrue?: IReferenceExpression; - private readonly _whenFalse?: IReferenceExpression; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; private readonly _matchValue?: string; // Handle mode fields (when wrapping a server-returned handle) @@ -63,12 +62,12 @@ export class ReferenceExpression implements IReferenceExpression { constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(condition: unknown, matchValue: string, whenTrue: IReferenceExpression, whenFalse: IReferenceExpression); + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); constructor( handleOrFormatOrCondition: Handle | string | unknown, clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, - whenTrueOrWhenFalse?: IReferenceExpression, - whenFalse?: IReferenceExpression + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression ) { if (typeof handleOrFormatOrCondition === 'string') { this._format = handleOrFormatOrCondition; @@ -98,55 +97,6 @@ export class ReferenceExpression implements IReferenceExpression { * @param values - The interpolated values (handles to value providers) * @returns A ReferenceExpression instance */ - static create(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { - // Build the format string with {0}, {1}, etc. placeholders - let format = ''; - for (let i = 0; i < strings.length; i++) { - format += strings[i]; - if (i < values.length) { - format += `{${i}}`; - } - } - - // Extract handles from values - const valueProviders = values.map(extractHandleForExpr); - - return new ReferenceExpression(format, valueProviders); - } - - /** - * Creates a conditional reference expression from its constituent parts. - * - * @param condition - A value provider whose result is compared to matchValue - * @param whenTrue - The expression to use when the condition matches - * @param whenFalse - The expression to use when the condition does not match - * @param matchValue - The value to compare the condition against (defaults to "True") - * @returns A ReferenceExpression instance in conditional mode - */ - static createConditional( - condition: unknown, - whenTrue: IReferenceExpression, - whenFalse: IReferenceExpression - ): IReferenceExpression; - static createConditional( - condition: unknown, - matchValue: string, - whenTrue: IReferenceExpression, - whenFalse: IReferenceExpression - ): IReferenceExpression; - static createConditional( - condition: unknown, - matchValueOrWhenTrue: string | IReferenceExpression, - whenTrueOrWhenFalse: IReferenceExpression, - whenFalse?: IReferenceExpression - ): IReferenceExpression { - if (typeof matchValueOrWhenTrue === 'string') { - return new ReferenceExpression(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); - } - - return new ReferenceExpression(condition, 'True', matchValueOrWhenTrue, whenTrueOrWhenFalse); - } - /** * Serializes the reference expression for JSON-RPC transport. * In expression mode, uses the $expr format with format + valueProviders. @@ -184,7 +134,7 @@ export class ReferenceExpression implements IReferenceExpression { * @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 | ICancellationToken): Promise { + async getValue(cancellationToken?: AbortSignal | CancellationToken): Promise { if (!this._handle || !this._client) { throw new Error('getValue is only available on server-returned ReferenceExpression instances'); } @@ -215,8 +165,51 @@ export class ReferenceExpression implements IReferenceExpression { } } +function createReferenceExpression(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { + let format = ''; + for (let i = 0; i < strings.length; i++) { + format += strings[i]; + if (i < values.length) { + format += `{${i}}`; + } + } + + const valueProviders = values.map(extractHandleForExpr); + + return new ReferenceExpressionImpl(format, valueProviders); +} + +function createConditionalReferenceExpression( + condition: unknown, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression +): ReferenceExpression; +function createConditionalReferenceExpression( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression +): ReferenceExpression; +function createConditionalReferenceExpression( + condition: unknown, + matchValueOrWhenTrue: string | ReferenceExpression, + whenTrueOrWhenFalse: ReferenceExpression, + whenFalse?: ReferenceExpression +): ReferenceExpression { + if (typeof matchValueOrWhenTrue === 'string') { + return new ReferenceExpressionImpl(condition, matchValueOrWhenTrue, whenTrueOrWhenFalse, whenFalse!); + } + + return new ReferenceExpressionImpl(condition, 'True', matchValueOrWhenTrue, whenTrueOrWhenFalse); +} + +export const ReferenceExpression = { + create: createReferenceExpression, + createConditional: createConditionalReferenceExpression +}; + registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpression', (handle, client) => - new ReferenceExpression(handle, client) + new ReferenceExpressionImpl(handle, client) ); /** @@ -281,7 +274,7 @@ function extractHandleForExpr(value: unknown): unknown { * await api.withEnvironment("REDIS_URL", expr); * ``` */ -export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IReferenceExpression { +export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): ReferenceExpression { return ReferenceExpression.create(strings, ...values); } @@ -289,7 +282,7 @@ export function refExpr(strings: TemplateStringsArray, ...values: unknown[]): IR // ResourceBuilderBase // ============================================================================ -export interface IHandleReference { +export interface HandleReference { toJSON(): MarshalledHandle; } @@ -297,7 +290,7 @@ export interface IHandleReference { * Base class for resource builders (e.g., RedisBuilder, ContainerBuilder). * Provides handle management and JSON serialization. */ -export class ResourceBuilderBase implements IHandleReference { +export class ResourceBuilderBase implements HandleReference { constructor(protected _handle: THandle, protected _client: AspireClient) {} toJSON(): MarshalledHandle { return this._handle.toJSON(); } diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts index 71f762b8009..724836a73fd 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts @@ -104,7 +104,7 @@ function isAbortSignal(value: unknown): value is AbortSignal { ); } -function isCancellationTokenLike(value: unknown): value is ICancellationToken { +function isCancellationTokenLike(value: unknown): value is CancellationToken { return ( value !== null && typeof value === 'object' && @@ -216,12 +216,12 @@ export class Handle { * const connectionString = await connectionStringExpression.getValue(cancellationToken); * ``` */ -export interface ICancellationToken { +export interface CancellationToken { toJSON(): string | undefined; register(client?: AspireClient): string | undefined; } -export class CancellationToken implements ICancellationToken { +class CancellationTokenImpl implements CancellationToken { private readonly _signal?: AbortSignal; private readonly _remoteTokenId?: string; @@ -238,47 +238,49 @@ export class CancellationToken implements ICancellationToken { /** * Creates a cancellation token from a local {@link AbortSignal}. */ - static from(signal?: AbortSignal): CancellationToken { - return new CancellationToken(signal); + 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); + } +} + +/** + * Creates transport-safe cancellation token values for the generated SDK. + */ +export const CancellationToken = { + from(signal?: AbortSignal): CancellationToken { + return new CancellationTokenImpl(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): ICancellationToken { + fromValue(value: unknown): CancellationToken { if (isCancellationTokenLike(value)) { return value; } if (typeof value === 'string') { - return new CancellationToken(value); + return new CancellationTokenImpl(value); } if (isAbortSignal(value)) { - return new CancellationToken(value); + return new CancellationTokenImpl(value); } - return new CancellationToken(); + return new CancellationTokenImpl(); } - - /** - * 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 @@ -601,7 +603,7 @@ function isAspireClientLike(value: unknown): value is 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 */ -export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | ICancellationToken): string | undefined; +export function registerCancellation(client: AspireClient, signalOrToken?: AbortSignal | CancellationToken): string | undefined; /** * Registers cancellation support using the single connected AspireClient. * @@ -618,15 +620,15 @@ export function registerCancellation(client: AspireClient, signalOrToken?: Abort * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signalOrToken?: AbortSignal | ICancellationToken): string | undefined; +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; export function registerCancellation( - clientOrSignalOrToken?: AspireClient | AbortSignal | ICancellationToken, - maybeSignalOrToken?: AbortSignal | ICancellationToken + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken ): string | undefined { const client = isAspireClientLike(clientOrSignalOrToken) ? clientOrSignalOrToken : undefined; const signalOrToken = client ? maybeSignalOrToken - : clientOrSignalOrToken as AbortSignal | ICancellationToken | undefined; + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; if (!signalOrToken) { return undefined;