sst 2.0.17 → 2.0.19

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
@@ -2291,9 +2291,11 @@ var init_server2 = __esm({
2291
2291
  "Lambda-Runtime-Client-Context": JSON.stringify(
2292
2292
  payload.context.clientContext || {}
2293
2293
  ),
2294
- "Lambda-Runtime-Cognito-Identity": JSON.stringify(
2295
- payload.context.identity || {}
2296
- )
2294
+ ...payload.context.identity ? {
2295
+ "Lambda-Runtime-Cognito-Identity": JSON.stringify(
2296
+ payload.context.identity
2297
+ )
2298
+ } : {}
2297
2299
  });
2298
2300
  res.json(payload.event);
2299
2301
  }
@@ -2302,10 +2304,13 @@ var init_server2 = __esm({
2302
2304
  `/:workerID/${cfg.API_VERSION}/runtime/invocation/:awsRequestId/response`,
2303
2305
  express2.json({
2304
2306
  strict: false,
2305
- type: ["application/json", "application/*+json"],
2307
+ type() {
2308
+ return true;
2309
+ },
2306
2310
  limit: "10mb"
2307
2311
  }),
2308
2312
  (req, res) => {
2313
+ console.log(JSON.stringify(req.body, null, 4));
2309
2314
  Logger.debug("Worker", req.params.workerID, "got response", req.body);
2310
2315
  const worker = workers.fromID(req.params.workerID);
2311
2316
  bus.publish("function.success", {
@@ -2488,8 +2493,8 @@ var init_workers = __esm({
2488
2493
  import { IoTClient, DescribeEndpointCommand } from "@aws-sdk/client-iot";
2489
2494
  import iot from "aws-iot-device-sdk";
2490
2495
  function encode(input) {
2491
- const json3 = JSON.stringify(input);
2492
- const parts = json3.match(/.{1,100000}/g);
2496
+ const json = JSON.stringify(input);
2497
+ const parts = json.match(/.{1,100000}/g);
2493
2498
  if (!parts)
2494
2499
  return [];
2495
2500
  const id = Math.random().toString();
@@ -2884,7 +2889,6 @@ import {
2884
2889
  PutObjectCommand,
2885
2890
  DeleteObjectCommand
2886
2891
  } from "@aws-sdk/client-s3";
2887
- import { json } from "stream/consumers";
2888
2892
  async function metadata() {
2889
2893
  Logger.debug("Fetching app metadata");
2890
2894
  const [project, credentials, bootstrap2] = await Promise.all([
@@ -2902,8 +2906,9 @@ async function metadata() {
2902
2906
  Key: useS3Key(),
2903
2907
  Bucket: bootstrap2.bucket
2904
2908
  })
2905
- ).then((result2) => json(result2.Body));
2906
- return result;
2909
+ );
2910
+ const body = await result.Body.transformToString();
2911
+ return JSON.parse(body);
2907
2912
  } catch (ex) {
2908
2913
  Logger.debug("Fetching app metadata: not found");
2909
2914
  }
@@ -4355,13 +4360,13 @@ async function listImports(exportName) {
4355
4360
  }
4356
4361
  }
4357
4362
  async function getLocalTemplate(stack) {
4358
- const fs18 = await import("fs/promises");
4359
- const fileContent = await fs18.readFile(stack.templateFullPath);
4363
+ const fs19 = await import("fs/promises");
4364
+ const fileContent = await fs19.readFile(stack.templateFullPath);
4360
4365
  return fileContent.toString();
4361
4366
  }
4362
4367
  async function saveLocalTemplate(stack, content) {
4363
- const fs18 = await import("fs/promises");
4364
- await fs18.writeFile(stack.templateFullPath, content);
4368
+ const fs19 = await import("fs/promises");
4369
+ await fs19.writeFile(stack.templateFullPath, content);
4365
4370
  }
4366
4371
  var init_deploy = __esm({
4367
4372
  "src/stacks/deploy.ts"() {
@@ -4477,7 +4482,6 @@ import {
4477
4482
  GetObjectCommand as GetObjectCommand2,
4478
4483
  ListObjectsV2Command
4479
4484
  } from "@aws-sdk/client-s3";
4480
- import { json as json2 } from "stream/consumers";
4481
4485
  async function metadata2() {
4482
4486
  Logger.debug("Fetching all metadata");
4483
4487
  const project = useProject();
@@ -4505,8 +4509,9 @@ async function metadata2() {
4505
4509
  Key: obj.Key,
4506
4510
  Bucket: bootstrap2.bucket
4507
4511
  })
4508
- ).then((result3) => json2(result3.Body));
4509
- return [stackID, result2];
4512
+ );
4513
+ const body = await result2.Body.transformToString();
4514
+ return [stackID, JSON.parse(body)];
4510
4515
  }) || []
4511
4516
  )
4512
4517
  );
@@ -4531,8 +4536,9 @@ async function metadataForStack(stackID) {
4531
4536
  Key: key,
4532
4537
  Bucket: bootstrap2.bucket
4533
4538
  })
4534
- ).then((result2) => json2(result2.Body));
4535
- return result;
4539
+ );
4540
+ const body = await result.Body.transformToString();
4541
+ return JSON.parse(body);
4536
4542
  } catch (ex) {
4537
4543
  console.error(ex);
4538
4544
  return [];
@@ -4874,14 +4880,14 @@ var init_node = __esm({
4874
4880
  }
4875
4881
  if (input.mode === "deploy" && nodejs.install) {
4876
4882
  const src = await find2(parsed.dir, "package.json");
4877
- const json3 = JSON.parse(
4883
+ const json = JSON.parse(
4878
4884
  await fs10.readFile(path10.join(src, "package.json")).then((x) => x.toString())
4879
4885
  );
4880
4886
  fs10.writeFile(
4881
4887
  path10.join(input.out, "package.json"),
4882
4888
  JSON.stringify({
4883
4889
  dependencies: Object.fromEntries(
4884
- nodejs.install?.map((x) => [x, json3.dependencies?.[x] || "*"])
4890
+ nodejs.install?.map((x) => [x, json.dependencies?.[x] || "*"])
4885
4891
  )
4886
4892
  })
4887
4893
  );
@@ -5047,19 +5053,131 @@ var init_go = __esm({
5047
5053
  }
5048
5054
  });
5049
5055
 
5056
+ // src/runtime/handlers/rust.ts
5057
+ var rust_exports = {};
5058
+ __export(rust_exports, {
5059
+ useRustHandler: () => useRustHandler
5060
+ });
5061
+ import path12 from "path";
5062
+ import fs12 from "fs/promises";
5063
+ import { exec as exec4, spawn as spawn4 } from "child_process";
5064
+ import { promisify as promisify3 } from "util";
5065
+ var execAsync3, useRustHandler;
5066
+ var init_rust = __esm({
5067
+ "src/runtime/handlers/rust.ts"() {
5068
+ "use strict";
5069
+ init_handlers();
5070
+ init_workers();
5071
+ init_context();
5072
+ init_error();
5073
+ init_server2();
5074
+ init_fs();
5075
+ execAsync3 = promisify3(exec4);
5076
+ useRustHandler = Context.memo(async () => {
5077
+ const workers = await useRuntimeWorkers();
5078
+ const server = await useRuntimeServerConfig();
5079
+ const handlers = useRuntimeHandlers();
5080
+ const processes = /* @__PURE__ */ new Map();
5081
+ const sources = /* @__PURE__ */ new Map();
5082
+ const handlerName = process.platform === "win32" ? `handler.exe` : `handler`;
5083
+ handlers.register({
5084
+ shouldBuild: (input) => {
5085
+ if (!input.file.endsWith(".rs"))
5086
+ return false;
5087
+ const parent = sources.get(input.functionID);
5088
+ if (!parent)
5089
+ return false;
5090
+ const result = isChild(parent, input.file);
5091
+ return result;
5092
+ },
5093
+ canHandle: (input) => input.startsWith("rust"),
5094
+ startWorker: async (input) => {
5095
+ const proc = spawn4(path12.join(input.out, handlerName), {
5096
+ env: {
5097
+ ...process.env,
5098
+ ...input.environment,
5099
+ IS_LOCAL: "true",
5100
+ RUST_BACKTRACE: "1",
5101
+ AWS_LAMBDA_RUNTIME_API: `http://localhost:${server.port}/${input.workerID}`,
5102
+ AWS_LAMBDA_FUNCTION_MEMORY_SIZE: "1024"
5103
+ },
5104
+ cwd: input.out
5105
+ });
5106
+ proc.on("exit", () => workers.exited(input.workerID));
5107
+ proc.stdout.on("data", (data2) => {
5108
+ workers.stdout(input.workerID, data2.toString());
5109
+ });
5110
+ proc.stderr.on("data", (data2) => {
5111
+ workers.stdout(input.workerID, data2.toString());
5112
+ });
5113
+ processes.set(input.workerID, proc);
5114
+ },
5115
+ stopWorker: async (workerID) => {
5116
+ const proc = processes.get(workerID);
5117
+ if (proc) {
5118
+ proc.kill();
5119
+ processes.delete(workerID);
5120
+ }
5121
+ },
5122
+ build: async (input) => {
5123
+ const parsed = path12.parse(input.props.handler);
5124
+ const project = await findAbove(parsed.dir, "Cargo.toml");
5125
+ sources.set(input.functionID, project);
5126
+ if (input.mode === "start") {
5127
+ try {
5128
+ await execAsync3(`cargo build --bin ${parsed.name}`, {
5129
+ cwd: project,
5130
+ env: {
5131
+ ...process.env
5132
+ }
5133
+ });
5134
+ await fs12.cp(
5135
+ path12.join(project, `target/debug`, parsed.name),
5136
+ path12.join(input.out, "handler")
5137
+ );
5138
+ } catch (ex) {
5139
+ throw new VisibleError("Failed to build");
5140
+ }
5141
+ }
5142
+ if (input.mode === "deploy") {
5143
+ try {
5144
+ await execAsync3(`cargo lambda build --release --bin ${parsed.name}`, {
5145
+ cwd: project,
5146
+ env: {
5147
+ ...process.env
5148
+ }
5149
+ });
5150
+ await fs12.cp(
5151
+ path12.join(project, `target/lambda/`, parsed.name, "bootstrap"),
5152
+ path12.join(input.out, "bootstrap")
5153
+ );
5154
+ } catch (ex) {
5155
+ throw new VisibleError("Failed to build");
5156
+ }
5157
+ }
5158
+ return {
5159
+ type: "success",
5160
+ handler: "handler"
5161
+ };
5162
+ }
5163
+ });
5164
+ });
5165
+ }
5166
+ });
5167
+
5050
5168
  // src/runtime/handlers/python.ts
5051
5169
  var python_exports = {};
5052
5170
  __export(python_exports, {
5053
5171
  usePythonHandler: () => usePythonHandler
5054
5172
  });
5055
- import path12 from "path";
5056
- import { exec as exec4, spawn as spawn4 } from "child_process";
5057
- import { promisify as promisify3 } from "util";
5173
+ import path13 from "path";
5174
+ import { exec as exec5, spawn as spawn5 } from "child_process";
5175
+ import { promisify as promisify4 } from "util";
5058
5176
  import { Runtime as Runtime2 } from "aws-cdk-lib/aws-lambda";
5059
- import fs12 from "fs/promises";
5177
+ import fs13 from "fs/promises";
5060
5178
  import os3 from "os";
5061
5179
  import url6 from "url";
5062
- var execAsync3, RUNTIME_MAP, usePythonHandler;
5180
+ var execAsync4, RUNTIME_MAP, usePythonHandler;
5063
5181
  var init_python = __esm({
5064
5182
  "src/runtime/handlers/python.ts"() {
5065
5183
  "use strict";
@@ -5068,7 +5186,7 @@ var init_python = __esm({
5068
5186
  init_context();
5069
5187
  init_server2();
5070
5188
  init_fs();
5071
- execAsync3 = promisify3(exec4);
5189
+ execAsync4 = promisify4(exec5);
5072
5190
  RUNTIME_MAP = {
5073
5191
  "python2.7": Runtime2.PYTHON_2_7,
5074
5192
  "python3.6": Runtime2.PYTHON_3_6,
@@ -5092,9 +5210,9 @@ var init_python = __esm({
5092
5210
  canHandle: (input) => input.startsWith("python"),
5093
5211
  startWorker: async (input) => {
5094
5212
  const src = await findAbove(input.handler, "requirements.txt");
5095
- const parsed = path12.parse(path12.relative(src, input.handler));
5096
- const target = [...parsed.dir.split(path12.sep), parsed.name].join(".");
5097
- const proc = spawn4(
5213
+ const parsed = path13.parse(path13.relative(src, input.handler));
5214
+ const target = [...parsed.dir.split(path13.sep), parsed.name].join(".");
5215
+ const proc = spawn5(
5098
5216
  os3.platform() === "win32" ? "python.exe" : "python3",
5099
5217
  [
5100
5218
  "-u",
@@ -5140,18 +5258,18 @@ var init_python = __esm({
5140
5258
  handler: input.props.handler
5141
5259
  };
5142
5260
  const src = await findAbove(input.props.handler, "requirements.txt");
5143
- await fs12.cp(src, input.out, {
5261
+ await fs13.cp(src, input.out, {
5144
5262
  recursive: true,
5145
5263
  filter: (src2) => !src2.includes(".sst")
5146
5264
  });
5147
5265
  if (input.props.python?.installCommands) {
5148
5266
  for (const cmd of input.props.python.installCommands) {
5149
- await execAsync3(cmd);
5267
+ await execAsync4(cmd);
5150
5268
  }
5151
5269
  }
5152
5270
  const result = {
5153
5271
  type: "success",
5154
- handler: path12.relative(src, path12.resolve(input.props.handler))
5272
+ handler: path13.relative(src, path13.resolve(input.props.handler))
5155
5273
  };
5156
5274
  return result;
5157
5275
  }
@@ -5165,14 +5283,14 @@ var java_exports = {};
5165
5283
  __export(java_exports, {
5166
5284
  useJavaHandler: () => useJavaHandler
5167
5285
  });
5168
- import path13 from "path";
5169
- import fs13 from "fs/promises";
5286
+ import path14 from "path";
5287
+ import fs14 from "fs/promises";
5170
5288
  import os4 from "os";
5171
5289
  import zipLocal from "zip-local";
5172
- import { spawn as spawn5 } from "child_process";
5290
+ import { spawn as spawn6 } from "child_process";
5173
5291
  import url7 from "url";
5174
5292
  async function getGradleBinary(srcPath) {
5175
- const gradleWrapperPath = path13.resolve(path13.join(srcPath, "gradlew"));
5293
+ const gradleWrapperPath = path14.resolve(path14.join(srcPath, "gradlew"));
5176
5294
  return await existsAsync(gradleWrapperPath) ? gradleWrapperPath : "gradle";
5177
5295
  }
5178
5296
  var useJavaHandler;
@@ -5204,7 +5322,7 @@ var init_java = __esm({
5204
5322
  },
5205
5323
  canHandle: (input) => input.startsWith("java"),
5206
5324
  startWorker: async (input) => {
5207
- const proc = spawn5(
5325
+ const proc = spawn6(
5208
5326
  `java`,
5209
5327
  [
5210
5328
  `-cp`,
@@ -5256,11 +5374,11 @@ var init_java = __esm({
5256
5374
  cwd: srcPath
5257
5375
  }
5258
5376
  );
5259
- const buildOutput = path13.join(srcPath, "build", outputDir);
5260
- const zip = (await fs13.readdir(buildOutput)).find(
5377
+ const buildOutput = path14.join(srcPath, "build", outputDir);
5378
+ const zip = (await fs14.readdir(buildOutput)).find(
5261
5379
  (f) => f.endsWith(".zip")
5262
5380
  );
5263
- zipLocal.sync.unzip(path13.join(buildOutput, zip)).save(input.out);
5381
+ zipLocal.sync.unzip(path14.join(buildOutput, zip)).save(input.out);
5264
5382
  return {
5265
5383
  type: "success",
5266
5384
  handler: input.props.handler
@@ -5279,12 +5397,13 @@ var init_java = __esm({
5279
5397
 
5280
5398
  // src/stacks/synth.ts
5281
5399
  import * as contextproviders from "aws-cdk/lib/context-providers/index.js";
5282
- import path14 from "path";
5400
+ import path15 from "path";
5283
5401
  async function synth(opts) {
5284
5402
  Logger.debug("Synthesizing stacks...");
5285
5403
  const { App: App2 } = await import("../src/constructs/App.js");
5286
5404
  const { useNodeHandler: useNodeHandler2 } = await Promise.resolve().then(() => (init_node(), node_exports));
5287
5405
  const { useGoHandler: useGoHandler2 } = await Promise.resolve().then(() => (init_go(), go_exports));
5406
+ const { useRustHandler: useRustHandler2 } = await Promise.resolve().then(() => (init_rust(), rust_exports));
5288
5407
  const { usePythonHandler: usePythonHandler2 } = await Promise.resolve().then(() => (init_python(), python_exports));
5289
5408
  const { useJavaHandler: useJavaHandler2 } = await Promise.resolve().then(() => (init_java(), java_exports));
5290
5409
  useNodeHandler2();
@@ -5292,12 +5411,13 @@ async function synth(opts) {
5292
5411
  usePythonHandler2();
5293
5412
  useJavaHandler2();
5294
5413
  useDotnetHandler();
5414
+ useRustHandler2();
5295
5415
  const { Configuration } = await import("aws-cdk/lib/settings.js");
5296
5416
  const project = useProject();
5297
5417
  const identity = await useSTSIdentity();
5298
5418
  opts = {
5299
5419
  ...opts,
5300
- buildDir: opts.buildDir || path14.join(project.paths.out, "dist")
5420
+ buildDir: opts.buildDir || path15.join(project.paths.out, "dist")
5301
5421
  };
5302
5422
  const cfg = new Configuration();
5303
5423
  await cfg.load();
@@ -5671,16 +5791,16 @@ __export(pothos_exports, {
5671
5791
  import babel from "@babel/core";
5672
5792
  import generator from "@babel/generator";
5673
5793
  import esbuild3 from "esbuild";
5674
- import fs14 from "fs/promises";
5675
- import path15 from "path";
5794
+ import fs15 from "fs/promises";
5795
+ import path16 from "path";
5676
5796
  import url8 from "url";
5677
5797
  async function generate(opts) {
5678
5798
  const { printSchema, lexicographicSortSchema } = await import("graphql");
5679
5799
  const contents = await extractSchema(opts);
5680
- const out = path15.join(path15.dirname(opts.schema), "out.mjs");
5681
- await fs14.writeFile(out, contents, "utf8");
5800
+ const out = path16.join(path16.dirname(opts.schema), "out.mjs");
5801
+ await fs15.writeFile(out, contents, "utf8");
5682
5802
  const { schema } = await import(url8.pathToFileURL(out).href + "?bust=" + Date.now());
5683
- await fs14.rm(out);
5803
+ await fs15.rm(out);
5684
5804
  const schemaAsString = printSchema(lexicographicSortSchema(schema));
5685
5805
  return schemaAsString;
5686
5806
  }
@@ -5715,15 +5835,15 @@ async function extractSchema(opts) {
5715
5835
  {
5716
5836
  name: "pothos-extractor",
5717
5837
  visitor: {
5718
- Program(path18) {
5719
- const dummyResolverId = path18.scope.generateUidIdentifier("DUMMY_RESOLVER");
5838
+ Program(path19) {
5839
+ const dummyResolverId = path19.scope.generateUidIdentifier("DUMMY_RESOLVER");
5720
5840
  const resolverNode = dummyResolver({
5721
5841
  dummy_resolver: dummyResolverId
5722
5842
  });
5723
- path18.unshiftContainer("body", resolverNode);
5724
- path18.scope.crawl();
5843
+ path19.unshiftContainer("body", resolverNode);
5844
+ path19.scope.crawl();
5725
5845
  let schemaBuilder = null;
5726
- path18.traverse({
5846
+ path19.traverse({
5727
5847
  ImportDeclaration(declarator) {
5728
5848
  if (!declarator)
5729
5849
  return;
@@ -5781,17 +5901,17 @@ async function extractSchema(opts) {
5781
5901
  );
5782
5902
  return contents.code;
5783
5903
  }
5784
- function getBindings(path18, globalPaths) {
5904
+ function getBindings(path19, globalPaths) {
5785
5905
  const bindings = [];
5786
- path18.traverse({
5906
+ path19.traverse({
5787
5907
  Expression(expressionPath) {
5788
5908
  if (!expressionPath.isIdentifier())
5789
5909
  return;
5790
- const binding = path18.scope.getBinding(expressionPath);
5910
+ const binding = path19.scope.getBinding(expressionPath);
5791
5911
  if (!binding || globalPaths.has(binding.path) || bindings.includes(binding.path))
5792
5912
  return;
5793
5913
  const rootBinding = findRootBinding(binding.path);
5794
- if (path18 === rootBinding) {
5914
+ if (path19 === rootBinding) {
5795
5915
  bindings.push(binding.path);
5796
5916
  return;
5797
5917
  }
@@ -5804,8 +5924,8 @@ function getBindings(path18, globalPaths) {
5804
5924
  }
5805
5925
  return bindings;
5806
5926
  }
5807
- function findRootBinding(path18) {
5808
- let rootPath = path18;
5927
+ function findRootBinding(path19) {
5928
+ let rootPath = path19;
5809
5929
  while (rootPath.parentPath?.node !== void 0 && !rootPath.parentPath?.isProgram()) {
5810
5930
  rootPath = rootPath.parentPath;
5811
5931
  }
@@ -5828,11 +5948,11 @@ var pothos_exports2 = {};
5828
5948
  __export(pothos_exports2, {
5829
5949
  usePothosBuilder: () => usePothosBuilder
5830
5950
  });
5831
- import fs15 from "fs/promises";
5832
- import { exec as exec5 } from "child_process";
5833
- import { promisify as promisify4 } from "util";
5834
- import path16 from "path";
5835
- var execAsync4, usePothosBuilder;
5951
+ import fs16 from "fs/promises";
5952
+ import { exec as exec6 } from "child_process";
5953
+ import { promisify as promisify5 } from "util";
5954
+ import path17 from "path";
5955
+ var execAsync5, usePothosBuilder;
5836
5956
  var init_pothos2 = __esm({
5837
5957
  "src/cli/commands/plugins/pothos.ts"() {
5838
5958
  "use strict";
@@ -5840,7 +5960,7 @@ var init_pothos2 = __esm({
5840
5960
  init_context();
5841
5961
  init_pothos();
5842
5962
  init_colors();
5843
- execAsync4 = promisify4(exec5);
5963
+ execAsync5 = promisify5(exec6);
5844
5964
  usePothosBuilder = Context.memo(() => {
5845
5965
  let routes = [];
5846
5966
  const bus = useBus();
@@ -5849,9 +5969,9 @@ var init_pothos2 = __esm({
5849
5969
  const schema = await pothos_exports.generate({
5850
5970
  schema: route.schema
5851
5971
  });
5852
- await fs15.writeFile(route.output, schema);
5972
+ await fs16.writeFile(route.output, schema);
5853
5973
  if (Array.isArray(route.commands) && route.commands.length > 0) {
5854
- await Promise.all(route.commands.map((cmd) => execAsync4(cmd)));
5974
+ await Promise.all(route.commands.map((cmd) => execAsync5(cmd)));
5855
5975
  }
5856
5976
  Colors.line(Colors.success(`\u2714`), " Pothos: Extracted pothos schema");
5857
5977
  } catch (ex) {
@@ -5865,9 +5985,9 @@ var init_pothos2 = __esm({
5865
5985
  if (evt.properties.file.endsWith("out.mjs"))
5866
5986
  return;
5867
5987
  for (const route of routes) {
5868
- const dir = path16.dirname(route.schema);
5869
- const relative = path16.relative(dir, evt.properties.file);
5870
- if (relative && !relative.startsWith("..") && !path16.isAbsolute(relative))
5988
+ const dir = path17.dirname(route.schema);
5989
+ const relative = path17.relative(dir, evt.properties.file);
5990
+ if (relative && !relative.startsWith("..") && !path17.isAbsolute(relative))
5871
5991
  build2(route);
5872
5992
  }
5873
5993
  });
@@ -5893,7 +6013,7 @@ __export(kysely_exports, {
5893
6013
  import { Kysely } from "kysely";
5894
6014
  import { DataApiDialect } from "kysely-data-api";
5895
6015
  import RDSDataService from "aws-sdk/clients/rdsdataservice.js";
5896
- import * as fs16 from "fs/promises";
6016
+ import * as fs17 from "fs/promises";
5897
6017
  import {
5898
6018
  DatabaseMetadata,
5899
6019
  EnumCollection,
@@ -5969,7 +6089,7 @@ var init_kysely = __esm({
5969
6089
  };
5970
6090
  const serializer = new Serializer();
5971
6091
  const data2 = serializer.serialize(nodes);
5972
- await fs16.writeFile(db.types.path, data2);
6092
+ await fs17.writeFile(db.types.path, data2);
5973
6093
  }
5974
6094
  bus.subscribe("stacks.metadata", (evt) => {
5975
6095
  const constructs = Object.values(evt.properties).flat();
@@ -6328,14 +6448,14 @@ var env = (program2) => program2.command(
6328
6448
  ),
6329
6449
  async (args) => {
6330
6450
  const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
6331
- const fs18 = await import("fs/promises");
6451
+ const fs19 = await import("fs/promises");
6332
6452
  const { SiteEnv } = await Promise.resolve().then(() => (init_site_env(), site_env_exports));
6333
6453
  const { spawnSync } = await import("child_process");
6334
6454
  const { useAWSCredentials: useAWSCredentials2 } = await Promise.resolve().then(() => (init_credentials(), credentials_exports));
6335
6455
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
6336
6456
  let spinner;
6337
6457
  while (true) {
6338
- const exists = await fs18.access(SiteEnv.valuesFile()).then(() => true).catch(() => false);
6458
+ const exists = await fs19.access(SiteEnv.valuesFile()).then(() => true).catch(() => false);
6339
6459
  if (!exists) {
6340
6460
  spinner = createSpinner2(
6341
6461
  "Cannot find SST environment variables. Waiting for SST to start..."
@@ -6397,8 +6517,8 @@ var dev = (program2) => program2.command(
6397
6517
  const { Context: Context2 } = await Promise.resolve().then(() => (init_context(), context_exports));
6398
6518
  const { printDeploymentResults: printDeploymentResults2, DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
6399
6519
  const { useLocalServer: useLocalServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
6400
- const path18 = await import("path");
6401
- const fs18 = await import("fs/promises");
6520
+ const path19 = await import("path");
6521
+ const fs19 = await import("fs/promises");
6402
6522
  const crypto2 = await import("crypto");
6403
6523
  const { useFunctions: useFunctions3 } = await import("../src/constructs/Function.js");
6404
6524
  const { SiteEnv } = await Promise.resolve().then(() => (init_site_env(), site_env_exports));
@@ -6587,8 +6707,8 @@ var dev = (program2) => program2.command(
6587
6707
  }
6588
6708
  await SiteEnv.writeValues(result);
6589
6709
  }
6590
- fs18.writeFile(
6591
- path18.join(project.paths.out, "outputs.json"),
6710
+ fs19.writeFile(
6711
+ path19.join(project.paths.out, "outputs.json"),
6592
6712
  JSON.stringify(
6593
6713
  pipe2(
6594
6714
  results,
@@ -6604,17 +6724,17 @@ var dev = (program2) => program2.command(
6604
6724
  build2();
6605
6725
  }
6606
6726
  async function checksum(cdkOutPath) {
6607
- const manifestPath = path18.join(cdkOutPath, "manifest.json");
6727
+ const manifestPath = path19.join(cdkOutPath, "manifest.json");
6608
6728
  const cdkManifest = JSON.parse(
6609
- await fs18.readFile(manifestPath).then((x) => x.toString())
6729
+ await fs19.readFile(manifestPath).then((x) => x.toString())
6610
6730
  );
6611
6731
  const checksumData = await Promise.all(
6612
6732
  Object.keys(cdkManifest.artifacts).filter(
6613
6733
  (key) => cdkManifest.artifacts[key].type === "aws:cloudformation:stack"
6614
6734
  ).map(async (key) => {
6615
6735
  const { templateFile } = cdkManifest.artifacts[key].properties;
6616
- const templatePath = path18.join(cdkOutPath, templateFile);
6617
- const templateContent = await fs18.readFile(templatePath);
6736
+ const templatePath = path19.join(cdkOutPath, templateFile);
6737
+ const templateContent = await fs19.readFile(templatePath);
6618
6738
  return templateContent;
6619
6739
  })
6620
6740
  ).then((x) => x.join("\n"));
@@ -6724,7 +6844,7 @@ var build = (program2) => program2.command(
6724
6844
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
6725
6845
  const { Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
6726
6846
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
6727
- const path18 = await import("path");
6847
+ const path19 = await import("path");
6728
6848
  const result = await Stacks.synth({
6729
6849
  fn: useProject2().stacks,
6730
6850
  buildDir: args.to,
@@ -6734,7 +6854,7 @@ var build = (program2) => program2.command(
6734
6854
  Colors2.line(
6735
6855
  Colors2.success(`\u2714`),
6736
6856
  Colors2.bold(" Built:"),
6737
- `${result.stacks.length} stack${result.stacks.length > 1 ? "s" : ""} to ${path18.relative(process.cwd(), result.directory)}`
6857
+ `${result.stacks.length} stack${result.stacks.length > 1 ? "s" : ""} to ${path19.relative(process.cwd(), result.directory)}`
6738
6858
  );
6739
6859
  process.exit(0);
6740
6860
  }
@@ -6743,8 +6863,8 @@ var build = (program2) => program2.command(
6743
6863
  // src/cli/commands/deploy.tsx
6744
6864
  init_credentials();
6745
6865
  init_colors();
6746
- import fs17 from "fs/promises";
6747
- import path17 from "path";
6866
+ import fs18 from "fs/promises";
6867
+ import path18 from "path";
6748
6868
  var deploy2 = (program2) => program2.command(
6749
6869
  "deploy [filter]",
6750
6870
  "Deploy your app to AWS",
@@ -6813,8 +6933,8 @@ var deploy2 = (program2) => program2.command(
6813
6933
  printDeploymentResults2(assembly, results);
6814
6934
  if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
6815
6935
  process.exit(1);
6816
- fs17.writeFile(
6817
- path17.join(project.paths.out, "outputs.json"),
6936
+ fs18.writeFile(
6937
+ path18.join(project.paths.out, "outputs.json"),
6818
6938
  JSON.stringify(
6819
6939
  mapValues2(results, (val) => val.outputs),
6820
6940
  null,
@@ -7068,7 +7188,9 @@ var set = (program2) => program2.command(
7068
7188
  ` Restarting all functions using ${blue4(args.name)}...`
7069
7189
  ).start();
7070
7190
  const count = await Config2.restart(args.name);
7071
- restarting.succeed(` Restarted ${count} functions`);
7191
+ restarting.succeed(
7192
+ count === 1 ? ` Restarted ${count} function` : ` Restarted ${count} functions`
7193
+ );
7072
7194
  }
7073
7195
  );
7074
7196
 
@@ -7096,22 +7218,22 @@ var update = (program2) => program2.command(
7096
7218
  }),
7097
7219
  async (args) => {
7098
7220
  const { green, yellow } = await import("colorette");
7099
- const fs18 = await import("fs/promises");
7100
- const path18 = await import("path");
7221
+ const fs19 = await import("fs/promises");
7222
+ const path19 = await import("path");
7101
7223
  const { fetch } = await import("undici");
7102
7224
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
7103
7225
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
7104
7226
  async function find2(dir) {
7105
- const children = await fs18.readdir(dir);
7227
+ const children = await fs19.readdir(dir);
7106
7228
  const tasks2 = children.map(async (item) => {
7107
7229
  if (item === "node_modules")
7108
7230
  return [];
7109
7231
  if (/(^|\/)\.[^\/\.]/g.test(item))
7110
7232
  return [];
7111
- const full = path18.join(dir, item);
7233
+ const full = path19.join(dir, item);
7112
7234
  if (item === "package.json")
7113
7235
  return [full];
7114
- const stat = await fs18.stat(full);
7236
+ const stat = await fs19.stat(full);
7115
7237
  if (stat.isDirectory())
7116
7238
  return find2(full);
7117
7239
  return [];
@@ -7125,7 +7247,7 @@ var update = (program2) => program2.command(
7125
7247
  ).then((resp) => resp.json());
7126
7248
  const results = /* @__PURE__ */ new Map();
7127
7249
  const tasks = files.map(async (file) => {
7128
- const data2 = await fs18.readFile(file).then((x) => x.toString()).then(JSON.parse);
7250
+ const data2 = await fs19.readFile(file).then((x) => x.toString()).then(JSON.parse);
7129
7251
  for (const field of FIELDS) {
7130
7252
  const deps = data2[field];
7131
7253
  if (!deps)
@@ -7153,7 +7275,7 @@ var update = (program2) => program2.command(
7153
7275
  deps[pkg] = desired;
7154
7276
  }
7155
7277
  }
7156
- await fs18.writeFile(file, JSON.stringify(data2, null, 2));
7278
+ await fs19.writeFile(file, JSON.stringify(data2, null, 2));
7157
7279
  });
7158
7280
  await Promise.all(tasks);
7159
7281
  if (results.size === 0) {
@@ -7163,7 +7285,7 @@ var update = (program2) => program2.command(
7163
7285
  for (const [file, pkgs] of results.entries()) {
7164
7286
  Colors2.line(
7165
7287
  Colors2.success(`\u2714 `),
7166
- Colors2.bold.dim(path18.relative(project.paths.root, file))
7288
+ Colors2.bold.dim(path19.relative(project.paths.root, file))
7167
7289
  );
7168
7290
  for (const [pkg, version2] of pkgs) {
7169
7291
  Colors2.line(Colors2.dim(` ${pkg}@${version2}`));