sst 2.18.4 → 2.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sst.mjs CHANGED
@@ -292,10 +292,10 @@ async function load(input, shallow) {
292
292
  plugins: [ts]
293
293
  });
294
294
  babel.traverse(ast, {
295
- ObjectMethod(path20) {
296
- const { key } = path20.node;
295
+ ObjectMethod(path22) {
296
+ const { key } = path22.node;
297
297
  if ("name" in key && key.name === "stacks") {
298
- path20.remove();
298
+ path22.remove();
299
299
  }
300
300
  }
301
301
  });
@@ -471,7 +471,7 @@ async function promptPersonalStage(out, isRetry) {
471
471
  input: process.stdin,
472
472
  output: process.stdout
473
473
  });
474
- const stage = await new Promise((resolve) => {
474
+ const stage = await new Promise((resolve2) => {
475
475
  const suggested = sanitizeStageName(os.userInfo().username) || "local";
476
476
  const instruction = !isRetry ? `Please enter a name you\u2019d like to use for your personal stage.` : `Please enter a name that starts with a letter, followed by letters, numbers, or hyphens.`;
477
477
  rl.question(
@@ -479,7 +479,7 @@ async function promptPersonalStage(out, isRetry) {
479
479
  async (input) => {
480
480
  rl.close();
481
481
  const result = input === "" ? suggested : input;
482
- resolve(result);
482
+ resolve2(result);
483
483
  }
484
484
  );
485
485
  });
@@ -541,7 +541,7 @@ var init_project = __esm({
541
541
  // src/cli/telemetry/post-payload.ts
542
542
  import https from "https";
543
543
  function postPayload(endpoint, body) {
544
- return new Promise((resolve, reject) => {
544
+ return new Promise((resolve2, reject) => {
545
545
  try {
546
546
  const req = https.request(
547
547
  endpoint,
@@ -555,7 +555,7 @@ function postPayload(endpoint, body) {
555
555
  reject(new Error(`Unexpected status code: ${resp.statusCode}`));
556
556
  return;
557
557
  }
558
- resolve();
558
+ resolve2();
559
559
  }
560
560
  );
561
561
  req.write(JSON.stringify(body));
@@ -981,11 +981,11 @@ function __metadata(metadataKey, metadataValue) {
981
981
  }
982
982
  function __awaiter(thisArg, _arguments, P, generator2) {
983
983
  function adopt(value) {
984
- return value instanceof P ? value : new P(function(resolve) {
985
- resolve(value);
984
+ return value instanceof P ? value : new P(function(resolve2) {
985
+ resolve2(value);
986
986
  });
987
987
  }
988
- return new (P || (P = Promise))(function(resolve, reject) {
988
+ return new (P || (P = Promise))(function(resolve2, reject) {
989
989
  function fulfilled(value) {
990
990
  try {
991
991
  step(generator2.next(value));
@@ -1001,7 +1001,7 @@ function __awaiter(thisArg, _arguments, P, generator2) {
1001
1001
  }
1002
1002
  }
1003
1003
  function step(result) {
1004
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1004
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
1005
1005
  }
1006
1006
  step((generator2 = generator2.apply(thisArg, _arguments || [])).next());
1007
1007
  });
@@ -1109,8 +1109,8 @@ function __read(o, n) {
1109
1109
  try {
1110
1110
  while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
1111
1111
  ar.push(r.value);
1112
- } catch (error2) {
1113
- e = { error: error2 };
1112
+ } catch (error3) {
1113
+ e = { error: error3 };
1114
1114
  } finally {
1115
1115
  try {
1116
1116
  if (r && !r.done && (m = i["return"]))
@@ -1207,14 +1207,14 @@ function __asyncValues(o) {
1207
1207
  }, i);
1208
1208
  function verb(n) {
1209
1209
  i[n] = o[n] && function(v) {
1210
- return new Promise(function(resolve, reject) {
1211
- v = o[n](v), settle(resolve, reject, v.done, v.value);
1210
+ return new Promise(function(resolve2, reject) {
1211
+ v = o[n](v), settle(resolve2, reject, v.done, v.value);
1212
1212
  });
1213
1213
  };
1214
1214
  }
1215
- function settle(resolve, reject, d, v) {
1215
+ function settle(resolve2, reject, d, v) {
1216
1216
  Promise.resolve(v).then(function(v2) {
1217
- resolve({ value: v2, done: d });
1217
+ resolve2({ value: v2, done: d });
1218
1218
  }, reject);
1219
1219
  }
1220
1220
  }
@@ -1714,11 +1714,11 @@ var init_credentials = __esm({
1714
1714
  input: process.stdin,
1715
1715
  output: process.stdout
1716
1716
  });
1717
- return new Promise((resolve) => {
1717
+ return new Promise((resolve2) => {
1718
1718
  Logger.debug(`Require MFA token for serial ARN ${serialArn}`);
1719
1719
  const prompt = () => rl.question(`Enter MFA code for ${serialArn}: `, async (input) => {
1720
1720
  if (input.trim() !== "") {
1721
- resolve(input.trim());
1721
+ resolve2(input.trim());
1722
1722
  rl.close();
1723
1723
  } else {
1724
1724
  prompt();
@@ -2084,7 +2084,7 @@ async function monitor(stack) {
2084
2084
  }
2085
2085
  throw ex;
2086
2086
  }
2087
- await new Promise((resolve) => setTimeout(resolve, 1e3));
2087
+ await new Promise((resolve2) => setTimeout(resolve2, 1e3));
2088
2088
  }
2089
2089
  }
2090
2090
  function filterOutputs(input) {
@@ -2136,6 +2136,750 @@ var init_monitor = __esm({
2136
2136
  }
2137
2137
  });
2138
2138
 
2139
+ // src/cdk-assets/private/docker.ts
2140
+ import * as fs5 from "fs";
2141
+ import * as os3 from "os";
2142
+ import * as path5 from "path";
2143
+ import {
2144
+ cdkCredentialsConfig,
2145
+ obtainEcrCredentials
2146
+ } from "cdk-assets/lib/private/docker-credentials.js";
2147
+ import {
2148
+ shell
2149
+ } from "cdk-assets/lib/private/shell.js";
2150
+ import { createCriticalSection } from "cdk-assets/lib/private/util.js";
2151
+ function getDockerCmd() {
2152
+ return process.env.CDK_DOCKER ?? "docker";
2153
+ }
2154
+ function flatten(x) {
2155
+ return Array.prototype.concat([], ...x);
2156
+ }
2157
+ var Docker, DockerFactory;
2158
+ var init_docker = __esm({
2159
+ "src/cdk-assets/private/docker.ts"() {
2160
+ "use strict";
2161
+ Docker = class {
2162
+ constructor(logger) {
2163
+ this.logger = logger;
2164
+ }
2165
+ configDir = void 0;
2166
+ async exists(tag) {
2167
+ try {
2168
+ await this.execute(["inspect", tag], { quiet: true });
2169
+ return true;
2170
+ } catch (e) {
2171
+ const error3 = e;
2172
+ if (error3.code !== "PROCESS_FAILED") {
2173
+ throw error3;
2174
+ }
2175
+ switch (error3.exitCode) {
2176
+ case 1 /* Docker */:
2177
+ case 125 /* Podman */:
2178
+ return false;
2179
+ default:
2180
+ throw error3;
2181
+ }
2182
+ }
2183
+ }
2184
+ async build(options) {
2185
+ const buildCommand = [
2186
+ "build",
2187
+ ...flatten(
2188
+ Object.entries(options.buildArgs || {}).map(([k, v]) => [
2189
+ "--build-arg",
2190
+ `${k}=${v}`
2191
+ ])
2192
+ ),
2193
+ ...flatten(
2194
+ Object.entries(options.buildSecrets || {}).map(([k, v]) => [
2195
+ "--secret",
2196
+ `id=${k},${v}`
2197
+ ])
2198
+ ),
2199
+ "--tag",
2200
+ options.tag,
2201
+ ...options.target ? ["--target", options.target] : [],
2202
+ ...options.file ? ["--file", options.file] : [],
2203
+ ...options.networkMode ? ["--network", options.networkMode] : [],
2204
+ ...options.platform ? ["--platform", options.platform] : [],
2205
+ ...options.outputs ? options.outputs.map((output) => [`--output=${output}`]) : [],
2206
+ ...options.cacheFrom ? [
2207
+ ...options.cacheFrom.map((cacheFrom) => [
2208
+ "--cache-from",
2209
+ this.cacheOptionToFlag(cacheFrom)
2210
+ ]).flat()
2211
+ ] : [],
2212
+ ...options.cacheTo ? ["--cache-to", this.cacheOptionToFlag(options.cacheTo)] : [],
2213
+ "."
2214
+ ];
2215
+ await this.execute(buildCommand, {
2216
+ cwd: options.directory,
2217
+ quiet: options.quiet
2218
+ });
2219
+ }
2220
+ async login(ecr) {
2221
+ const credentials = await obtainEcrCredentials(ecr);
2222
+ await this.execute(
2223
+ [
2224
+ "login",
2225
+ "--username",
2226
+ credentials.username,
2227
+ "--password-stdin",
2228
+ credentials.endpoint
2229
+ ],
2230
+ {
2231
+ input: credentials.password,
2232
+ quiet: true
2233
+ }
2234
+ );
2235
+ }
2236
+ async tag(sourceTag, targetTag) {
2237
+ await this.execute(["tag", sourceTag, targetTag]);
2238
+ }
2239
+ async push(options) {
2240
+ await this.execute(["push", options.tag], { quiet: options.quiet });
2241
+ }
2242
+ configureCdkCredentials() {
2243
+ const config = cdkCredentialsConfig();
2244
+ if (!config) {
2245
+ return false;
2246
+ }
2247
+ this.configDir = fs5.mkdtempSync(path5.join(os3.tmpdir(), "cdkDockerConfig"));
2248
+ const domains = Object.keys(config.domainCredentials);
2249
+ const credHelpers = domains.reduce(
2250
+ (map3, domain) => {
2251
+ map3[domain] = "cdk-assets";
2252
+ return map3;
2253
+ },
2254
+ {}
2255
+ );
2256
+ fs5.writeFileSync(
2257
+ path5.join(this.configDir, "config.json"),
2258
+ JSON.stringify({ credHelpers }),
2259
+ { encoding: "utf-8" }
2260
+ );
2261
+ return true;
2262
+ }
2263
+ resetAuthPlugins() {
2264
+ this.configDir = void 0;
2265
+ }
2266
+ async execute(args, options = {}) {
2267
+ const configArgs = this.configDir ? ["--config", this.configDir] : [];
2268
+ const pathToCdkAssets = "";
2269
+ try {
2270
+ await shell([getDockerCmd(), ...configArgs, ...args], {
2271
+ logger: this.logger,
2272
+ ...options,
2273
+ env: {
2274
+ ...process.env,
2275
+ ...options.env,
2276
+ PATH: `${pathToCdkAssets}${path5.delimiter}${options.env?.PATH ?? process.env.PATH}`
2277
+ }
2278
+ });
2279
+ } catch (e) {
2280
+ if (e.code === "ENOENT") {
2281
+ throw new Error(
2282
+ "Unable to execute 'docker' in order to build a container asset. Please install 'docker' and try again."
2283
+ );
2284
+ }
2285
+ throw e;
2286
+ }
2287
+ }
2288
+ cacheOptionToFlag(option) {
2289
+ let flag = `type=${option.type}`;
2290
+ if (option.params) {
2291
+ flag += "," + Object.entries(option.params).map(([k, v]) => `${k}=${v}`).join(",");
2292
+ }
2293
+ return flag;
2294
+ }
2295
+ };
2296
+ DockerFactory = class {
2297
+ enterLoggedInDestinationsCriticalSection = createCriticalSection();
2298
+ loggedInDestinations = /* @__PURE__ */ new Set();
2299
+ async forBuild(options) {
2300
+ const docker = new Docker(options.logger);
2301
+ let cdkDockerCredentialsConfigured = docker.configureCdkCredentials();
2302
+ if (!cdkDockerCredentialsConfigured) {
2303
+ await this.loginOncePerDestination(docker, options);
2304
+ }
2305
+ return docker;
2306
+ }
2307
+ async forEcrPush(options) {
2308
+ const docker = new Docker(options.logger);
2309
+ await this.loginOncePerDestination(docker, options);
2310
+ return docker;
2311
+ }
2312
+ async loginOncePerDestination(docker, options) {
2313
+ const repositoryDomain = options.repoUri.split("/")[0];
2314
+ await this.enterLoggedInDestinationsCriticalSection(async () => {
2315
+ if (this.loggedInDestinations.has(repositoryDomain)) {
2316
+ return;
2317
+ }
2318
+ await docker.login(options.ecr);
2319
+ this.loggedInDestinations.add(repositoryDomain);
2320
+ });
2321
+ }
2322
+ };
2323
+ }
2324
+ });
2325
+
2326
+ // src/cdk-assets/private/handlers/container-images.ts
2327
+ import * as path6 from "path";
2328
+ import { EventType } from "cdk-assets/lib/progress.js";
2329
+ import { replaceAwsPlaceholders } from "cdk-assets/lib/private/placeholders.js";
2330
+ import { shell as shell2 } from "cdk-assets/lib/private/shell.js";
2331
+ async function imageExists(ecr, repositoryName, imageTag) {
2332
+ try {
2333
+ await ecr.describeImages({ repositoryName, imageIds: [{ imageTag }] }).promise();
2334
+ return true;
2335
+ } catch (e) {
2336
+ if (e.code !== "ImageNotFoundException") {
2337
+ throw e;
2338
+ }
2339
+ return false;
2340
+ }
2341
+ }
2342
+ async function repositoryUri(ecr, repositoryName) {
2343
+ try {
2344
+ const response = await ecr.describeRepositories({ repositoryNames: [repositoryName] }).promise();
2345
+ return (response.repositories || [])[0]?.repositoryUri;
2346
+ } catch (e) {
2347
+ if (e.code !== "RepositoryNotFoundException") {
2348
+ throw e;
2349
+ }
2350
+ return void 0;
2351
+ }
2352
+ }
2353
+ var ContainerImageAssetHandler, ContainerImageBuilder;
2354
+ var init_container_images = __esm({
2355
+ "src/cdk-assets/private/handlers/container-images.ts"() {
2356
+ "use strict";
2357
+ ContainerImageAssetHandler = class {
2358
+ constructor(workDir, asset, host, options) {
2359
+ this.workDir = workDir;
2360
+ this.asset = asset;
2361
+ this.host = host;
2362
+ this.options = options;
2363
+ }
2364
+ init;
2365
+ async build() {
2366
+ const initOnce = await this.initOnce();
2367
+ if (initOnce.destinationAlreadyExists) {
2368
+ return;
2369
+ }
2370
+ if (this.host.aborted) {
2371
+ return;
2372
+ }
2373
+ const dockerForBuilding = await this.host.dockerFactory.forBuild({
2374
+ repoUri: initOnce.repoUri,
2375
+ logger: (m) => this.host.emitMessage(EventType.DEBUG, m),
2376
+ ecr: initOnce.ecr
2377
+ });
2378
+ const builder = new ContainerImageBuilder(
2379
+ dockerForBuilding,
2380
+ this.workDir,
2381
+ this.asset,
2382
+ this.host,
2383
+ {
2384
+ quiet: this.options.quiet
2385
+ }
2386
+ );
2387
+ const localTagName = await builder.build();
2388
+ if (localTagName === void 0 || this.host.aborted) {
2389
+ return;
2390
+ }
2391
+ if (this.host.aborted) {
2392
+ return;
2393
+ }
2394
+ await dockerForBuilding.tag(localTagName, initOnce.imageUri);
2395
+ }
2396
+ async isPublished() {
2397
+ try {
2398
+ const initOnce = await this.initOnce({ quiet: true });
2399
+ return initOnce.destinationAlreadyExists;
2400
+ } catch (e) {
2401
+ this.host.emitMessage(EventType.DEBUG, `${e.message}`);
2402
+ }
2403
+ return false;
2404
+ }
2405
+ async publish() {
2406
+ const initOnce = await this.initOnce();
2407
+ if (initOnce.destinationAlreadyExists) {
2408
+ return;
2409
+ }
2410
+ if (this.host.aborted) {
2411
+ return;
2412
+ }
2413
+ const dockerForPushing = await this.host.dockerFactory.forEcrPush({
2414
+ repoUri: initOnce.repoUri,
2415
+ logger: (m) => this.host.emitMessage(EventType.DEBUG, m),
2416
+ ecr: initOnce.ecr
2417
+ });
2418
+ if (this.host.aborted) {
2419
+ return;
2420
+ }
2421
+ this.host.emitMessage(EventType.UPLOAD, `Push ${initOnce.imageUri}`);
2422
+ await dockerForPushing.push({
2423
+ tag: initOnce.imageUri,
2424
+ quiet: this.options.quiet
2425
+ });
2426
+ }
2427
+ async initOnce(options = {}) {
2428
+ if (this.init) {
2429
+ return this.init;
2430
+ }
2431
+ const destination = await replaceAwsPlaceholders(
2432
+ this.asset.destination,
2433
+ this.host.aws
2434
+ );
2435
+ const ecr = await this.host.aws.ecrClient({
2436
+ ...destination,
2437
+ quiet: options.quiet
2438
+ });
2439
+ const account = async () => (await this.host.aws.discoverCurrentAccount())?.accountId;
2440
+ const repoUri = await repositoryUri(ecr, destination.repositoryName);
2441
+ if (!repoUri) {
2442
+ throw new Error(
2443
+ `No ECR repository named '${destination.repositoryName}' in account ${await account()}. Is this account bootstrapped?`
2444
+ );
2445
+ }
2446
+ const imageUri = `${repoUri}:${destination.imageTag}`;
2447
+ this.init = {
2448
+ imageUri,
2449
+ ecr,
2450
+ repoUri,
2451
+ destinationAlreadyExists: await this.destinationAlreadyExists(
2452
+ ecr,
2453
+ destination,
2454
+ imageUri
2455
+ )
2456
+ };
2457
+ return this.init;
2458
+ }
2459
+ async destinationAlreadyExists(ecr, destination, imageUri) {
2460
+ this.host.emitMessage(EventType.CHECK, `Check ${imageUri}`);
2461
+ if (await imageExists(ecr, destination.repositoryName, destination.imageTag)) {
2462
+ this.host.emitMessage(EventType.FOUND, `Found ${imageUri}`);
2463
+ return true;
2464
+ }
2465
+ return false;
2466
+ }
2467
+ };
2468
+ ContainerImageBuilder = class {
2469
+ constructor(docker, workDir, asset, host, options) {
2470
+ this.docker = docker;
2471
+ this.workDir = workDir;
2472
+ this.asset = asset;
2473
+ this.host = host;
2474
+ this.options = options;
2475
+ }
2476
+ async build() {
2477
+ return this.asset.source.executable ? this.buildExternalAsset(this.asset.source.executable) : this.buildDirectoryAsset();
2478
+ }
2479
+ async buildDirectoryAsset() {
2480
+ const localTagName = `cdkasset-${this.asset.id.assetId.toLowerCase()}`;
2481
+ if (!await this.isImageCached(localTagName)) {
2482
+ if (this.host.aborted) {
2483
+ return void 0;
2484
+ }
2485
+ await this.buildImage(localTagName);
2486
+ }
2487
+ return localTagName;
2488
+ }
2489
+ async buildExternalAsset(executable, cwd) {
2490
+ const assetPath = cwd ?? this.workDir;
2491
+ this.host.emitMessage(
2492
+ EventType.BUILD,
2493
+ `Building Docker image using command '${executable}'`
2494
+ );
2495
+ if (this.host.aborted) {
2496
+ return void 0;
2497
+ }
2498
+ return (await shell2(executable, { cwd: assetPath, quiet: true })).trim();
2499
+ }
2500
+ async buildImage(localTagName) {
2501
+ const source = this.asset.source;
2502
+ if (!source.directory) {
2503
+ throw new Error(
2504
+ `'directory' is expected in the DockerImage asset source, got: ${JSON.stringify(
2505
+ source
2506
+ )}`
2507
+ );
2508
+ }
2509
+ const fullPath = path6.resolve(this.workDir, source.directory);
2510
+ this.host.emitMessage(
2511
+ EventType.BUILD,
2512
+ `Building Docker image at ${fullPath}`
2513
+ );
2514
+ await this.docker.build({
2515
+ directory: fullPath,
2516
+ tag: localTagName,
2517
+ buildArgs: source.dockerBuildArgs,
2518
+ buildSecrets: source.dockerBuildSecrets,
2519
+ target: source.dockerBuildTarget,
2520
+ file: source.dockerFile,
2521
+ networkMode: source.networkMode,
2522
+ platform: source.platform,
2523
+ outputs: source.dockerOutputs,
2524
+ cacheFrom: source.cacheFrom,
2525
+ cacheTo: source.cacheTo,
2526
+ quiet: this.options.quiet
2527
+ });
2528
+ }
2529
+ async isImageCached(localTagName) {
2530
+ if (await this.docker.exists(localTagName)) {
2531
+ this.host.emitMessage(EventType.CACHED, `Cached ${localTagName}`);
2532
+ return true;
2533
+ }
2534
+ return false;
2535
+ }
2536
+ };
2537
+ }
2538
+ });
2539
+
2540
+ // src/cdk-assets/private/handlers/index.ts
2541
+ import { FileAssetHandler } from "cdk-assets/lib/private/handlers/files.js";
2542
+ import {
2543
+ DockerImageManifestEntry,
2544
+ FileManifestEntry
2545
+ } from "cdk-assets/lib/asset-manifest.js";
2546
+ function makeAssetHandler(manifest, asset, host, options) {
2547
+ if (asset instanceof FileManifestEntry) {
2548
+ return new FileAssetHandler(manifest.directory, asset, host);
2549
+ }
2550
+ if (asset instanceof DockerImageManifestEntry) {
2551
+ return new ContainerImageAssetHandler(
2552
+ manifest.directory,
2553
+ asset,
2554
+ host,
2555
+ options
2556
+ );
2557
+ }
2558
+ throw new Error(`Unrecognized asset type: '${asset}'`);
2559
+ }
2560
+ var init_handlers = __esm({
2561
+ "src/cdk-assets/private/handlers/index.ts"() {
2562
+ "use strict";
2563
+ init_container_images();
2564
+ }
2565
+ });
2566
+
2567
+ // src/cdk-assets/publishing.ts
2568
+ import {
2569
+ EventType as EventType2
2570
+ } from "cdk-assets/lib/progress.js";
2571
+ var AssetPublishing;
2572
+ var init_publishing = __esm({
2573
+ "src/cdk-assets/publishing.ts"() {
2574
+ "use strict";
2575
+ init_docker();
2576
+ init_handlers();
2577
+ AssetPublishing = class {
2578
+ constructor(manifest, options) {
2579
+ this.manifest = manifest;
2580
+ this.options = options;
2581
+ this.assets = manifest.entries;
2582
+ this.totalOperations = this.assets.length;
2583
+ this.publishInParallel = options.publishInParallel ?? false;
2584
+ this.buildAssets = options.buildAssets ?? true;
2585
+ this.publishAssets = options.publishAssets ?? true;
2586
+ const self = this;
2587
+ this.handlerHost = {
2588
+ aws: this.options.aws,
2589
+ get aborted() {
2590
+ return self.aborted;
2591
+ },
2592
+ emitMessage(t, m) {
2593
+ self.progressEvent(t, m);
2594
+ },
2595
+ dockerFactory: new DockerFactory()
2596
+ };
2597
+ }
2598
+ message = "Starting";
2599
+ currentAsset;
2600
+ failures = new Array();
2601
+ assets;
2602
+ totalOperations;
2603
+ completedOperations = 0;
2604
+ aborted = false;
2605
+ handlerHost;
2606
+ publishInParallel;
2607
+ buildAssets;
2608
+ publishAssets;
2609
+ handlerCache = /* @__PURE__ */ new Map();
2610
+ async publish() {
2611
+ if (this.publishInParallel) {
2612
+ await Promise.all(
2613
+ this.assets.map(async (asset) => this.publishAsset(asset))
2614
+ );
2615
+ } else {
2616
+ for (const asset of this.assets) {
2617
+ if (!await this.publishAsset(asset)) {
2618
+ break;
2619
+ }
2620
+ }
2621
+ }
2622
+ if ((this.options.throwOnError ?? true) && this.failures.length > 0) {
2623
+ throw new Error(
2624
+ `Error publishing: ${this.failures.map((e) => e.error.message)}`
2625
+ );
2626
+ }
2627
+ }
2628
+ async buildEntry(asset) {
2629
+ try {
2630
+ if (this.progressEvent(EventType2.START, `Building ${asset.id}`)) {
2631
+ return false;
2632
+ }
2633
+ const handler = this.assetHandler(asset);
2634
+ await handler.build();
2635
+ if (this.aborted) {
2636
+ throw new Error("Aborted");
2637
+ }
2638
+ this.completedOperations++;
2639
+ if (this.progressEvent(EventType2.SUCCESS, `Built ${asset.id}`)) {
2640
+ return false;
2641
+ }
2642
+ } catch (e) {
2643
+ this.failures.push({ asset, error: e });
2644
+ this.completedOperations++;
2645
+ if (this.progressEvent(EventType2.FAIL, e.message)) {
2646
+ return false;
2647
+ }
2648
+ }
2649
+ return true;
2650
+ }
2651
+ async publishEntry(asset) {
2652
+ try {
2653
+ if (this.progressEvent(EventType2.START, `Publishing ${asset.id}`)) {
2654
+ return false;
2655
+ }
2656
+ const handler = this.assetHandler(asset);
2657
+ await handler.publish();
2658
+ if (this.aborted) {
2659
+ throw new Error("Aborted");
2660
+ }
2661
+ this.completedOperations++;
2662
+ if (this.progressEvent(EventType2.SUCCESS, `Published ${asset.id}`)) {
2663
+ return false;
2664
+ }
2665
+ } catch (e) {
2666
+ this.failures.push({ asset, error: e });
2667
+ this.completedOperations++;
2668
+ if (this.progressEvent(EventType2.FAIL, e.message)) {
2669
+ return false;
2670
+ }
2671
+ }
2672
+ return true;
2673
+ }
2674
+ isEntryPublished(asset) {
2675
+ const handler = this.assetHandler(asset);
2676
+ return handler.isPublished();
2677
+ }
2678
+ async publishAsset(asset) {
2679
+ try {
2680
+ if (this.progressEvent(EventType2.START, `Publishing ${asset.id}`)) {
2681
+ return false;
2682
+ }
2683
+ const handler = this.assetHandler(asset);
2684
+ if (this.buildAssets) {
2685
+ await handler.build();
2686
+ }
2687
+ if (this.publishAssets) {
2688
+ await handler.publish();
2689
+ }
2690
+ if (this.aborted) {
2691
+ throw new Error("Aborted");
2692
+ }
2693
+ this.completedOperations++;
2694
+ if (this.progressEvent(EventType2.SUCCESS, `Published ${asset.id}`)) {
2695
+ return false;
2696
+ }
2697
+ } catch (e) {
2698
+ this.failures.push({ asset, error: e });
2699
+ this.completedOperations++;
2700
+ if (this.progressEvent(EventType2.FAIL, e.message)) {
2701
+ return false;
2702
+ }
2703
+ }
2704
+ return true;
2705
+ }
2706
+ get percentComplete() {
2707
+ if (this.totalOperations === 0) {
2708
+ return 100;
2709
+ }
2710
+ return Math.floor(this.completedOperations / this.totalOperations * 100);
2711
+ }
2712
+ abort() {
2713
+ this.aborted = true;
2714
+ }
2715
+ get hasFailures() {
2716
+ return this.failures.length > 0;
2717
+ }
2718
+ progressEvent(event, message) {
2719
+ this.message = message;
2720
+ if (this.options.progressListener) {
2721
+ this.options.progressListener.onPublishEvent(event, this);
2722
+ }
2723
+ return this.aborted;
2724
+ }
2725
+ assetHandler(asset) {
2726
+ const existing = this.handlerCache.get(asset);
2727
+ if (existing) {
2728
+ return existing;
2729
+ }
2730
+ const ret = makeAssetHandler(this.manifest, asset, this.handlerHost, {
2731
+ quiet: this.options.quiet
2732
+ });
2733
+ this.handlerCache.set(asset, ret);
2734
+ return ret;
2735
+ }
2736
+ };
2737
+ }
2738
+ });
2739
+
2740
+ // src/cdk/asset-publishing.ts
2741
+ import * as cxapi from "@aws-cdk/cx-api";
2742
+ import * as cdk_assets from "cdk-assets";
2743
+ import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
2744
+ import { debug, error, print } from "sst-aws-cdk/lib/logging.js";
2745
+ async function publishAssets(manifest, sdk, targetEnv, options = {}) {
2746
+ if (targetEnv.account === void 0 || targetEnv.account === cxapi.UNKNOWN_ACCOUNT || targetEnv.region === void 0 || targetEnv.account === cxapi.UNKNOWN_REGION) {
2747
+ throw new Error(
2748
+ `Asset publishing requires resolved account and region, got ${JSON.stringify(
2749
+ targetEnv
2750
+ )}`
2751
+ );
2752
+ }
2753
+ const publisher = new AssetPublishing(manifest, {
2754
+ aws: new PublishingAws(sdk, targetEnv),
2755
+ progressListener: new PublishingProgressListener(options.quiet ?? false),
2756
+ throwOnError: false,
2757
+ publishInParallel: options.parallel ?? true,
2758
+ buildAssets: options.buildAssets ?? true,
2759
+ publishAssets: true,
2760
+ quiet: options.quiet
2761
+ });
2762
+ await publisher.publish();
2763
+ if (publisher.hasFailures) {
2764
+ console.log(publisher.failures);
2765
+ throw new Error(
2766
+ "Failed to publish one or more assets. See the error messages above for more information."
2767
+ );
2768
+ }
2769
+ }
2770
+ async function buildAssets(manifest, sdk, targetEnv, options = {}) {
2771
+ if (targetEnv.account === void 0 || targetEnv.account === cxapi.UNKNOWN_ACCOUNT || targetEnv.region === void 0 || targetEnv.account === cxapi.UNKNOWN_REGION) {
2772
+ throw new Error(
2773
+ `Asset building requires resolved account and region, got ${JSON.stringify(
2774
+ targetEnv
2775
+ )}`
2776
+ );
2777
+ }
2778
+ const publisher = new cdk_assets.AssetPublishing(manifest, {
2779
+ aws: new PublishingAws(sdk, targetEnv),
2780
+ progressListener: new PublishingProgressListener(options.quiet ?? false),
2781
+ throwOnError: false,
2782
+ publishInParallel: options.parallel ?? true,
2783
+ buildAssets: true,
2784
+ publishAssets: false
2785
+ });
2786
+ await publisher.publish();
2787
+ if (publisher.hasFailures) {
2788
+ throw new Error(
2789
+ "Failed to build one or more assets. See the error messages above for more information."
2790
+ );
2791
+ }
2792
+ }
2793
+ var PublishingAws, EVENT_TO_LOGGER, PublishingProgressListener;
2794
+ var init_asset_publishing = __esm({
2795
+ "src/cdk/asset-publishing.ts"() {
2796
+ "use strict";
2797
+ init_publishing();
2798
+ PublishingAws = class {
2799
+ constructor(aws2, targetEnv) {
2800
+ this.aws = aws2;
2801
+ this.targetEnv = targetEnv;
2802
+ }
2803
+ sdkCache = /* @__PURE__ */ new Map();
2804
+ async discoverPartition() {
2805
+ return await this.aws.baseCredentialsPartition(
2806
+ this.targetEnv,
2807
+ Mode.ForWriting
2808
+ ) ?? "aws";
2809
+ }
2810
+ async discoverDefaultRegion() {
2811
+ return this.targetEnv.region;
2812
+ }
2813
+ async discoverCurrentAccount() {
2814
+ const account = await this.aws.defaultAccount();
2815
+ return account ?? {
2816
+ accountId: "<unknown account>",
2817
+ partition: "aws"
2818
+ };
2819
+ }
2820
+ async discoverTargetAccount(options) {
2821
+ return (await this.sdk(options)).currentAccount();
2822
+ }
2823
+ async s3Client(options) {
2824
+ return (await this.sdk(options)).s3();
2825
+ }
2826
+ async ecrClient(options) {
2827
+ return (await this.sdk(options)).ecr();
2828
+ }
2829
+ async secretsManagerClient(options) {
2830
+ return (await this.sdk(options)).secretsManager();
2831
+ }
2832
+ async sdk(options) {
2833
+ const env = {
2834
+ ...this.targetEnv,
2835
+ region: options.region ?? this.targetEnv.region
2836
+ };
2837
+ const cacheKey = JSON.stringify({
2838
+ env,
2839
+ assumeRuleArn: options.assumeRoleArn,
2840
+ assumeRoleExternalId: options.assumeRoleExternalId,
2841
+ quiet: options.quiet
2842
+ });
2843
+ const maybeSdk = this.sdkCache.get(cacheKey);
2844
+ if (maybeSdk) {
2845
+ return maybeSdk;
2846
+ }
2847
+ const sdk = (await this.aws.forEnvironment(
2848
+ env,
2849
+ Mode.ForWriting,
2850
+ {
2851
+ assumeRoleArn: options.assumeRoleArn,
2852
+ assumeRoleExternalId: options.assumeRoleExternalId
2853
+ },
2854
+ options.quiet
2855
+ )).sdk;
2856
+ this.sdkCache.set(cacheKey, sdk);
2857
+ return sdk;
2858
+ }
2859
+ };
2860
+ EVENT_TO_LOGGER = {
2861
+ build: debug,
2862
+ cached: debug,
2863
+ check: debug,
2864
+ debug,
2865
+ fail: error,
2866
+ found: debug,
2867
+ start: print,
2868
+ success: print,
2869
+ upload: debug
2870
+ };
2871
+ PublishingProgressListener = class {
2872
+ constructor(quiet) {
2873
+ this.quiet = quiet;
2874
+ }
2875
+ onPublishEvent(type, event) {
2876
+ const handler = this.quiet && type !== "fail" ? debug : EVENT_TO_LOGGER[type];
2877
+ handler(`[${event.percentComplete}%] ${type}: ${event.message}`);
2878
+ }
2879
+ };
2880
+ }
2881
+ });
2882
+
2139
2883
  // src/cdk/util.ts
2140
2884
  async function callWithRetry(cb) {
2141
2885
  try {
@@ -2154,14 +2898,14 @@ var init_util = __esm({
2154
2898
  });
2155
2899
 
2156
2900
  // src/cdk/deploy-stack.ts
2157
- import * as cxapi from "@aws-cdk/cx-api";
2158
- import fs5 from "fs/promises";
2901
+ import * as cxapi2 from "@aws-cdk/cx-api";
2902
+ import fs6 from "fs/promises";
2159
2903
  import * as uuid from "uuid";
2160
2904
  import { addMetadataAssetsToManifest } from "sst-aws-cdk/lib/assets.js";
2161
- import { debug, error, print } from "sst-aws-cdk/lib/logging.js";
2905
+ import { debug as debug2, error as error2, print as print2 } from "sst-aws-cdk/lib/logging.js";
2162
2906
  import { toYAML } from "sst-aws-cdk/lib/serialize.js";
2163
2907
  import { AssetManifestBuilder } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
2164
- import { publishAssets } from "sst-aws-cdk/lib/util/asset-publishing.js";
2908
+ import { publishAssets as publishAssets2 } from "sst-aws-cdk/lib/util/asset-publishing.js";
2165
2909
  import { contentHash } from "sst-aws-cdk/lib/util/content-hash.js";
2166
2910
  import { CfnEvaluationException } from "sst-aws-cdk/lib/api/evaluate-cloudformation-template.js";
2167
2911
  import { HotswapMode } from "sst-aws-cdk/lib/api/hotswap/common.js";
@@ -2185,7 +2929,7 @@ async function deployStack(options) {
2185
2929
  () => CloudFormationStack.lookup(cfn, deployName)
2186
2930
  );
2187
2931
  if (cloudFormationStack.stackStatus.isCreationFailure) {
2188
- debug(
2932
+ debug2(
2189
2933
  `Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`
2190
2934
  );
2191
2935
  await cfn.deleteStack({ StackName: deployName }).promise();
@@ -2217,7 +2961,7 @@ async function deployStack(options) {
2217
2961
  cloudFormationStack,
2218
2962
  stackParams.hasChanges(cloudFormationStack.parameters)
2219
2963
  )) {
2220
- debug(`${deployName}: skipping deployment (use --force to override)`);
2964
+ debug2(`${deployName}: skipping deployment (use --force to override)`);
2221
2965
  if (options.hotswap) {
2222
2966
  }
2223
2967
  return {
@@ -2226,7 +2970,7 @@ async function deployStack(options) {
2226
2970
  stackArn: cloudFormationStack.stackId
2227
2971
  };
2228
2972
  } else {
2229
- debug(`${deployName}: deploying...`);
2973
+ debug2(`${deployName}: deploying...`);
2230
2974
  }
2231
2975
  const bodyParameter = await makeBodyParameter(
2232
2976
  stackArtifact,
@@ -2236,7 +2980,7 @@ async function deployStack(options) {
2236
2980
  options.sdk,
2237
2981
  options.overrideTemplate
2238
2982
  );
2239
- await publishAssets(
2983
+ await publishAssets2(
2240
2984
  legacyAssets.toManifest(stackArtifact.assembly.directory),
2241
2985
  options.sdkProvider,
2242
2986
  stackEnv,
@@ -2257,7 +3001,7 @@ async function deployStack(options) {
2257
3001
  if (hotswapDeploymentResult) {
2258
3002
  return hotswapDeploymentResult;
2259
3003
  }
2260
- print(
3004
+ print2(
2261
3005
  "Could not perform a hotswap deployment, as the stack %s contains non-Asset changes",
2262
3006
  stackArtifact.displayName
2263
3007
  );
@@ -2265,13 +3009,13 @@ async function deployStack(options) {
2265
3009
  if (!(e instanceof CfnEvaluationException)) {
2266
3010
  throw e;
2267
3011
  }
2268
- print(
3012
+ print2(
2269
3013
  "Could not perform a hotswap deployment, because the CloudFormation template could not be resolved: %s",
2270
3014
  e.message
2271
3015
  );
2272
3016
  }
2273
3017
  if (hotswapMode === HotswapMode.FALL_BACK) {
2274
- print("Falling back to doing a full deployment");
3018
+ print2("Falling back to doing a full deployment");
2275
3019
  options.sdk.appendCustomUserAgent("cdk-hotswap/fallback");
2276
3020
  } else {
2277
3021
  return {
@@ -2305,7 +3049,7 @@ async function makeBodyParameter(stack, resolvedEnvironment, assetManifest, tool
2305
3049
  return { TemplateBody: templateJson };
2306
3050
  }
2307
3051
  if (!toolkitInfo.found) {
2308
- error(
3052
+ error2(
2309
3053
  `The template for stack "${stack.displayName}" is ${Math.round(
2310
3054
  templateJson.length / 1024
2311
3055
  )}KiB. Templates larger than ${LARGE_TEMPLATE_SIZE_KB}KiB must be uploaded to S3.
@@ -2324,7 +3068,7 @@ Run the following command in order to setup an S3 bucket in this environment, an
2324
3068
  let templateFile = stack.templateFile;
2325
3069
  if (overrideTemplate) {
2326
3070
  templateFile = `${stack.templateFile}-${templateHash}.yaml`;
2327
- await fs5.writeFile(templateFile, templateJson, { encoding: "utf-8" });
3071
+ await fs6.writeFile(templateFile, templateJson, { encoding: "utf-8" });
2328
3072
  }
2329
3073
  assetManifest.addFileAsset(
2330
3074
  templateHash,
@@ -2337,7 +3081,7 @@ Run the following command in order to setup an S3 bucket in this environment, an
2337
3081
  }
2338
3082
  );
2339
3083
  const templateURL = `${toolkitInfo.bucketUrl}/${key}`;
2340
- debug("Storing template in S3 at:", templateURL);
3084
+ debug2("Storing template in S3 at:", templateURL);
2341
3085
  return { TemplateURL: templateURL };
2342
3086
  }
2343
3087
  async function makeBodyParameterAndUpload(stack, resolvedEnvironment, toolkitInfo, sdkProvider, sdk, overrideTemplate) {
@@ -2354,7 +3098,7 @@ async function makeBodyParameterAndUpload(stack, resolvedEnvironment, toolkitInf
2354
3098
  overrideTemplate
2355
3099
  );
2356
3100
  const manifest = builder.toManifest(stack.assembly.directory);
2357
- await publishAssets(manifest, sdkProvider, resolvedEnvironment, {
3101
+ await publishAssets2(manifest, sdkProvider, resolvedEnvironment, {
2358
3102
  quiet: true
2359
3103
  });
2360
3104
  return bodyparam;
@@ -2381,47 +3125,47 @@ async function destroyStack(options) {
2381
3125
  }
2382
3126
  async function canSkipDeploy(deployStackOptions, cloudFormationStack, parameterChanges) {
2383
3127
  const deployName = deployStackOptions.deployName || deployStackOptions.stack.stackName;
2384
- debug(`${deployName}: checking if we can skip deploy`);
3128
+ debug2(`${deployName}: checking if we can skip deploy`);
2385
3129
  if (deployStackOptions.force) {
2386
- debug(`${deployName}: forced deployment`);
3130
+ debug2(`${deployName}: forced deployment`);
2387
3131
  return false;
2388
3132
  }
2389
3133
  if (deployStackOptions.deploymentMethod?.method === "change-set" && deployStackOptions.deploymentMethod.execute === false) {
2390
- debug(`${deployName}: --no-execute, always creating change set`);
3134
+ debug2(`${deployName}: --no-execute, always creating change set`);
2391
3135
  return false;
2392
3136
  }
2393
3137
  if (!cloudFormationStack.exists) {
2394
- debug(`${deployName}: no existing stack`);
3138
+ debug2(`${deployName}: no existing stack`);
2395
3139
  return false;
2396
3140
  }
2397
3141
  if (cloudFormationStack.stackStatus.isInProgress) {
2398
- debug(`${deployName}: stack is busy`);
3142
+ debug2(`${deployName}: stack is busy`);
2399
3143
  return false;
2400
3144
  }
2401
3145
  if (JSON.stringify(deployStackOptions.stack.template) !== JSON.stringify(await cloudFormationStack.template())) {
2402
- debug(`${deployName}: template has changed`);
3146
+ debug2(`${deployName}: template has changed`);
2403
3147
  return false;
2404
3148
  }
2405
3149
  if (!compareTags(cloudFormationStack.tags, deployStackOptions.tags ?? [])) {
2406
- debug(`${deployName}: tags have changed`);
3150
+ debug2(`${deployName}: tags have changed`);
2407
3151
  return false;
2408
3152
  }
2409
3153
  if (!!deployStackOptions.stack.terminationProtection !== !!cloudFormationStack.terminationProtection) {
2410
- debug(`${deployName}: termination protection has been updated`);
3154
+ debug2(`${deployName}: termination protection has been updated`);
2411
3155
  return false;
2412
3156
  }
2413
3157
  if (parameterChanges) {
2414
3158
  if (parameterChanges === "ssm") {
2415
- debug(
3159
+ debug2(
2416
3160
  `${deployName}: some parameters come from SSM so we have to assume they may have changed`
2417
3161
  );
2418
3162
  } else {
2419
- debug(`${deployName}: parameters have changed`);
3163
+ debug2(`${deployName}: parameters have changed`);
2420
3164
  }
2421
3165
  return false;
2422
3166
  }
2423
3167
  if (cloudFormationStack.stackStatus.isFailure) {
2424
- debug(`${deployName}: stack is in a failure state`);
3168
+ debug2(`${deployName}: stack is in a failure state`);
2425
3169
  return false;
2426
3170
  }
2427
3171
  return true;
@@ -2440,7 +3184,7 @@ function compareTags(a, b) {
2440
3184
  }
2441
3185
  function restUrlFromManifest(url10, environment, sdk) {
2442
3186
  const doNotUseMarker = "**DONOTUSE**";
2443
- url10 = cxapi.EnvironmentPlaceholders.replace(url10, {
3187
+ url10 = cxapi2.EnvironmentPlaceholders.replace(url10, {
2444
3188
  accountId: environment.account,
2445
3189
  region: environment.region,
2446
3190
  partition: doNotUseMarker
@@ -2509,9 +3253,9 @@ var init_deploy_stack = __esm({
2509
3253
  );
2510
3254
  await this.updateTerminationProtection();
2511
3255
  if (changeSetHasNoChanges(changeSetDescription)) {
2512
- debug("No changes are to be performed on %s.", this.stackName);
3256
+ debug2("No changes are to be performed on %s.", this.stackName);
2513
3257
  if (execute) {
2514
- debug("Deleting empty change set %s", changeSetDescription.ChangeSetId);
3258
+ debug2("Deleting empty change set %s", changeSetDescription.ChangeSetId);
2515
3259
  await this.cfn.deleteChangeSet({
2516
3260
  StackName: this.stackName,
2517
3261
  ChangeSetName: changeSetName
@@ -2524,7 +3268,7 @@ var init_deploy_stack = __esm({
2524
3268
  };
2525
3269
  }
2526
3270
  if (!execute) {
2527
- print(
3271
+ print2(
2528
3272
  "Changeset %s created and waiting in review for manual execution (--no-execute)",
2529
3273
  changeSetDescription.ChangeSetId
2530
3274
  );
@@ -2538,7 +3282,7 @@ var init_deploy_stack = __esm({
2538
3282
  }
2539
3283
  async createChangeSet(changeSetName, willExecute) {
2540
3284
  await this.cleanupOldChangeset(changeSetName);
2541
- debug(
3285
+ debug2(
2542
3286
  `Attempting to create ChangeSet with name ${changeSetName} to ${this.verb} stack ${this.stackName}`
2543
3287
  );
2544
3288
  const changeSet = await this.cfn.createChangeSet({
@@ -2550,7 +3294,7 @@ var init_deploy_stack = __esm({
2550
3294
  ClientToken: `create${this.uuid}`,
2551
3295
  ...this.commonPrepareOptions()
2552
3296
  }).promise();
2553
- debug(
3297
+ debug2(
2554
3298
  "Initiated creation of changeset: %s; waiting for it to finish creating...",
2555
3299
  changeSet.Id
2556
3300
  );
@@ -2559,7 +3303,7 @@ var init_deploy_stack = __esm({
2559
3303
  });
2560
3304
  }
2561
3305
  async executeChangeSet(changeSet) {
2562
- debug(
3306
+ debug2(
2563
3307
  "Initiating execution of changeset %s on stack %s",
2564
3308
  changeSet.ChangeSetId,
2565
3309
  this.stackName
@@ -2570,7 +3314,7 @@ var init_deploy_stack = __esm({
2570
3314
  ClientRequestToken: `exec${this.uuid}`,
2571
3315
  ...this.commonExecuteOptions()
2572
3316
  }).promise();
2573
- debug(
3317
+ debug2(
2574
3318
  "Execution of changeset %s on stack %s has started; waiting for the update to complete...",
2575
3319
  changeSet.ChangeSetId,
2576
3320
  this.stackName
@@ -2580,7 +3324,7 @@ var init_deploy_stack = __esm({
2580
3324
  }
2581
3325
  async cleanupOldChangeset(changeSetName) {
2582
3326
  if (this.cloudFormationStack.exists) {
2583
- debug(
3327
+ debug2(
2584
3328
  `Removing existing change set with name ${changeSetName} if it exists`
2585
3329
  );
2586
3330
  await this.cfn.deleteChangeSet({
@@ -2592,7 +3336,7 @@ var init_deploy_stack = __esm({
2592
3336
  async updateTerminationProtection() {
2593
3337
  const terminationProtection = this.stackArtifact.terminationProtection ?? false;
2594
3338
  if (!!this.cloudFormationStack.terminationProtection !== terminationProtection) {
2595
- debug(
3339
+ debug2(
2596
3340
  "Updating termination protection from %s to %s for stack %s",
2597
3341
  this.cloudFormationStack.terminationProtection,
2598
3342
  terminationProtection,
@@ -2602,7 +3346,7 @@ var init_deploy_stack = __esm({
2602
3346
  StackName: this.stackName,
2603
3347
  EnableTerminationProtection: terminationProtection
2604
3348
  }).promise();
2605
- debug(
3349
+ debug2(
2606
3350
  "Termination protection updated to %s for stack %s",
2607
3351
  terminationProtection,
2608
3352
  this.stackName
@@ -2651,7 +3395,7 @@ var init_deploy_stack = __esm({
2651
3395
  throw new Error(suffixWithErrors(e.message));
2652
3396
  } finally {
2653
3397
  }
2654
- debug("Stack %s has completed updating", this.stackName);
3398
+ debug2("Stack %s has completed updating", this.stackName);
2655
3399
  return {
2656
3400
  noOp: false,
2657
3401
  outputs: finalState.outputs,
@@ -2690,17 +3434,11 @@ __export(deployments_exports, {
2690
3434
  CloudFormationDeployments: () => CloudFormationDeployments,
2691
3435
  Deployments: () => Deployments
2692
3436
  });
2693
- import * as cxapi2 from "@aws-cdk/cx-api";
2694
- import * as cdk_assets from "cdk-assets";
2695
- import { AssetManifest } from "cdk-assets";
2696
- import { debug as debug2, warning } from "sst-aws-cdk/lib/logging.js";
2697
- import {
2698
- buildAssets,
2699
- publishAssets as publishAssets2,
2700
- PublishingAws,
2701
- EVENT_TO_LOGGER
2702
- } from "sst-aws-cdk/lib/util/asset-publishing.js";
2703
- import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
3437
+ import * as cxapi3 from "@aws-cdk/cx-api";
3438
+ import * as cdk_assets2 from "cdk-assets";
3439
+ import { AssetManifest as AssetManifest2 } from "cdk-assets";
3440
+ import { debug as debug3, warning } from "sst-aws-cdk/lib/logging.js";
3441
+ import { Mode as Mode2 } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
2704
3442
  import {
2705
3443
  loadCurrentTemplateWithNestedStacks,
2706
3444
  loadCurrentTemplate
@@ -2714,6 +3452,7 @@ var Deployments, ParallelSafeAssetProgress, CloudFormationDeployments;
2714
3452
  var init_deployments = __esm({
2715
3453
  "src/cdk/deployments.ts"() {
2716
3454
  "use strict";
3455
+ init_asset_publishing();
2717
3456
  init_deploy_stack();
2718
3457
  init_util();
2719
3458
  Deployments = class {
@@ -2734,18 +3473,18 @@ var init_deployments = __esm({
2734
3473
  )).deployedTemplate;
2735
3474
  }
2736
3475
  async readCurrentTemplate(stackArtifact) {
2737
- debug2(`Reading existing template for stack ${stackArtifact.displayName}.`);
3476
+ debug3(`Reading existing template for stack ${stackArtifact.displayName}.`);
2738
3477
  const sdk = (await this.prepareSdkWithLookupOrDeployRole(stackArtifact)).stackSdk;
2739
3478
  return loadCurrentTemplate(stackArtifact, sdk);
2740
3479
  }
2741
3480
  async resourceIdentifierSummaries(stackArtifact, toolkitStackName) {
2742
- debug2(
3481
+ debug3(
2743
3482
  `Retrieving template summary for stack ${stackArtifact.displayName}.`
2744
3483
  );
2745
3484
  const { stackSdk, resolvedEnvironment } = await this.prepareSdkFor(
2746
3485
  stackArtifact,
2747
3486
  void 0,
2748
- Mode.ForReading
3487
+ Mode2.ForReading
2749
3488
  );
2750
3489
  const cfn = stackSdk.cloudFormation();
2751
3490
  const toolkitInfo = await this.lookupToolkit(
@@ -2762,7 +3501,7 @@ var init_deployments = __esm({
2762
3501
  );
2763
3502
  const response = await cfn.getTemplateSummary(cfnParam).promise();
2764
3503
  if (!response.ResourceIdentifierSummaries) {
2765
- debug2(
3504
+ debug3(
2766
3505
  'GetTemplateSummary API call did not return "ResourceIdentifierSummaries"'
2767
3506
  );
2768
3507
  }
@@ -2782,7 +3521,7 @@ var init_deployments = __esm({
2782
3521
  execute: options.execute
2783
3522
  };
2784
3523
  }
2785
- const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn, Mode.ForWriting);
3524
+ const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn, Mode2.ForWriting);
2786
3525
  const toolkitInfo = await callWithRetry(
2787
3526
  () => this.lookupToolkit(
2788
3527
  resolvedEnvironment,
@@ -2797,11 +3536,11 @@ var init_deployments = __esm({
2797
3536
  toolkitInfo
2798
3537
  );
2799
3538
  const assetArtifacts = options.stack.dependencies.filter(
2800
- cxapi2.AssetManifestArtifact.isAssetManifestArtifact
3539
+ cxapi3.AssetManifestArtifact.isAssetManifestArtifact
2801
3540
  );
2802
3541
  for (const asset of assetArtifacts) {
2803
- const manifest = AssetManifest.fromFile(asset.file);
2804
- await publishAssets2(manifest, this.sdkProvider, resolvedEnvironment, {
3542
+ const manifest = AssetManifest2.fromFile(asset.file);
3543
+ await publishAssets(manifest, this.sdkProvider, resolvedEnvironment, {
2805
3544
  buildAssets: true,
2806
3545
  quiet: options.quiet,
2807
3546
  parallel: options.assetParallelism
@@ -2835,7 +3574,7 @@ var init_deployments = __esm({
2835
3574
  });
2836
3575
  }
2837
3576
  async destroyStack(options) {
2838
- const { stackSdk, cloudFormationRoleArn: roleArn } = await this.prepareSdkFor(options.stack, options.roleArn, Mode.ForWriting);
3577
+ const { stackSdk, cloudFormationRoleArn: roleArn } = await this.prepareSdkFor(options.stack, options.roleArn, Mode2.ForWriting);
2839
3578
  return destroyStack({
2840
3579
  sdk: stackSdk,
2841
3580
  roleArn,
@@ -2849,7 +3588,7 @@ var init_deployments = __esm({
2849
3588
  const { stackSdk } = await this.prepareSdkFor(
2850
3589
  options.stack,
2851
3590
  void 0,
2852
- Mode.ForReading
3591
+ Mode2.ForReading
2853
3592
  );
2854
3593
  const stack = await CloudFormationStack2.lookup(
2855
3594
  stackSdk.cloudFormation(),
@@ -2868,7 +3607,7 @@ var init_deployments = __esm({
2868
3607
  }
2869
3608
  } catch {
2870
3609
  }
2871
- return this.prepareSdkFor(stackArtifact, void 0, Mode.ForReading);
3610
+ return this.prepareSdkFor(stackArtifact, void 0, Mode2.ForReading);
2872
3611
  }
2873
3612
  async prepareSdkFor(stack, roleArn, mode) {
2874
3613
  if (!stack.environment) {
@@ -2917,7 +3656,7 @@ var init_deployments = __esm({
2917
3656
  try {
2918
3657
  const stackSdk = await this.cachedSdkForEnvironment(
2919
3658
  resolvedEnvironment,
2920
- Mode.ForReading,
3659
+ Mode2.ForReading,
2921
3660
  {
2922
3661
  assumeRoleArn: arns.lookupRoleArn,
2923
3662
  assumeRoleExternalId: stack.lookupRole?.assumeRoleExternalId
@@ -2938,7 +3677,7 @@ var init_deployments = __esm({
2938
3677
  }
2939
3678
  return { ...stackSdk, resolvedEnvironment };
2940
3679
  } catch (e) {
2941
- debug2(e);
3680
+ debug3(e);
2942
3681
  if (stack.lookupRole && stack.lookupRole.requiresBootstrapStackVersion) {
2943
3682
  warning(warningMessage);
2944
3683
  warning(upgradeMessage);
@@ -2964,7 +3703,7 @@ var init_deployments = __esm({
2964
3703
  const { stackSdk, resolvedEnvironment } = await this.prepareSdkFor(
2965
3704
  options.stack,
2966
3705
  options.roleArn,
2967
- Mode.ForWriting
3706
+ Mode2.ForWriting
2968
3707
  );
2969
3708
  const toolkitInfo = await this.lookupToolkit(
2970
3709
  resolvedEnvironment,
@@ -2980,7 +3719,7 @@ var init_deployments = __esm({
2980
3719
  asset.bootstrapStackVersionSsmParameter,
2981
3720
  toolkitInfo
2982
3721
  );
2983
- const manifest = AssetManifest.fromFile(asset.file);
3722
+ const manifest = AssetManifest2.fromFile(asset.file);
2984
3723
  return { manifest, stackEnv };
2985
3724
  }
2986
3725
  async buildAssets(asset, options) {
@@ -3000,7 +3739,7 @@ var init_deployments = __esm({
3000
3739
  asset,
3001
3740
  options
3002
3741
  );
3003
- await publishAssets2(
3742
+ await publishAssets(
3004
3743
  manifest,
3005
3744
  this.sdkProvider,
3006
3745
  stackEnv,
@@ -3008,7 +3747,7 @@ var init_deployments = __esm({
3008
3747
  );
3009
3748
  }
3010
3749
  async buildSingleAsset(assetArtifact, assetManifest, asset, options) {
3011
- const { stackSdk, resolvedEnvironment: stackEnv } = await this.prepareSdkFor(options.stack, options.roleArn, Mode.ForWriting);
3750
+ const { stackSdk, resolvedEnvironment: stackEnv } = await this.prepareSdkFor(options.stack, options.roleArn, Mode2.ForWriting);
3012
3751
  const toolkitInfo = await this.lookupToolkit(
3013
3752
  stackEnv,
3014
3753
  stackSdk,
@@ -3031,7 +3770,7 @@ var init_deployments = __esm({
3031
3770
  const { resolvedEnvironment: stackEnv } = await this.prepareSdkFor(
3032
3771
  options.stack,
3033
3772
  options.roleArn,
3034
- Mode.ForWriting
3773
+ Mode2.ForWriting
3035
3774
  );
3036
3775
  const publisher = this.cachedPublisher(
3037
3776
  assetManifest,
@@ -3044,7 +3783,7 @@ var init_deployments = __esm({
3044
3783
  const { resolvedEnvironment: stackEnv } = await this.prepareSdkFor(
3045
3784
  options.stack,
3046
3785
  options.roleArn,
3047
- Mode.ForWriting
3786
+ Mode2.ForWriting
3048
3787
  );
3049
3788
  const publisher = this.cachedPublisher(
3050
3789
  assetManifest,
@@ -3092,7 +3831,7 @@ var init_deployments = __esm({
3092
3831
  return existing;
3093
3832
  }
3094
3833
  const prefix = stackName ? `${stackName}: ` : "";
3095
- const publisher = new cdk_assets.AssetPublishing(assetManifest, {
3834
+ const publisher = new cdk_assets2.AssetPublishing(assetManifest, {
3096
3835
  aws: new PublishingAws(this.sdkProvider, env),
3097
3836
  progressListener: new ParallelSafeAssetProgress(
3098
3837
  prefix,
@@ -3109,7 +3848,7 @@ var init_deployments = __esm({
3109
3848
  this.quiet = quiet;
3110
3849
  }
3111
3850
  onPublishEvent(type, event) {
3112
- const handler = this.quiet && type !== "fail" ? debug2 : EVENT_TO_LOGGER[type];
3851
+ const handler = this.quiet && type !== "fail" ? debug3 : EVENT_TO_LOGGER[type];
3113
3852
  handler(`${this.prefix} ${type}: ${event.message}`);
3114
3853
  }
3115
3854
  };
@@ -3123,15 +3862,15 @@ var deployments_wrapper_exports = {};
3123
3862
  __export(deployments_wrapper_exports, {
3124
3863
  publishDeployAssets: () => publishDeployAssets
3125
3864
  });
3126
- import * as cxapi3 from "@aws-cdk/cx-api";
3127
- import { AssetManifest as AssetManifest2 } from "cdk-assets";
3128
- import { debug as debug3 } from "sst-aws-cdk/lib/logging.js";
3865
+ import * as cxapi4 from "@aws-cdk/cx-api";
3866
+ import { AssetManifest as AssetManifest3 } from "cdk-assets";
3867
+ import { debug as debug4 } from "sst-aws-cdk/lib/logging.js";
3129
3868
  import {
3130
3869
  CloudFormationStack as CloudFormationStack3,
3131
3870
  TemplateParameters as TemplateParameters2,
3132
3871
  waitForStackDelete as waitForStackDelete2
3133
3872
  } from "sst-aws-cdk/lib/api/util/cloudformation.js";
3134
- import { Mode as Mode2 } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
3873
+ import { Mode as Mode3 } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
3135
3874
  import { ToolkitInfo as ToolkitInfo2 } from "sst-aws-cdk/lib/api/toolkit-info.js";
3136
3875
  import { addMetadataAssetsToManifest as addMetadataAssetsToManifest2 } from "sst-aws-cdk/lib/assets.js";
3137
3876
  import { publishAssets as publishAssets3 } from "sst-aws-cdk/lib/util/asset-publishing.js";
@@ -3145,10 +3884,10 @@ async function publishDeployAssets(sdkProvider, options) {
3145
3884
  cloudFormationRoleArn
3146
3885
  } = await useDeployment().get(sdkProvider, options);
3147
3886
  const assetArtifacts = options.stack.dependencies.filter(
3148
- cxapi3.AssetManifestArtifact.isAssetManifestArtifact
3887
+ cxapi4.AssetManifestArtifact.isAssetManifestArtifact
3149
3888
  );
3150
3889
  for (const asset of assetArtifacts) {
3151
- const manifest = AssetManifest2.fromFile(asset.file);
3890
+ const manifest = AssetManifest3.fromFile(asset.file);
3152
3891
  await publishAssets3(manifest, sdkProvider, resolvedEnvironment, {
3153
3892
  buildAssets: true,
3154
3893
  quiet: options.quiet,
@@ -3190,7 +3929,7 @@ async function deployStack2(options) {
3190
3929
  const deployName = options.deployName || stackArtifact.stackName;
3191
3930
  let cloudFormationStack = await CloudFormationStack3.lookup(cfn, deployName);
3192
3931
  if (cloudFormationStack.stackStatus.isCreationFailure) {
3193
- debug3(
3932
+ debug4(
3194
3933
  `Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`
3195
3934
  );
3196
3935
  await cfn.deleteStack({ StackName: deployName }).promise();
@@ -3266,7 +4005,7 @@ var init_deployments_wrapper = __esm({
3266
4005
  const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await deployment.prepareSdkFor(
3267
4006
  options.stack,
3268
4007
  options.roleArn,
3269
- Mode2.ForWriting
4008
+ Mode3.ForWriting
3270
4009
  );
3271
4010
  const toolkitInfo = await ToolkitInfo2.lookup(
3272
4011
  resolvedEnvironment,
@@ -3326,7 +4065,7 @@ async function deployMany(stacks) {
3326
4065
  const complete = /* @__PURE__ */ new Set();
3327
4066
  const todo = new Set(stacks.map((s) => s.id));
3328
4067
  const results = {};
3329
- return new Promise((resolve) => {
4068
+ return new Promise((resolve2) => {
3330
4069
  async function trigger() {
3331
4070
  for (const stack of stacks) {
3332
4071
  if (!todo.has(stack.id))
@@ -3355,7 +4094,7 @@ async function deployMany(stacks) {
3355
4094
  }
3356
4095
  });
3357
4096
  if (complete.size === stacks.length) {
3358
- resolve(results);
4097
+ resolve2(results);
3359
4098
  }
3360
4099
  trigger();
3361
4100
  });
@@ -3491,13 +4230,13 @@ async function listImports(exportName) {
3491
4230
  }
3492
4231
  }
3493
4232
  async function getLocalTemplate(stack) {
3494
- const fs18 = await import("fs/promises");
3495
- const fileContent = await fs18.readFile(stack.templateFullPath);
4233
+ const fs19 = await import("fs/promises");
4234
+ const fileContent = await fs19.readFile(stack.templateFullPath);
3496
4235
  return fileContent.toString();
3497
4236
  }
3498
4237
  async function saveLocalTemplate(stack, content) {
3499
- const fs18 = await import("fs/promises");
3500
- await fs18.writeFile(stack.templateFullPath, content);
4238
+ const fs19 = await import("fs/promises");
4239
+ await fs19.writeFile(stack.templateFullPath, content);
3501
4240
  }
3502
4241
  var init_deploy = __esm({
3503
4242
  "src/stacks/deploy.ts"() {
@@ -3566,8 +4305,8 @@ var init_diff = __esm({
3566
4305
  });
3567
4306
 
3568
4307
  // src/cache.ts
3569
- import path5 from "path";
3570
- import fs6 from "fs/promises";
4308
+ import path7 from "path";
4309
+ import fs7 from "fs/promises";
3571
4310
  var useCache;
3572
4311
  var init_cache = __esm({
3573
4312
  "src/cache.ts"() {
@@ -3577,19 +4316,19 @@ var init_cache = __esm({
3577
4316
  init_context();
3578
4317
  useCache = Context.memo(async () => {
3579
4318
  const project = useProject();
3580
- const cache = path5.join(project.paths.out, "cache");
3581
- await fs6.mkdir(cache, {
4319
+ const cache = path7.join(project.paths.out, "cache");
4320
+ await fs7.mkdir(cache, {
3582
4321
  recursive: true
3583
4322
  });
3584
4323
  async function write(key, data2) {
3585
- const full = path5.join(cache, key);
4324
+ const full = path7.join(cache, key);
3586
4325
  Logger.debug("Writing cache", full, data2.length, "bytes");
3587
- await fs6.writeFile(full, data2);
4326
+ await fs7.writeFile(full, data2);
3588
4327
  }
3589
4328
  async function read(key) {
3590
- const full = path5.join(cache, key);
4329
+ const full = path7.join(cache, key);
3591
4330
  try {
3592
- const data2 = await fs6.readFile(full);
4331
+ const data2 = await fs7.readFile(full);
3593
4332
  return data2.toString();
3594
4333
  } catch {
3595
4334
  return null;
@@ -3682,7 +4421,7 @@ var init_metadata = __esm({
3682
4421
  bus.publish("stacks.metadata", data2);
3683
4422
  return data2;
3684
4423
  } catch {
3685
- await new Promise((resolve) => setTimeout(resolve, 1e3));
4424
+ await new Promise((resolve2) => setTimeout(resolve2, 1e3));
3686
4425
  }
3687
4426
  }
3688
4427
  });
@@ -3696,7 +4435,7 @@ __export(watcher_exports, {
3696
4435
  useWatcher: () => useWatcher
3697
4436
  });
3698
4437
  import chokidar from "chokidar";
3699
- import path6 from "path";
4438
+ import path8 from "path";
3700
4439
  var useWatcher;
3701
4440
  var init_watcher = __esm({
3702
4441
  "src/watcher.ts"() {
@@ -3727,7 +4466,7 @@ var init_watcher = __esm({
3727
4466
  watcher.on("change", (file) => {
3728
4467
  bus.publish("file.changed", {
3729
4468
  file,
3730
- relative: path6.relative(project.paths.root, file)
4469
+ relative: path8.relative(project.paths.root, file)
3731
4470
  });
3732
4471
  });
3733
4472
  return {
@@ -3738,11 +4477,11 @@ var init_watcher = __esm({
3738
4477
  });
3739
4478
 
3740
4479
  // src/runtime/handlers.ts
3741
- import path7 from "path";
3742
- import fs7 from "fs/promises";
4480
+ import path9 from "path";
4481
+ import fs8 from "fs/promises";
3743
4482
  import { useFunctions } from "../src/constructs/Function.js";
3744
4483
  var useRuntimeHandlers, useFunctionBuilder;
3745
- var init_handlers = __esm({
4484
+ var init_handlers2 = __esm({
3746
4485
  "src/runtime/handlers.ts"() {
3747
4486
  "use strict";
3748
4487
  init_context();
@@ -3775,9 +4514,10 @@ var init_handlers = __esm({
3775
4514
  errors: [`Function with ID "${functionID}" not found`]
3776
4515
  };
3777
4516
  const handler = result.for(func.runtime);
3778
- const out = path7.join(project.paths.artifacts, functionID);
3779
- await fs7.rm(out, { recursive: true, force: true });
3780
- await fs7.mkdir(out, { recursive: true });
4517
+ const out = path9.join(project.paths.artifacts, functionID);
4518
+ await fs8.rm(out, { recursive: true, force: true });
4519
+ await fs8.mkdir(out, { recursive: true });
4520
+ bus.publish("function.build.started", { functionID });
3781
4521
  if (func.hooks?.beforeBuild)
3782
4522
  await func.hooks.beforeBuild(func, out);
3783
4523
  const built = await handler.build({
@@ -3796,22 +4536,22 @@ var init_handlers = __esm({
3796
4536
  if (func.copyFiles) {
3797
4537
  await Promise.all(
3798
4538
  func.copyFiles.map(async (entry) => {
3799
- const fromPath = path7.join(project.paths.root, entry.from);
4539
+ const fromPath = path9.join(project.paths.root, entry.from);
3800
4540
  const to = entry.to || entry.from;
3801
- if (path7.isAbsolute(to))
4541
+ if (path9.isAbsolute(to))
3802
4542
  throw new Error(
3803
4543
  `Copy destination path "${to}" must be relative`
3804
4544
  );
3805
- const toPath = path7.join(out, to);
4545
+ const toPath = path9.join(out, to);
3806
4546
  if (mode === "deploy")
3807
- await fs7.cp(fromPath, toPath, {
4547
+ await fs8.cp(fromPath, toPath, {
3808
4548
  recursive: true
3809
4549
  });
3810
4550
  if (mode === "start") {
3811
4551
  try {
3812
- const dir = path7.dirname(toPath);
3813
- await fs7.mkdir(dir, { recursive: true });
3814
- await fs7.symlink(fromPath, toPath);
4552
+ const dir = path9.dirname(toPath);
4553
+ await fs8.mkdir(dir, { recursive: true });
4554
+ await fs8.symlink(fromPath, toPath);
3815
4555
  } catch (ex) {
3816
4556
  Logger.debug("Failed to symlink", fromPath, toPath, ex);
3817
4557
  }
@@ -3921,8 +4661,8 @@ var init_server = __esm({
3921
4661
  const value = queue?.shift();
3922
4662
  if (value)
3923
4663
  return value;
3924
- return new Promise((resolve, reject) => {
3925
- workersWaiting.set(workerID, resolve);
4664
+ return new Promise((resolve2, reject) => {
4665
+ workersWaiting.set(workerID, resolve2);
3926
4666
  });
3927
4667
  }
3928
4668
  workers.subscribe("worker.exited", async (evt) => {
@@ -4091,7 +4831,7 @@ var init_workers = __esm({
4091
4831
  "use strict";
4092
4832
  init_context();
4093
4833
  init_bus();
4094
- init_handlers();
4834
+ init_handlers2();
4095
4835
  init_server();
4096
4836
  useRuntimeWorkers = Context.memo(async () => {
4097
4837
  const workers = /* @__PURE__ */ new Map();
@@ -4133,6 +4873,7 @@ var init_workers = __esm({
4133
4873
  await handler.startWorker({
4134
4874
  ...build2,
4135
4875
  workerID: evt.properties.workerID,
4876
+ functionID: evt.properties.functionID,
4136
4877
  environment: evt.properties.env,
4137
4878
  url: `${server.url}/${evt.properties.workerID}/${server.API_VERSION}`,
4138
4879
  runtime: props.runtime
@@ -4198,7 +4939,7 @@ var FRAMEWORK_MAP, BOOTSTRAP_MAP, useDotnetHandler;
4198
4939
  var init_dotnet = __esm({
4199
4940
  "src/runtime/handlers/dotnet.ts"() {
4200
4941
  "use strict";
4201
- init_handlers();
4942
+ init_handlers2();
4202
4943
  init_workers();
4203
4944
  init_context();
4204
4945
  init_server();
@@ -4326,8 +5067,8 @@ var node_exports = {};
4326
5067
  __export(node_exports, {
4327
5068
  useNodeHandler: () => useNodeHandler
4328
5069
  });
4329
- import path8 from "path";
4330
- import fs8 from "fs/promises";
5070
+ import path10 from "path";
5071
+ import fs9 from "fs/promises";
4331
5072
  import { exec as exec2 } from "child_process";
4332
5073
  import fsSync2 from "fs";
4333
5074
  import esbuild2 from "esbuild";
@@ -4338,7 +5079,7 @@ var init_node = __esm({
4338
5079
  "src/runtime/handlers/node.ts"() {
4339
5080
  "use strict";
4340
5081
  init_project();
4341
- init_handlers();
5082
+ init_handlers2();
4342
5083
  init_workers();
4343
5084
  init_context();
4344
5085
  init_error();
@@ -4354,7 +5095,7 @@ var init_node = __esm({
4354
5095
  const result = cache[input.functionID];
4355
5096
  if (!result)
4356
5097
  return false;
4357
- const relative = path8.relative(project.paths.root, input.file).split(path8.sep).join(path8.posix.sep);
5098
+ const relative = path10.relative(project.paths.root, input.file).split(path10.sep).join(path10.posix.sep);
4358
5099
  return Boolean(result.metafile?.inputs[relative]);
4359
5100
  },
4360
5101
  canHandle: (input) => input.startsWith("nodejs"),
@@ -4392,7 +5133,7 @@ var init_node = __esm({
4392
5133
  },
4393
5134
  build: async (input) => {
4394
5135
  const exists = cache[input.functionID];
4395
- const parsed = path8.parse(input.props.handler);
5136
+ const parsed = path10.parse(input.props.handler);
4396
5137
  const file = [
4397
5138
  ".ts",
4398
5139
  ".tsx",
@@ -4402,7 +5143,7 @@ var init_node = __esm({
4402
5143
  ".jsx",
4403
5144
  ".mjs",
4404
5145
  ".cjs"
4405
- ].map((ext) => path8.join(parsed.dir, parsed.name + ext)).find((file2) => {
5146
+ ].map((ext) => path10.join(parsed.dir, parsed.name + ext)).find((file2) => {
4406
5147
  return fsSync2.existsSync(file2);
4407
5148
  });
4408
5149
  if (!file)
@@ -4412,17 +5153,17 @@ var init_node = __esm({
4412
5153
  };
4413
5154
  const nodejs = input.props.nodejs || {};
4414
5155
  const isESM = (nodejs.format || "esm") === "esm";
4415
- const relative = path8.relative(
5156
+ const relative = path10.relative(
4416
5157
  project.paths.root,
4417
- path8.resolve(parsed.dir)
5158
+ path10.resolve(parsed.dir)
4418
5159
  );
4419
5160
  const extension = isESM ? ".mjs" : ".cjs";
4420
- const target = path8.join(
5161
+ const target = path10.join(
4421
5162
  input.out,
4422
- !relative.startsWith("..") && !path8.isAbsolute(input.props.handler) ? relative : "",
5163
+ !relative.startsWith("..") && !path10.isAbsolute(input.props.handler) ? relative : "",
4423
5164
  parsed.name + extension
4424
5165
  );
4425
- const handler = path8.relative(input.out, target.replace(extension, parsed.ext)).split(path8.sep).join(path8.posix.sep);
5166
+ const handler = path10.relative(input.out, target.replace(extension, parsed.ext)).split(path10.sep).join(path10.posix.sep);
4426
5167
  if (exists?.rebuild) {
4427
5168
  const result = await exists.rebuild();
4428
5169
  cache[input.functionID] = result;
@@ -4481,32 +5222,32 @@ var init_node = __esm({
4481
5222
  ...nodejs.install || [],
4482
5223
  ...forceExternal.filter((pkg) => pkg !== "aws-sdk").filter((pkg) => !external?.includes(pkg)).filter(
4483
5224
  (pkg) => Object.values(result.metafile?.inputs || {}).some(
4484
- ({ imports }) => imports.some(({ path: path20 }) => path20 === pkg)
5225
+ ({ imports }) => imports.some(({ path: path22 }) => path22 === pkg)
4485
5226
  )
4486
5227
  )
4487
5228
  ];
4488
5229
  const warnings = [];
4489
5230
  Object.entries(result.metafile?.inputs || {}).forEach(
4490
- ([inputPath, { imports }]) => imports.filter(({ path: path20 }) => path20.includes("sst/constructs")).forEach(({ path: path20 }) => {
5231
+ ([inputPath, { imports }]) => imports.filter(({ path: path22 }) => path22.includes("sst/constructs")).forEach(({ path: path22 }) => {
4491
5232
  warnings.push(
4492
- `You are importing from "${path20}" in "${inputPath}". Did you mean to import from "sst/node"?`
5233
+ `You are importing from "${path22}" in "${inputPath}". Did you mean to import from "sst/node"?`
4493
5234
  );
4494
5235
  })
4495
5236
  );
4496
5237
  async function find2(dir, target2) {
4497
5238
  if (dir === "/")
4498
5239
  throw new VisibleError("Could not find a package.json file");
4499
- if (await fs8.access(path8.join(dir, target2)).then(() => true).catch(() => false))
5240
+ if (await fs9.access(path10.join(dir, target2)).then(() => true).catch(() => false))
4500
5241
  return dir;
4501
- return find2(path8.join(dir, ".."), target2);
5242
+ return find2(path10.join(dir, ".."), target2);
4502
5243
  }
4503
5244
  if (input.mode === "deploy" && installPackages) {
4504
5245
  const src = await find2(parsed.dir, "package.json");
4505
5246
  const json = JSON.parse(
4506
- await fs8.readFile(path8.join(src, "package.json")).then((x) => x.toString())
5247
+ await fs9.readFile(path10.join(src, "package.json")).then((x) => x.toString())
4507
5248
  );
4508
- await fs8.writeFile(
4509
- path8.join(input.out, "package.json"),
5249
+ await fs9.writeFile(
5250
+ path10.join(input.out, "package.json"),
4510
5251
  JSON.stringify({
4511
5252
  dependencies: Object.fromEntries(
4512
5253
  installPackages.map((x) => [x, json.dependencies?.[x] || "*"])
@@ -4520,24 +5261,24 @@ var init_node = __esm({
4520
5261
  input.props.architecture === "arm_64" ? "--arch=arm64" : "--arch=x64"
4521
5262
  );
4522
5263
  }
4523
- await new Promise((resolve, reject) => {
4524
- exec2(cmd.join(" "), { cwd: input.out }, (error2) => {
4525
- if (error2) {
4526
- reject(error2);
5264
+ await new Promise((resolve2, reject) => {
5265
+ exec2(cmd.join(" "), { cwd: input.out }, (error3) => {
5266
+ if (error3) {
5267
+ reject(error3);
4527
5268
  }
4528
- resolve();
5269
+ resolve2();
4529
5270
  });
4530
5271
  });
4531
5272
  }
4532
5273
  if (input.mode === "start") {
4533
- const dir = path8.join(
5274
+ const dir = path10.join(
4534
5275
  await find2(parsed.dir, "package.json"),
4535
5276
  "node_modules"
4536
5277
  );
4537
5278
  try {
4538
- await fs8.symlink(
4539
- path8.resolve(dir),
4540
- path8.resolve(path8.join(input.out, "node_modules")),
5279
+ await fs9.symlink(
5280
+ path10.resolve(dir),
5281
+ path10.resolve(path10.join(input.out, "node_modules")),
4541
5282
  "dir"
4542
5283
  );
4543
5284
  } catch {
@@ -4576,22 +5317,22 @@ var go_exports = {};
4576
5317
  __export(go_exports, {
4577
5318
  useGoHandler: () => useGoHandler
4578
5319
  });
4579
- import path9 from "path";
4580
- import fs9 from "fs/promises";
4581
- import os3 from "os";
5320
+ import path11 from "path";
5321
+ import fs10 from "fs/promises";
5322
+ import os4 from "os";
4582
5323
  import { spawn as spawn2 } from "child_process";
4583
5324
  async function find(dir, target) {
4584
5325
  if (dir === "/")
4585
5326
  throw new VisibleError(`Could not find a ${target} file`);
4586
- if (await fs9.access(path9.join(dir, target)).then(() => true).catch(() => false))
5327
+ if (await fs10.access(path11.join(dir, target)).then(() => true).catch(() => false))
4587
5328
  return dir;
4588
- return find(path9.join(dir, ".."), target);
5329
+ return find(path11.join(dir, ".."), target);
4589
5330
  }
4590
5331
  var useGoHandler;
4591
5332
  var init_go = __esm({
4592
5333
  "src/runtime/handlers/go.ts"() {
4593
5334
  "use strict";
4594
- init_handlers();
5335
+ init_handlers2();
4595
5336
  init_workers();
4596
5337
  init_context();
4597
5338
  init_error();
@@ -4614,7 +5355,7 @@ var init_go = __esm({
4614
5355
  },
4615
5356
  canHandle: (input) => input.startsWith("go"),
4616
5357
  startWorker: async (input) => {
4617
- const proc = spawn2(path9.join(input.out, handlerName), {
5358
+ const proc = spawn2(path11.join(input.out, handlerName), {
4618
5359
  env: {
4619
5360
  ...process.env,
4620
5361
  ...input.environment,
@@ -4640,14 +5381,14 @@ var init_go = __esm({
4640
5381
  }
4641
5382
  },
4642
5383
  build: async (input) => {
4643
- const parsed = path9.parse(input.props.handler);
5384
+ const parsed = path11.parse(input.props.handler);
4644
5385
  const project = await find(parsed.dir, "go.mod");
4645
5386
  sources.set(input.functionID, project);
4646
- const src = path9.relative(project, input.props.handler);
5387
+ const src = path11.relative(project, input.props.handler);
4647
5388
  if (input.mode === "start") {
4648
5389
  try {
4649
- const target = path9.join(input.out, handlerName);
4650
- const srcPath = os3.platform() === "win32" ? src.replaceAll("\\", "\\\\") : src;
5390
+ const target = path11.join(input.out, handlerName);
5391
+ const srcPath = os4.platform() === "win32" ? src.replaceAll("\\", "\\\\") : src;
4651
5392
  const result = await execAsync(
4652
5393
  `go build -ldflags "-s -w" -o "${target}" ./${srcPath}`,
4653
5394
  {
@@ -4666,8 +5407,8 @@ var init_go = __esm({
4666
5407
  }
4667
5408
  if (input.mode === "deploy") {
4668
5409
  try {
4669
- const target = path9.join(input.out, "bootstrap");
4670
- const srcPath = os3.platform() === "win32" ? src.replaceAll("\\", "\\\\") : src;
5410
+ const target = path11.join(input.out, "bootstrap");
5411
+ const srcPath = os4.platform() === "win32" ? src.replaceAll("\\", "\\\\") : src;
4671
5412
  await execAsync(
4672
5413
  `go build -ldflags "-s -w" -o "${target}" ./${srcPath}`,
4673
5414
  {
@@ -4697,20 +5438,156 @@ var init_go = __esm({
4697
5438
  }
4698
5439
  });
4699
5440
 
5441
+ // src/runtime/handlers/container.ts
5442
+ var container_exports = {};
5443
+ __export(container_exports, {
5444
+ useContainerHandler: () => useContainerHandler
5445
+ });
5446
+ import { spawn as spawn3 } from "child_process";
5447
+ var useContainerHandler;
5448
+ var init_container = __esm({
5449
+ "src/runtime/handlers/container.ts"() {
5450
+ "use strict";
5451
+ init_handlers2();
5452
+ init_workers();
5453
+ init_context();
5454
+ init_error();
5455
+ init_server();
5456
+ init_fs();
5457
+ init_process();
5458
+ useContainerHandler = Context.memo(async () => {
5459
+ const workers = await useRuntimeWorkers();
5460
+ const server = await useRuntimeServerConfig();
5461
+ const handlers = useRuntimeHandlers();
5462
+ const containers = /* @__PURE__ */ new Map();
5463
+ const sources = /* @__PURE__ */ new Map();
5464
+ handlers.register({
5465
+ shouldBuild: (input) => {
5466
+ const parent = sources.get(input.functionID);
5467
+ if (!parent)
5468
+ return false;
5469
+ return isChild(parent, input.file);
5470
+ },
5471
+ canHandle: (input) => input.startsWith("container"),
5472
+ startWorker: async (input) => {
5473
+ const name = `sst-workerID-${input.workerID}-${Date.now()}`;
5474
+ const proc = spawn3(
5475
+ "docker",
5476
+ [
5477
+ "run",
5478
+ "--rm",
5479
+ "--network=host",
5480
+ `--name=${name}`,
5481
+ ...Object.entries({
5482
+ ...input.environment,
5483
+ IS_LOCAL: "true",
5484
+ AWS_LAMBDA_RUNTIME_API: `host.docker.internal:${server.port}/${input.workerID}`
5485
+ }).map(([key, value]) => ["-e", `${key}=${value}`]).flat(),
5486
+ `sst-dev:${input.functionID}`
5487
+ ],
5488
+ {
5489
+ env: {
5490
+ ...process.env
5491
+ },
5492
+ cwd: input.out
5493
+ }
5494
+ );
5495
+ proc.on("exit", () => {
5496
+ workers.exited(input.workerID);
5497
+ });
5498
+ proc.stdout.on("data", (data2) => {
5499
+ workers.stdout(input.workerID, data2.toString());
5500
+ });
5501
+ proc.stderr.on("data", (data2) => {
5502
+ workers.stdout(input.workerID, data2.toString());
5503
+ });
5504
+ containers.set(input.workerID, name);
5505
+ },
5506
+ stopWorker: async (workerID) => {
5507
+ const name = containers.get(workerID);
5508
+ if (name) {
5509
+ try {
5510
+ await execAsync(`docker kill ${name}`, {
5511
+ env: {
5512
+ ...process.env
5513
+ }
5514
+ });
5515
+ } catch (ex) {
5516
+ console.error(ex);
5517
+ throw new VisibleError(`Could not stop docker container ${name}`);
5518
+ }
5519
+ containers.delete(workerID);
5520
+ }
5521
+ },
5522
+ build: async (input) => {
5523
+ const project = input.props.handler;
5524
+ sources.set(input.functionID, project);
5525
+ if (input.mode === "start") {
5526
+ try {
5527
+ const result = await execAsync(
5528
+ `docker build -t sst-dev:${input.functionID} .`,
5529
+ {
5530
+ cwd: project,
5531
+ env: {
5532
+ ...process.env
5533
+ }
5534
+ }
5535
+ );
5536
+ } catch (ex) {
5537
+ return {
5538
+ type: "error",
5539
+ errors: [String(ex)]
5540
+ };
5541
+ }
5542
+ }
5543
+ if (input.mode === "deploy") {
5544
+ try {
5545
+ const platform = input.props.architecture === "arm_64" ? "linux/arm64" : "linux/amd64";
5546
+ await execAsync(
5547
+ [
5548
+ `docker build`,
5549
+ `-t sst-build:${input.functionID}`,
5550
+ `--platform ${platform}`,
5551
+ `.`
5552
+ ].join(" "),
5553
+ {
5554
+ cwd: project,
5555
+ env: {
5556
+ ...process.env
5557
+ }
5558
+ }
5559
+ );
5560
+ } catch (ex) {
5561
+ return {
5562
+ type: "error",
5563
+ errors: [String(ex)]
5564
+ };
5565
+ }
5566
+ }
5567
+ return {
5568
+ type: "success",
5569
+ handler: "not required for container"
5570
+ };
5571
+ }
5572
+ });
5573
+ });
5574
+ }
5575
+ });
5576
+
4700
5577
  // src/runtime/handlers/rust.ts
4701
5578
  var rust_exports = {};
4702
5579
  __export(rust_exports, {
4703
5580
  useRustHandler: () => useRustHandler
4704
5581
  });
4705
- import path10 from "path";
4706
- import fs10 from "fs/promises";
4707
- import { exec as exec4, spawn as spawn3 } from "child_process";
5582
+ import path12 from "path";
5583
+ import fs11 from "fs/promises";
5584
+ import { exec as exec4, spawn as spawn4 } from "child_process";
4708
5585
  import { promisify as promisify2 } from "util";
4709
5586
  var execAsync2, useRustHandler;
4710
5587
  var init_rust = __esm({
4711
5588
  "src/runtime/handlers/rust.ts"() {
4712
5589
  "use strict";
4713
- init_handlers();
5590
+ init_handlers2();
4714
5591
  init_workers();
4715
5592
  init_context();
4716
5593
  init_error();
@@ -4736,7 +5613,7 @@ var init_rust = __esm({
4736
5613
  },
4737
5614
  canHandle: (input) => input.startsWith("rust"),
4738
5615
  startWorker: async (input) => {
4739
- const proc = spawn3(path10.join(input.out, handlerName), {
5616
+ const proc = spawn4(path12.join(input.out, handlerName), {
4740
5617
  env: {
4741
5618
  ...process.env,
4742
5619
  ...input.environment,
@@ -4764,7 +5641,7 @@ var init_rust = __esm({
4764
5641
  }
4765
5642
  },
4766
5643
  build: async (input) => {
4767
- const parsed = path10.parse(input.props.handler);
5644
+ const parsed = path12.parse(input.props.handler);
4768
5645
  const project = await findAbove(parsed.dir, "Cargo.toml");
4769
5646
  if (!project)
4770
5647
  return {
@@ -4780,9 +5657,9 @@ var init_rust = __esm({
4780
5657
  ...process.env
4781
5658
  }
4782
5659
  });
4783
- await fs10.cp(
4784
- path10.join(project, `target/debug`, parsed.name),
4785
- path10.join(input.out, "handler")
5660
+ await fs11.cp(
5661
+ path12.join(project, `target/debug`, parsed.name),
5662
+ path12.join(input.out, "handler")
4786
5663
  );
4787
5664
  } catch (ex) {
4788
5665
  throw new VisibleError("Failed to build");
@@ -4796,9 +5673,9 @@ var init_rust = __esm({
4796
5673
  ...process.env
4797
5674
  }
4798
5675
  });
4799
- await fs10.cp(
4800
- path10.join(project, `target/lambda/`, parsed.name, "bootstrap"),
4801
- path10.join(input.out, "bootstrap")
5676
+ await fs11.cp(
5677
+ path12.join(project, `target/lambda/`, parsed.name, "bootstrap"),
5678
+ path12.join(input.out, "bootstrap")
4802
5679
  );
4803
5680
  } catch (ex) {
4804
5681
  throw new VisibleError("Failed to build");
@@ -4815,9 +5692,9 @@ var init_rust = __esm({
4815
5692
  });
4816
5693
 
4817
5694
  // src/runtime/handlers/pythonBundling.ts
4818
- import fs11 from "fs";
5695
+ import fs12 from "fs";
4819
5696
  import url5 from "url";
4820
- import path11 from "path";
5697
+ import path13 from "path";
4821
5698
  import { DockerImage, FileSystem } from "aws-cdk-lib/core";
4822
5699
  function bundle(options) {
4823
5700
  const { entry, runtime, architecture, outputPathSuffix, installCommands } = options;
@@ -4828,9 +5705,9 @@ function bundle(options) {
4828
5705
  stagedir
4829
5706
  );
4830
5707
  const dockerfile = hasInstallCommands ? "Dockerfile.custom" : hasDeps ? "Dockerfile.dependencies" : "Dockerfile";
4831
- fs11.copyFileSync(
4832
- path11.join(__dirname, "../../support/python-runtime", dockerfile),
4833
- path11.join(stagedir, dockerfile)
5708
+ fs12.copyFileSync(
5709
+ path13.join(__dirname, "../../support/python-runtime", dockerfile),
5710
+ path13.join(stagedir, dockerfile)
4834
5711
  );
4835
5712
  const image = DockerImage.fromBuild(stagedir, {
4836
5713
  buildArgs: {
@@ -4838,21 +5715,21 @@ function bundle(options) {
4838
5715
  },
4839
5716
  file: dockerfile
4840
5717
  });
4841
- const outputPath = path11.join(options.out, outputPathSuffix);
5718
+ const outputPath = path13.join(options.out, outputPathSuffix);
4842
5719
  if (hasDeps || hasInstallCommands) {
4843
5720
  image.cp(`${BUNDLER_DEPENDENCIES_CACHE}/.`, outputPath);
4844
5721
  }
4845
- fs11.cpSync(entry, outputPath, {
5722
+ fs12.cpSync(entry, outputPath, {
4846
5723
  recursive: true
4847
5724
  });
4848
5725
  }
4849
5726
  function stageDependencies(entry, stagedir) {
4850
5727
  const prefixes = ["Pipfile", "pyproject", "poetry", "requirements.txt"];
4851
5728
  let found = false;
4852
- for (const file of fs11.readdirSync(entry)) {
5729
+ for (const file of fs12.readdirSync(entry)) {
4853
5730
  for (const prefix of prefixes) {
4854
5731
  if (file.startsWith(prefix)) {
4855
- fs11.copyFileSync(path11.join(entry, file), path11.join(stagedir, file));
5732
+ fs12.copyFileSync(path13.join(entry, file), path13.join(stagedir, file));
4856
5733
  found = true;
4857
5734
  }
4858
5735
  }
@@ -4862,9 +5739,9 @@ function stageDependencies(entry, stagedir) {
4862
5739
  function stageInstallCommands(installCommands, stagedir) {
4863
5740
  let found = false;
4864
5741
  if (installCommands.length > 0) {
4865
- const filePath = path11.join(stagedir, "sst-deps-install-command.sh");
4866
- fs11.writeFileSync(filePath, installCommands.join(" && "));
4867
- fs11.chmodSync(filePath, "755");
5742
+ const filePath = path13.join(stagedir, "sst-deps-install-command.sh");
5743
+ fs12.writeFileSync(filePath, installCommands.join(" && "));
5744
+ fs12.chmodSync(filePath, "755");
4868
5745
  found = true;
4869
5746
  }
4870
5747
  return found;
@@ -4873,7 +5750,7 @@ var __dirname, BUNDLER_DEPENDENCIES_CACHE;
4873
5750
  var init_pythonBundling = __esm({
4874
5751
  "src/runtime/handlers/pythonBundling.ts"() {
4875
5752
  "use strict";
4876
- __dirname = path11.dirname(url5.fileURLToPath(import.meta.url));
5753
+ __dirname = path13.dirname(url5.fileURLToPath(import.meta.url));
4877
5754
  BUNDLER_DEPENDENCIES_CACHE = "/var/dependencies";
4878
5755
  }
4879
5756
  });
@@ -4883,17 +5760,17 @@ var python_exports = {};
4883
5760
  __export(python_exports, {
4884
5761
  usePythonHandler: () => usePythonHandler
4885
5762
  });
4886
- import path12 from "path";
4887
- import { exec as exec5, spawn as spawn4 } from "child_process";
5763
+ import path14 from "path";
5764
+ import { exec as exec5, spawn as spawn5 } from "child_process";
4888
5765
  import { promisify as promisify3 } from "util";
4889
5766
  import { Runtime } from "aws-cdk-lib/aws-lambda";
4890
- import os4 from "os";
5767
+ import os5 from "os";
4891
5768
  import url6 from "url";
4892
5769
  var execAsync3, RUNTIME_MAP, usePythonHandler;
4893
5770
  var init_python = __esm({
4894
5771
  "src/runtime/handlers/python.ts"() {
4895
5772
  "use strict";
4896
- init_handlers();
5773
+ init_handlers2();
4897
5774
  init_workers();
4898
5775
  init_context();
4899
5776
  init_server();
@@ -4934,10 +5811,10 @@ var init_python = __esm({
4934
5811
  const src = await findSrc(input.handler);
4935
5812
  if (!src)
4936
5813
  throw new Error(`Could not find src for ${input.handler}`);
4937
- const parsed = path12.parse(path12.relative(src, input.handler));
4938
- const target = [...parsed.dir.split(path12.sep), parsed.name].join(".");
4939
- const proc = spawn4(
4940
- os4.platform() === "win32" ? "python.exe" : "python3",
5814
+ const parsed = path14.parse(path14.relative(src, input.handler));
5815
+ const target = [...parsed.dir.split(path14.sep), parsed.name].join(".");
5816
+ const proc = spawn5(
5817
+ os5.platform() === "win32" ? "python.exe" : "python3",
4941
5818
  [
4942
5819
  "-u",
4943
5820
  url6.fileURLToPath(
@@ -4997,7 +5874,7 @@ var init_python = __esm({
4997
5874
  });
4998
5875
  return {
4999
5876
  type: "success",
5000
- handler: path12.relative(src, path12.resolve(input.props.handler)).split(path12.sep).join(path12.posix.sep)
5877
+ handler: path14.relative(src, path14.resolve(input.props.handler)).split(path14.sep).join(path14.posix.sep)
5001
5878
  };
5002
5879
  }
5003
5880
  });
@@ -5010,21 +5887,21 @@ var java_exports = {};
5010
5887
  __export(java_exports, {
5011
5888
  useJavaHandler: () => useJavaHandler
5012
5889
  });
5013
- import path13 from "path";
5014
- import fs12 from "fs/promises";
5015
- import os5 from "os";
5016
- import { spawn as spawn5 } from "child_process";
5890
+ import path15 from "path";
5891
+ import fs13 from "fs/promises";
5892
+ import os6 from "os";
5893
+ import { spawn as spawn6 } from "child_process";
5017
5894
  import url7 from "url";
5018
5895
  import AdmZip from "adm-zip";
5019
5896
  async function getGradleBinary(srcPath) {
5020
- const gradleWrapperPath = path13.resolve(path13.join(srcPath, "gradlew"));
5897
+ const gradleWrapperPath = path15.resolve(path15.join(srcPath, "gradlew"));
5021
5898
  return await existsAsync(gradleWrapperPath) ? gradleWrapperPath : "gradle";
5022
5899
  }
5023
5900
  var useJavaHandler;
5024
5901
  var init_java = __esm({
5025
5902
  "src/runtime/handlers/java.ts"() {
5026
5903
  "use strict";
5027
- init_handlers();
5904
+ init_handlers2();
5028
5905
  init_workers();
5029
5906
  init_context();
5030
5907
  init_server();
@@ -5049,7 +5926,7 @@ var init_java = __esm({
5049
5926
  },
5050
5927
  canHandle: (input) => input.startsWith("java"),
5051
5928
  startWorker: async (input) => {
5052
- const proc = spawn5(
5929
+ const proc = spawn6(
5053
5930
  `java`,
5054
5931
  [
5055
5932
  `-cp`,
@@ -5057,7 +5934,7 @@ var init_java = __esm({
5057
5934
  url7.fileURLToPath(
5058
5935
  new URL("../../support/java-runtime/release/*", import.meta.url)
5059
5936
  )
5060
- ].join(os5.platform() === "win32" ? ";" : ":"),
5937
+ ].join(os6.platform() === "win32" ? ";" : ":"),
5061
5938
  "com.amazonaws.services.lambda.runtime.api.client.AWSLambda",
5062
5939
  input.handler
5063
5940
  ],
@@ -5101,11 +5978,11 @@ var init_java = __esm({
5101
5978
  cwd: srcPath
5102
5979
  }
5103
5980
  );
5104
- const buildOutput = path13.join(srcPath, "build", outputDir);
5105
- const zip = (await fs12.readdir(buildOutput)).find(
5981
+ const buildOutput = path15.join(srcPath, "build", outputDir);
5982
+ const zip = (await fs13.readdir(buildOutput)).find(
5106
5983
  (f) => f.endsWith(".zip")
5107
5984
  );
5108
- new AdmZip(path13.join(buildOutput, zip)).extractAllTo(input.out);
5985
+ new AdmZip(path15.join(buildOutput, zip)).extractAllTo(input.out);
5109
5986
  return {
5110
5987
  type: "success",
5111
5988
  handler: input.props.handler
@@ -5124,31 +6001,36 @@ var init_java = __esm({
5124
6001
 
5125
6002
  // src/stacks/synth.ts
5126
6003
  import * as contextproviders from "sst-aws-cdk/lib/context-providers/index.js";
5127
- import path14 from "path";
6004
+ import path16 from "path";
5128
6005
  async function synth(opts) {
5129
6006
  Logger.debug("Synthesizing stacks...");
5130
6007
  const { App: App2 } = await import("../src/constructs/App.js");
5131
6008
  const { useNodeHandler: useNodeHandler2 } = await Promise.resolve().then(() => (init_node(), node_exports));
5132
6009
  const { useGoHandler: useGoHandler2 } = await Promise.resolve().then(() => (init_go(), go_exports));
6010
+ const { useContainerHandler: useContainerHandler2 } = await Promise.resolve().then(() => (init_container(), container_exports));
5133
6011
  const { useRustHandler: useRustHandler2 } = await Promise.resolve().then(() => (init_rust(), rust_exports));
5134
6012
  const { usePythonHandler: usePythonHandler2 } = await Promise.resolve().then(() => (init_python(), python_exports));
5135
6013
  const { useJavaHandler: useJavaHandler2 } = await Promise.resolve().then(() => (init_java(), java_exports));
5136
6014
  useNodeHandler2();
5137
6015
  useGoHandler2();
6016
+ useContainerHandler2();
5138
6017
  usePythonHandler2();
5139
6018
  useJavaHandler2();
5140
6019
  useDotnetHandler();
5141
6020
  useRustHandler2();
6021
+ const cxapi5 = await import("@aws-cdk/cx-api");
5142
6022
  const { Configuration } = await import("sst-aws-cdk/lib/settings.js");
5143
6023
  const project = useProject();
5144
6024
  const identity = await useSTSIdentity();
5145
6025
  opts = {
5146
6026
  ...opts,
5147
- buildDir: opts.buildDir || path14.join(project.paths.out, "dist")
6027
+ buildDir: opts.buildDir || path16.join(project.paths.out, "dist")
5148
6028
  };
5149
6029
  const cfg = new Configuration();
5150
6030
  await cfg.load();
5151
6031
  let previous2 = /* @__PURE__ */ new Set();
6032
+ const context = cfg.context.all;
6033
+ context[cxapi5.PATH_METADATA_ENABLE_CONTEXT] = project.config.cdk?.pathMetadata ?? false;
5152
6034
  while (true) {
5153
6035
  const app = new App2(
5154
6036
  {
@@ -5163,7 +6045,7 @@ async function synth(opts) {
5163
6045
  },
5164
6046
  {
5165
6047
  outdir: opts.buildDir,
5166
- context: cfg.context.all
6048
+ context
5167
6049
  }
5168
6050
  );
5169
6051
  await opts.fn(app);
@@ -5229,7 +6111,7 @@ async function removeMany(stacks) {
5229
6111
  const complete = /* @__PURE__ */ new Set();
5230
6112
  const todo = new Set(stacks.map((s) => s.id));
5231
6113
  const results = {};
5232
- return new Promise((resolve) => {
6114
+ return new Promise((resolve2) => {
5233
6115
  async function trigger() {
5234
6116
  for (const stack of stacks) {
5235
6117
  if (!todo.has(stack.id))
@@ -5268,7 +6150,7 @@ async function removeMany(stacks) {
5268
6150
  }
5269
6151
  });
5270
6152
  if (complete.size === stacks.length) {
5271
- resolve(results);
6153
+ resolve2(results);
5272
6154
  }
5273
6155
  trigger();
5274
6156
  });
@@ -5357,9 +6239,9 @@ __export(bootstrap_exports, {
5357
6239
  useBootstrap: () => useBootstrap
5358
6240
  });
5359
6241
  import url8 from "url";
5360
- import path15 from "path";
6242
+ import path17 from "path";
5361
6243
  import { bold, dim } from "colorette";
5362
- import { spawn as spawn6 } from "child_process";
6244
+ import { spawn as spawn7 } from "child_process";
5363
6245
  import {
5364
6246
  DescribeStacksCommand as DescribeStacksCommand2,
5365
6247
  CloudFormationClient as CloudFormationClient3
@@ -5486,7 +6368,7 @@ async function bootstrapSST() {
5486
6368
  });
5487
6369
  const fn = new Function(stack, "MetadataHandler", {
5488
6370
  code: Code.fromAsset(
5489
- path15.resolve(__dirname2, "support/bootstrap-metadata-function")
6371
+ path17.resolve(__dirname2, "support/bootstrap-metadata-function")
5490
6372
  ),
5491
6373
  handler: "index.handler",
5492
6374
  runtime: region?.startsWith("us-gov-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
@@ -5547,8 +6429,8 @@ async function bootstrapCDK() {
5547
6429
  const identity = await useSTSIdentity();
5548
6430
  const credentials = await useAWSCredentials();
5549
6431
  const { region, profile, cdk } = useProject().config;
5550
- await new Promise((resolve, reject) => {
5551
- const proc = spawn6(
6432
+ await new Promise((resolve2, reject) => {
6433
+ const proc = spawn7(
5552
6434
  [
5553
6435
  "npx",
5554
6436
  "cdk",
@@ -5585,7 +6467,7 @@ async function bootstrapCDK() {
5585
6467
  proc.on("exit", (code) => {
5586
6468
  Logger.debug("CDK bootstrap exited with code " + code);
5587
6469
  if (code === 0) {
5588
- resolve();
6470
+ resolve2();
5589
6471
  } else {
5590
6472
  console.log(bold(dim(stderr)));
5591
6473
  reject(new VisibleError(`Failed to bootstrap`));
@@ -5694,7 +6576,7 @@ __export(server_exports2, {
5694
6576
  });
5695
6577
  import { produceWithPatches, enablePatches } from "immer";
5696
6578
  import express2 from "express";
5697
- import fs13 from "fs/promises";
6579
+ import fs14 from "fs/promises";
5698
6580
  import { WebSocketServer } from "ws";
5699
6581
  import https3 from "https";
5700
6582
  import http from "http";
@@ -5775,15 +6657,15 @@ async function useLocalServer(opts) {
5775
6657
  const CERT_PATH = ".sst/localhost.pem";
5776
6658
  if (result2.status === 0) {
5777
6659
  try {
5778
- await Promise.all([fs13.access(KEY_PATH), fs13.access(CERT_PATH)]);
6660
+ await Promise.all([fs14.access(KEY_PATH), fs14.access(CERT_PATH)]);
5779
6661
  } catch (e) {
5780
6662
  sync("mkcert", ["localhost"], {
5781
6663
  cwd: ".sst"
5782
6664
  });
5783
6665
  }
5784
6666
  const [key, cert] = await Promise.all([
5785
- fs13.readFile(KEY_PATH),
5786
- fs13.readFile(CERT_PATH)
6667
+ fs14.readFile(KEY_PATH),
6668
+ fs14.readFile(CERT_PATH)
5787
6669
  ]);
5788
6670
  return https3.createServer(
5789
6671
  {
@@ -6206,10 +7088,10 @@ function printDeploymentResults(assembly, results, remove4) {
6206
7088
  Colors.line(
6207
7089
  ` ${Colors.dim(stackNameToId(stack))} ${Colors.dim(result.status)}`
6208
7090
  );
6209
- for (const [id, error2] of Object.entries(result.errors)) {
7091
+ for (const [id, error3] of Object.entries(result.errors)) {
6210
7092
  const readable = logicalIdToCdkPath(assembly, stack, id) || id;
6211
- Colors.line(` ${Colors.danger.bold(readable + ":")} ${error2}`);
6212
- const helper = getHelper(error2);
7093
+ Colors.line(` ${Colors.danger.bold(readable + ":")} ${error3}`);
7094
+ const helper = getHelper(error3);
6213
7095
  if (helper) {
6214
7096
  Colors.line(` ${Colors.warning.bold("\u2B91 Hint:")} ${helper}`);
6215
7097
  }
@@ -6234,30 +7116,30 @@ function logicalIdToCdkPath(assembly, stack, logicalId) {
6234
7116
  }
6235
7117
  return found.split("/").filter(Boolean).slice(1, -1).join("/");
6236
7118
  }
6237
- function getHelper(error2) {
6238
- return getCloudFrontBehaviorLimitHelper(error2) || getApiAccessLogPermissionsHelper(error2) || getAppSyncMultiResolverHelper(error2) || getApiLogRoleHelper(error2);
7119
+ function getHelper(error3) {
7120
+ return getCloudFrontBehaviorLimitHelper(error3) || getApiAccessLogPermissionsHelper(error3) || getAppSyncMultiResolverHelper(error3) || getApiLogRoleHelper(error3);
6239
7121
  }
6240
- function getCloudFrontBehaviorLimitHelper(error2) {
6241
- if (error2.indexOf(
7122
+ function getCloudFrontBehaviorLimitHelper(error3) {
7123
+ if (error3.indexOf(
6242
7124
  "Your request contains more CacheBehaviors than are allowed per distribution."
6243
7125
  ) > -1) {
6244
7126
  return `This error often occurs when deploying a frontend with a large number of top-level files and folders in the assets directory. Check out this doc on how to resolve the issue - https://docs.sst.dev/known-issues#cloudfront-cachebehaviors-limit-exceeded`;
6245
7127
  }
6246
7128
  }
6247
- function getApiAccessLogPermissionsHelper(error2) {
6248
- if (error2.indexOf("Insufficient permissions to enable logging") > -1) {
7129
+ function getApiAccessLogPermissionsHelper(error3) {
7130
+ if (error3.indexOf("Insufficient permissions to enable logging") > -1) {
6249
7131
  return `This is a common deploy error. Check out this GitHub issue for more details - https://github.com/serverless-stack/sst/issues/125`;
6250
7132
  }
6251
7133
  }
6252
- function getAppSyncMultiResolverHelper(error2) {
6253
- if (error2.indexOf(
7134
+ function getAppSyncMultiResolverHelper(error3) {
7135
+ if (error3.indexOf(
6254
7136
  "Only one resolver is allowed per field. (Service: AWSAppSync"
6255
7137
  ) > -1) {
6256
7138
  return `This is a common error for deploying AppSync APIs. Check out this GitHub issue for more details - https://github.com/aws/aws-cdk/issues/13269`;
6257
7139
  }
6258
7140
  }
6259
- function getApiLogRoleHelper(error2) {
6260
- if (error2.indexOf(
7141
+ function getApiLogRoleHelper(error3) {
7142
+ if (error3.indexOf(
6261
7143
  "CloudWatch Logs role ARN must be set in account settings to enable logging (Service: AmazonApiGatewayV2"
6262
7144
  ) > -1) {
6263
7145
  return `This is a common error when configuring Access Log for WebSocket APIs. The AWS API Gateway service in your AWS account does not have permissions to the CloudWatch logs service. Follow this article to create an IAM role for logging to CloudWatch - https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudwatch-logs/`;
@@ -6337,16 +7219,16 @@ __export(pothos_exports, {
6337
7219
  import babel2 from "@babel/core";
6338
7220
  import generator from "@babel/generator";
6339
7221
  import esbuild3 from "esbuild";
6340
- import fs14 from "fs/promises";
6341
- import path16 from "path";
7222
+ import fs15 from "fs/promises";
7223
+ import path18 from "path";
6342
7224
  import url9 from "url";
6343
7225
  async function generate2(opts) {
6344
7226
  const { printSchema, lexicographicSortSchema } = await import("graphql");
6345
7227
  const contents = await extractSchema(opts);
6346
- const out = path16.join(path16.dirname(opts.schema), "out.mjs");
6347
- await fs14.writeFile(out, contents, "utf8");
7228
+ const out = path18.join(path18.dirname(opts.schema), "out.mjs");
7229
+ await fs15.writeFile(out, contents, "utf8");
6348
7230
  const { schema } = await import(url9.pathToFileURL(out).href + "?bust=" + Date.now());
6349
- await fs14.rm(out);
7231
+ await fs15.rm(out);
6350
7232
  const schemaAsString = printSchema(lexicographicSortSchema(schema));
6351
7233
  return schemaAsString;
6352
7234
  }
@@ -6384,15 +7266,15 @@ async function extractSchema(opts) {
6384
7266
  {
6385
7267
  name: "pothos-extractor",
6386
7268
  visitor: {
6387
- Program(path20) {
6388
- const dummyResolverId = path20.scope.generateUidIdentifier("DUMMY_RESOLVER");
7269
+ Program(path22) {
7270
+ const dummyResolverId = path22.scope.generateUidIdentifier("DUMMY_RESOLVER");
6389
7271
  const resolverNode = dummyResolver({
6390
7272
  dummy_resolver: dummyResolverId
6391
7273
  });
6392
- path20.unshiftContainer("body", resolverNode);
6393
- path20.scope.crawl();
7274
+ path22.unshiftContainer("body", resolverNode);
7275
+ path22.scope.crawl();
6394
7276
  let schemaBuilder = null;
6395
- path20.traverse({
7277
+ path22.traverse({
6396
7278
  ImportDeclaration(declarator) {
6397
7279
  if (!declarator)
6398
7280
  return;
@@ -6450,17 +7332,17 @@ async function extractSchema(opts) {
6450
7332
  );
6451
7333
  return contents.code;
6452
7334
  }
6453
- function getBindings(path20, globalPaths) {
7335
+ function getBindings(path22, globalPaths) {
6454
7336
  const bindings = [];
6455
- path20.traverse({
7337
+ path22.traverse({
6456
7338
  Expression(expressionPath) {
6457
7339
  if (!expressionPath.isIdentifier())
6458
7340
  return;
6459
- const binding = path20.scope.getBinding(expressionPath);
7341
+ const binding = path22.scope.getBinding(expressionPath);
6460
7342
  if (!binding || globalPaths.has(binding.path) || bindings.includes(binding.path))
6461
7343
  return;
6462
7344
  const rootBinding = findRootBinding(binding.path);
6463
- if (path20 === rootBinding) {
7345
+ if (path22 === rootBinding) {
6464
7346
  bindings.push(binding.path);
6465
7347
  return;
6466
7348
  }
@@ -6473,8 +7355,8 @@ function getBindings(path20, globalPaths) {
6473
7355
  }
6474
7356
  return bindings;
6475
7357
  }
6476
- function findRootBinding(path20) {
6477
- let rootPath = path20;
7358
+ function findRootBinding(path22) {
7359
+ let rootPath = path22;
6478
7360
  while (rootPath.parentPath?.node !== void 0 && !rootPath.parentPath?.isProgram()) {
6479
7361
  rootPath = rootPath.parentPath;
6480
7362
  }
@@ -6497,10 +7379,10 @@ var pothos_exports2 = {};
6497
7379
  __export(pothos_exports2, {
6498
7380
  usePothosBuilder: () => usePothosBuilder
6499
7381
  });
6500
- import fs15 from "fs/promises";
7382
+ import fs16 from "fs/promises";
6501
7383
  import { exec as exec6 } from "child_process";
6502
7384
  import { promisify as promisify4 } from "util";
6503
- import path17 from "path";
7385
+ import path19 from "path";
6504
7386
  var execAsync4, usePothosBuilder;
6505
7387
  var init_pothos2 = __esm({
6506
7388
  "src/cli/commands/plugins/pothos.ts"() {
@@ -6519,7 +7401,7 @@ var init_pothos2 = __esm({
6519
7401
  schema: route.schema,
6520
7402
  internalPackages: route.internalPackages
6521
7403
  });
6522
- await fs15.writeFile(route.output, schema);
7404
+ await fs16.writeFile(route.output, schema);
6523
7405
  if (Array.isArray(route.commands) && route.commands.length > 0) {
6524
7406
  await Promise.all(route.commands.map((cmd) => execAsync4(cmd)));
6525
7407
  }
@@ -6535,9 +7417,9 @@ var init_pothos2 = __esm({
6535
7417
  if (evt.properties.file.endsWith("out.mjs"))
6536
7418
  return;
6537
7419
  for (const route of routes) {
6538
- const dir = path17.dirname(route.schema);
6539
- const relative = path17.relative(dir, evt.properties.file);
6540
- if (relative && !relative.startsWith("..") && !path17.isAbsolute(relative))
7420
+ const dir = path19.dirname(route.schema);
7421
+ const relative = path19.relative(dir, evt.properties.file);
7422
+ if (relative && !relative.startsWith("..") && !path19.isAbsolute(relative))
6541
7423
  build2(route);
6542
7424
  }
6543
7425
  });
@@ -6563,7 +7445,7 @@ __export(kysely_exports, {
6563
7445
  import { Kysely } from "kysely";
6564
7446
  import { DataApiDialect } from "kysely-data-api";
6565
7447
  import { RDSData } from "@aws-sdk/client-rds-data";
6566
- import * as fs16 from "fs/promises";
7448
+ import * as fs17 from "fs/promises";
6567
7449
  import {
6568
7450
  PostgresDialect,
6569
7451
  MysqlDialect,
@@ -6621,7 +7503,7 @@ var init_kysely = __esm({
6621
7503
  };
6622
7504
  const serializer = new Serializer();
6623
7505
  const data2 = serializer.serialize(nodes);
6624
- await fs16.writeFile(db.types.path, data2);
7506
+ await fs17.writeFile(db.types.path, data2);
6625
7507
  }
6626
7508
  bus.subscribe("stacks.metadata", (evt) => {
6627
7509
  const constructs = Object.values(evt.properties).flat();
@@ -6996,12 +7878,12 @@ var program = yargs(hideBin(process.argv)).scriptName("sst").option("stage", {
6996
7878
  const { trackCli: trackCli2 } = await Promise.resolve().then(() => (init_telemetry(), telemetry_exports));
6997
7879
  trackCli2(argv._[0]);
6998
7880
  }
6999
- }).version(false).epilogue(`Join the SST community on Discord https://sst.dev/discord`).recommendCommands().demandCommand().strict().fail((_, error2, yargs2) => {
7000
- if (!error2) {
7881
+ }).version(false).epilogue(`Join the SST community on Discord https://sst.dev/discord`).recommendCommands().demandCommand().strict().fail((_, error3, yargs2) => {
7882
+ if (!error3) {
7001
7883
  yargs2.showHelp();
7002
7884
  process.exit(1);
7003
7885
  }
7004
- throw error2;
7886
+ throw error3;
7005
7887
  });
7006
7888
 
7007
7889
  // src/cli/sst.ts
@@ -7034,14 +7916,14 @@ var dev = (program2) => program2.command(
7034
7916
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
7035
7917
  const { printHeader: printHeader2 } = await Promise.resolve().then(() => (init_header(), header_exports));
7036
7918
  const { mapValues } = await import("remeda");
7037
- const path20 = await import("path");
7919
+ const path22 = await import("path");
7038
7920
  const { useRuntimeWorkers: useRuntimeWorkers2 } = await Promise.resolve().then(() => (init_workers(), workers_exports));
7039
7921
  const { useIOTBridge: useIOTBridge2 } = await Promise.resolve().then(() => (init_iot2(), iot_exports2));
7040
7922
  const { useRuntimeServer: useRuntimeServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
7041
7923
  const { useBus: useBus2 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
7042
7924
  const { useWatcher: useWatcher2 } = await Promise.resolve().then(() => (init_watcher(), watcher_exports));
7043
7925
  const { useAppMetadata: useAppMetadata2, saveAppMetadata: saveAppMetadata2, Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
7044
- const { Logger: Logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
7926
+ const { Logger: Logger3 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
7045
7927
  const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
7046
7928
  const { bold: bold2, dim: dim2, yellow } = await import("colorette");
7047
7929
  const { render } = await import("ink");
@@ -7049,7 +7931,7 @@ var dev = (program2) => program2.command(
7049
7931
  const { Context: Context2 } = await Promise.resolve().then(() => (init_context(), context_exports));
7050
7932
  const { printDeploymentResults: printDeploymentResults2, DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
7051
7933
  const { useLocalServer: useLocalServer2 } = await Promise.resolve().then(() => (init_server2(), server_exports2));
7052
- const fs18 = await import("fs/promises");
7934
+ const fs19 = await import("fs/promises");
7053
7935
  const crypto2 = await import("crypto");
7054
7936
  const { useFunctions: useFunctions3 } = await import("../src/constructs/Function.js");
7055
7937
  const { useSites } = await import("../src/constructs/SsrSite.js");
@@ -7101,9 +7983,16 @@ var dev = (program2) => program2.command(
7101
7983
  );
7102
7984
  });
7103
7985
  bus.subscribe("worker.stdout", async (evt) => {
7986
+ const info = useFunctions3().fromID(evt.properties.functionID);
7104
7987
  prefix(evt.properties.requestID);
7105
7988
  const { started } = pending.get(evt.properties.requestID);
7106
7989
  for (let line of evt.properties.message.split("\n")) {
7990
+ if (info?.runtime === "container") {
7991
+ const parts = line.split(" ");
7992
+ if (parts.length >= 4 && Date.parse(parts[0]) && parts[1].length === 36) {
7993
+ line = parts.slice(3).join(" ");
7994
+ }
7995
+ }
7107
7996
  Colors2.line(
7108
7997
  prefix(evt.properties.requestID),
7109
7998
  Colors2.dim(("+" + (Date.now() - started) + "ms").padEnd(7)),
@@ -7111,13 +8000,27 @@ var dev = (program2) => program2.command(
7111
8000
  );
7112
8001
  }
7113
8002
  });
8003
+ bus.subscribe("function.build.started", async (evt) => {
8004
+ const info = useFunctions3().fromID(evt.properties.functionID);
8005
+ if (!info)
8006
+ return;
8007
+ if (info.enableLiveDev === false)
8008
+ return;
8009
+ if (info.runtime !== "container")
8010
+ return;
8011
+ Colors2.line(
8012
+ Colors2.dim(Colors2.prefix, "Building", info.handler, "container")
8013
+ );
8014
+ });
7114
8015
  bus.subscribe("function.build.success", async (evt) => {
7115
8016
  const info = useFunctions3().fromID(evt.properties.functionID);
7116
8017
  if (!info)
7117
8018
  return;
7118
8019
  if (info.enableLiveDev === false)
7119
8020
  return;
7120
- Colors2.line(Colors2.dim(Colors2.prefix, "Built", info.handler));
8021
+ Colors2.line(
8022
+ info.runtime === "container" ? Colors2.dim(Colors2.prefix, "Built", info.handler, "container") : Colors2.dim(Colors2.prefix, "Built", info.handler)
8023
+ );
7121
8024
  });
7122
8025
  bus.subscribe("function.build.failed", async (evt) => {
7123
8026
  const info = useFunctions3().fromID(evt.properties.functionID);
@@ -7191,9 +8094,9 @@ var dev = (program2) => program2.command(
7191
8094
  outDir: `.sst/cdk.out`,
7192
8095
  mode: "dev"
7193
8096
  });
7194
- Logger2.debug("Directory", assembly.directory);
8097
+ Logger3.debug("Directory", assembly.directory);
7195
8098
  const next = await checksum(assembly.directory);
7196
- Logger2.debug("Checksum", "next", next, "old", lastDeployed);
8099
+ Logger3.debug("Checksum", "next", next, "old", lastDeployed);
7197
8100
  if (next === lastDeployed) {
7198
8101
  spinner.succeed(Colors2.dim(" Built with no changes"));
7199
8102
  isWorking = false;
@@ -7231,7 +8134,7 @@ var dev = (program2) => program2.command(
7231
8134
  useSites().all.filter(({ props }) => props.dev?.deploy !== true).forEach(({ type, props }) => {
7232
8135
  const framework = type === "AstroSite" ? "Astro" : type === "NextjsSite" ? "Next.js" : type === "RemixSite" ? "Remix" : type === "SolidStartSite" ? "SolidStart" : type === "SvelteKitSite" ? "SvelteKit" : void 0;
7233
8136
  if (framework) {
7234
- const cdCmd = path20.resolve(props.path) === process.cwd() ? "" : `cd ${props.path} && `;
8137
+ const cdCmd = path22.resolve(props.path) === process.cwd() ? "" : `cd ${props.path} && `;
7235
8138
  Colors2.line(
7236
8139
  Colors2.primary(`\u279C `),
7237
8140
  Colors2.bold(`Start ${framework}:`),
@@ -7242,8 +8145,8 @@ var dev = (program2) => program2.command(
7242
8145
  });
7243
8146
  }
7244
8147
  lastDeployed = nextChecksum;
7245
- fs18.writeFile(
7246
- path20.join(project.paths.out, "outputs.json"),
8148
+ fs19.writeFile(
8149
+ path22.join(project.paths.out, "outputs.json"),
7247
8150
  JSON.stringify(
7248
8151
  mapValues(results, (val) => val.outputs),
7249
8152
  null,
@@ -7255,17 +8158,17 @@ var dev = (program2) => program2.command(
7255
8158
  build2();
7256
8159
  }
7257
8160
  async function checksum(cdkOutPath) {
7258
- const manifestPath = path20.join(cdkOutPath, "manifest.json");
8161
+ const manifestPath = path22.join(cdkOutPath, "manifest.json");
7259
8162
  const cdkManifest = JSON.parse(
7260
- await fs18.readFile(manifestPath).then((x) => x.toString())
8163
+ await fs19.readFile(manifestPath).then((x) => x.toString())
7261
8164
  );
7262
8165
  const checksumData = await Promise.all(
7263
8166
  Object.keys(cdkManifest.artifacts).filter(
7264
8167
  (key) => cdkManifest.artifacts[key].type === "aws:cloudformation:stack"
7265
8168
  ).map(async (key) => {
7266
8169
  const { templateFile } = cdkManifest.artifacts[key].properties;
7267
- const templatePath = path20.join(cdkOutPath, templateFile);
7268
- const templateContent = await fs18.readFile(templatePath);
8170
+ const templatePath = path22.join(cdkOutPath, templateFile);
8171
+ const templateContent = await fs19.readFile(templatePath);
7269
8172
  return templateContent;
7270
8173
  })
7271
8174
  ).then((x) => x.join("\n"));
@@ -7275,7 +8178,7 @@ var dev = (program2) => program2.command(
7275
8178
  watcher.subscribe("file.changed", async (evt) => {
7276
8179
  if (!project.metafile)
7277
8180
  return;
7278
- if (!project.metafile.inputs[evt.properties.relative.split(path20.sep).join(path20.posix.sep)])
8181
+ if (!project.metafile.inputs[evt.properties.relative.split(path22.sep).join(path22.posix.sep)])
7279
8182
  return;
7280
8183
  build2();
7281
8184
  });
@@ -7320,7 +8223,7 @@ var dev = (program2) => program2.command(
7320
8223
  input: process.stdin,
7321
8224
  output: process.stdout
7322
8225
  });
7323
- return new Promise((resolve) => {
8226
+ return new Promise((resolve2) => {
7324
8227
  console.log("");
7325
8228
  rl.question(
7326
8229
  `You have previously deployed the stage "${useProject2().config.stage}" in production. It is recommended that you use a different stage for development. Read more here \u2014 https://docs.sst.dev/live-lambda-development
@@ -7328,7 +8231,7 @@ var dev = (program2) => program2.command(
7328
8231
  Are you sure you want to run this stage in dev mode? [y/N] `,
7329
8232
  async (input) => {
7330
8233
  rl.close();
7331
- resolve(input.trim() === "y");
8234
+ resolve2(input.trim() === "y");
7332
8235
  }
7333
8236
  );
7334
8237
  });
@@ -7357,7 +8260,7 @@ Are you sure you want to run this stage in dev mode? [y/N] `,
7357
8260
 
7358
8261
  // src/cli/commands/bind.ts
7359
8262
  init_error();
7360
- import path18 from "path";
8263
+ import path20 from "path";
7361
8264
  var MetadataNotFoundError = class extends Error {
7362
8265
  };
7363
8266
  var MetadataOutdatedError = class extends Error {
@@ -7376,13 +8279,13 @@ var bind = (program2) => program2.command(
7376
8279
  "Bind resources to your site before deployment"
7377
8280
  ),
7378
8281
  async (args) => {
7379
- const { spawn: spawn7 } = await import("child_process");
8282
+ const { spawn: spawn8 } = await import("child_process");
7380
8283
  const kill = await import("tree-kill");
7381
8284
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
7382
8285
  const { useBus: useBus2 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
7383
8286
  const { useIOT: useIOT2 } = await Promise.resolve().then(() => (init_iot(), iot_exports));
7384
8287
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
7385
- const { Logger: Logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
8288
+ const { Logger: Logger3 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
7386
8289
  if (args._[0] === "env") {
7387
8290
  Colors2.line(
7388
8291
  Colors2.warning(
@@ -7407,7 +8310,7 @@ var bind = (program2) => program2.command(
7407
8310
  );
7408
8311
  }
7409
8312
  if (args.script || !isSite && !args.site) {
7410
- Logger2.debug("Running in script mode.");
8313
+ Logger3.debug("Running in script mode.");
7411
8314
  return await bindScript();
7412
8315
  }
7413
8316
  await bindSite("init");
@@ -7527,7 +8430,7 @@ var bind = (program2) => program2.command(
7527
8430
  if (!c.data.path || isSsr && !c.data.server || !isSsr && !c.data.environment) {
7528
8431
  throw new MetadataOutdatedError();
7529
8432
  }
7530
- return path18.resolve(project.paths.root, c.data.path) === process.cwd();
8433
+ return path20.resolve(project.paths.root, c.data.path) === process.cwd();
7531
8434
  });
7532
8435
  if (!data2) {
7533
8436
  throw new MetadataNotFoundError();
@@ -7586,16 +8489,16 @@ var bind = (program2) => program2.command(
7586
8489
  Colors2.gap();
7587
8490
  if (p) {
7588
8491
  p.removeAllListeners("exit");
7589
- await new Promise((resolve, reject) => {
7590
- kill.default(p?.pid, (error2) => {
7591
- if (error2) {
7592
- return reject(error2);
8492
+ await new Promise((resolve2, reject) => {
8493
+ kill.default(p?.pid, (error3) => {
8494
+ if (error3) {
8495
+ return reject(error3);
7593
8496
  }
7594
- resolve(true);
8497
+ resolve2(true);
7595
8498
  });
7596
8499
  });
7597
8500
  }
7598
- p = spawn7(command, {
8501
+ p = spawn8(command, {
7599
8502
  env: {
7600
8503
  ...process.env,
7601
8504
  ...envs,
@@ -7641,7 +8544,7 @@ var bind = (program2) => program2.command(
7641
8544
  Colors2.line(
7642
8545
  "Using local IAM credentials since `sst dev` is not running."
7643
8546
  );
7644
- Logger2.debug(`Failed to assume ${roleArn}.`, err);
8547
+ Logger3.debug(`Failed to assume ${roleArn}.`, err);
7645
8548
  }
7646
8549
  }
7647
8550
  ).strict(false);
@@ -7658,7 +8561,7 @@ var build = (program2) => program2.command(
7658
8561
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
7659
8562
  const { Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
7660
8563
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
7661
- const path20 = await import("path");
8564
+ const path22 = await import("path");
7662
8565
  const project = useProject2();
7663
8566
  const [_metafile, sstConfig] = await Stacks.load(project.paths.config);
7664
8567
  const result = await Stacks.synth({
@@ -7670,7 +8573,7 @@ var build = (program2) => program2.command(
7670
8573
  Colors2.line(
7671
8574
  Colors2.success(`\u2714`),
7672
8575
  Colors2.bold(" Built:"),
7673
- `${result.stacks.length} stack${result.stacks.length > 1 ? "s" : ""} to ${path20.relative(process.cwd(), result.directory)}`
8576
+ `${result.stacks.length} stack${result.stacks.length > 1 ? "s" : ""} to ${path22.relative(process.cwd(), result.directory)}`
7674
8577
  );
7675
8578
  process.exit(0);
7676
8579
  }
@@ -7679,8 +8582,8 @@ var build = (program2) => program2.command(
7679
8582
  // src/cli/commands/deploy.tsx
7680
8583
  init_credentials();
7681
8584
  init_colors();
7682
- import fs17 from "fs/promises";
7683
- import path19 from "path";
8585
+ import fs18 from "fs/promises";
8586
+ import path21 from "path";
7684
8587
  var deploy2 = (program2) => program2.command(
7685
8588
  "deploy [filter]",
7686
8589
  "Deploy your app to AWS",
@@ -7713,7 +8616,7 @@ var deploy2 = (program2) => program2.command(
7713
8616
  input: process.stdin,
7714
8617
  output: process.stdout
7715
8618
  });
7716
- return new Promise((resolve) => {
8619
+ return new Promise((resolve2) => {
7717
8620
  console.log("");
7718
8621
  rl.question(
7719
8622
  `You were previously running the stage "${project.config.stage}" in dev mode. It is recommended that you use a different stage for production. Read more here \u2014 https://docs.sst.dev/live-lambda-development
@@ -7721,7 +8624,7 @@ var deploy2 = (program2) => program2.command(
7721
8624
  Are you sure you want to deploy to this stage? (y/N) `,
7722
8625
  async (input) => {
7723
8626
  rl.close();
7724
- resolve(input.trim() === "y");
8627
+ resolve2(input.trim() === "y");
7725
8628
  }
7726
8629
  );
7727
8630
  });
@@ -7770,8 +8673,8 @@ Are you sure you want to deploy to this stage? (y/N) `,
7770
8673
  printDeploymentResults2(assembly, results);
7771
8674
  if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
7772
8675
  process.exit(1);
7773
- fs17.writeFile(
7774
- path19.join(project.paths.out, "outputs.json"),
8676
+ fs18.writeFile(
8677
+ path21.join(project.paths.out, "outputs.json"),
7775
8678
  JSON.stringify(
7776
8679
  mapValues(results, (val) => val.outputs),
7777
8680
  null,
@@ -7988,8 +8891,8 @@ var load2 = (program2) => program2.command(
7988
8891
  const { blue: blue4 } = await import("colorette");
7989
8892
  const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
7990
8893
  const { parse: parse2 } = await import("dotenv");
7991
- const fs18 = await import("fs/promises");
7992
- const fileContent = await fs18.readFile(args.filename, "utf-8");
8894
+ const fs19 = await import("fs/promises");
8895
+ const fileContent = await fs19.readFile(args.filename, "utf-8");
7993
8896
  const envVars = parse2(fileContent);
7994
8897
  const setting = createSpinner2(
7995
8898
  ` Setting secrets from "${args.filename}"`
@@ -8145,22 +9048,22 @@ var update = (program2) => program2.command(
8145
9048
  }),
8146
9049
  async (args) => {
8147
9050
  const { green, yellow } = await import("colorette");
8148
- const fs18 = await import("fs/promises");
8149
- const path20 = await import("path");
9051
+ const fs19 = await import("fs/promises");
9052
+ const path22 = await import("path");
8150
9053
  const { fetch } = await import("undici");
8151
9054
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
8152
9055
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
8153
9056
  async function find2(dir) {
8154
- const children = await fs18.readdir(dir);
9057
+ const children = await fs19.readdir(dir);
8155
9058
  const tasks2 = children.map(async (item) => {
8156
9059
  if (item === "node_modules")
8157
9060
  return [];
8158
9061
  if (/(^|\/)\.[^\/\.]/g.test(item))
8159
9062
  return [];
8160
- const full = path20.join(dir, item);
9063
+ const full = path22.join(dir, item);
8161
9064
  if (item === "package.json")
8162
9065
  return [full];
8163
- const stat = await fs18.stat(full);
9066
+ const stat = await fs19.stat(full);
8164
9067
  if (stat.isDirectory())
8165
9068
  return find2(full);
8166
9069
  return [];
@@ -8174,7 +9077,7 @@ var update = (program2) => program2.command(
8174
9077
  ).then((resp) => resp.json());
8175
9078
  const results = /* @__PURE__ */ new Map();
8176
9079
  const tasks = files.map(async (file) => {
8177
- const data2 = await fs18.readFile(file).then((x) => x.toString()).then(JSON.parse);
9080
+ const data2 = await fs19.readFile(file).then((x) => x.toString()).then(JSON.parse);
8178
9081
  for (const field of FIELDS) {
8179
9082
  const deps = data2[field];
8180
9083
  if (!deps)
@@ -8208,7 +9111,7 @@ var update = (program2) => program2.command(
8208
9111
  }
8209
9112
  }
8210
9113
  if (results.has(file)) {
8211
- await fs18.writeFile(file, JSON.stringify(data2, null, 2));
9114
+ await fs19.writeFile(file, JSON.stringify(data2, null, 2));
8212
9115
  }
8213
9116
  });
8214
9117
  await Promise.all(tasks);
@@ -8219,7 +9122,7 @@ var update = (program2) => program2.command(
8219
9122
  for (const [file, pkgs] of results.entries()) {
8220
9123
  Colors2.line(
8221
9124
  Colors2.success(`\u2714 `),
8222
- Colors2.bold.dim(path20.relative(project.paths.root, file))
9125
+ Colors2.bold.dim(path22.relative(project.paths.root, file))
8223
9126
  );
8224
9127
  for (const [pkg, version2] of pkgs) {
8225
9128
  Colors2.line(Colors2.dim(` ${pkg}@${version2}`));