sst 2.0.0-rc.22 → 2.0.0-rc.23

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.
@@ -9,6 +9,7 @@ import { usePothosBuilder } from "./plugins/pothos.js";
9
9
  import { useKyselyTypeGenerator } from "./plugins/kysely.js";
10
10
  import { useRDSWarmer } from "./plugins/warmer.js";
11
11
  import { useProject } from "../../project.js";
12
+ import { useMetadata } from "../../stacks/metadata.js";
12
13
  export const dev = (program) => program.command(["start", "dev"], "Work on your SST app locally", (yargs) => yargs.option("fullscreen", {
13
14
  type: "boolean",
14
15
  describe: "Disable full screen UI",
@@ -178,6 +179,7 @@ export const dev = (program) => program.command(["start", "dev"], "Work on your
178
179
  useIOTBridge(),
179
180
  useRuntimeServer(),
180
181
  usePothosBuilder(),
182
+ useMetadata(),
181
183
  useKyselyTypeGenerator(),
182
184
  useRDSWarmer(),
183
185
  useFunctionLogger(),
@@ -6,6 +6,8 @@ import { DatabaseMetadata, EnumCollection, PostgresDialect, Serializer, Transfor
6
6
  import { Context } from "../../../context/context.js";
7
7
  import { useBus } from "../../../bus.js";
8
8
  import { useProject } from "../../../project.js";
9
+ import { Logger } from "../../../logger.js";
10
+ import { useAWSCredentials, } from "../../../credentials.js";
9
11
  export const useKyselyTypeGenerator = Context.memo(async () => {
10
12
  let databases = [];
11
13
  const bus = useBus();
@@ -13,6 +15,8 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
13
15
  async function generate(db) {
14
16
  if (!db.types)
15
17
  return;
18
+ Logger.debug("Generating types for", db.migratorID);
19
+ const credentials = await useAWSCredentials();
16
20
  const k = new Kysely({
17
21
  dialect: new DataApiDialect({
18
22
  mode: db.engine.includes("postgres") ? "postgres" : "mysql",
@@ -22,6 +26,7 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
22
26
  database: db.defaultDatabaseName,
23
27
  client: new RDSDataService({
24
28
  region: project.config.region,
29
+ credentials,
25
30
  }),
26
31
  },
27
32
  }),
@@ -67,13 +72,13 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
67
72
  await fs.writeFile(db.types.path, data);
68
73
  }
69
74
  bus.subscribe("stacks.metadata", (evt) => {
70
- databases = Object.values(evt.properties)
71
- .flat()
75
+ const constructs = Object.values(evt.properties).flat();
76
+ databases = constructs
72
77
  .filter((c) => c.type === "RDS")
73
78
  .filter((c) => c.data.migrator)
74
79
  .filter((c) => c.data.types)
75
80
  .map((c) => ({
76
- migratorID: evt.properties.metadata.find((fn) => fn.addr == c.data.migrator?.node).addr,
81
+ migratorID: constructs.find((fn) => fn.addr == c.data.migrator?.node).addr,
77
82
  clusterArn: c.data.clusterArn,
78
83
  types: c.data.types,
79
84
  engine: c.data.engine,
@@ -83,9 +88,12 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
83
88
  databases.map((db) => generate(db));
84
89
  });
85
90
  bus.subscribe("function.success", async (evt) => {
91
+ if (!evt.properties.body?.results)
92
+ return;
86
93
  const db = databases.find((db) => db.migratorID === evt.properties.functionID);
87
94
  if (!db)
88
95
  return;
89
96
  generate(db);
90
97
  });
98
+ Logger.debug("Loaded kyseley type generator");
91
99
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.22",
3
+ "version": "2.0.0-rc.23",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/sst.mjs CHANGED
@@ -5429,6 +5429,8 @@ var usePothosBuilder = Context.memo(() => {
5429
5429
  init_context();
5430
5430
  init_bus();
5431
5431
  init_project();
5432
+ init_logger();
5433
+ init_credentials();
5432
5434
  import { Kysely } from "kysely";
5433
5435
  import { DataApiDialect } from "kysely-data-api";
5434
5436
  import RDSDataService from "aws-sdk/clients/rdsdataservice.js";
@@ -5447,6 +5449,8 @@ var useKyselyTypeGenerator = Context.memo(async () => {
5447
5449
  async function generate2(db) {
5448
5450
  if (!db.types)
5449
5451
  return;
5452
+ Logger.debug("Generating types for", db.migratorID);
5453
+ const credentials = await useAWSCredentials();
5450
5454
  const k = new Kysely({
5451
5455
  dialect: new DataApiDialect({
5452
5456
  mode: db.engine.includes("postgres") ? "postgres" : "mysql",
@@ -5455,7 +5459,8 @@ var useKyselyTypeGenerator = Context.memo(async () => {
5455
5459
  resourceArn: db.clusterArn,
5456
5460
  database: db.defaultDatabaseName,
5457
5461
  client: new RDSDataService({
5458
- region: project.config.region
5462
+ region: project.config.region,
5463
+ credentials
5459
5464
  })
5460
5465
  }
5461
5466
  })
@@ -5499,8 +5504,9 @@ var useKyselyTypeGenerator = Context.memo(async () => {
5499
5504
  await fs16.writeFile(db.types.path, data2);
5500
5505
  }
5501
5506
  bus.subscribe("stacks.metadata", (evt) => {
5502
- databases = Object.values(evt.properties).flat().filter((c) => c.type === "RDS").filter((c) => c.data.migrator).filter((c) => c.data.types).map((c) => ({
5503
- migratorID: evt.properties.metadata.find(
5507
+ const constructs = Object.values(evt.properties).flat();
5508
+ databases = constructs.filter((c) => c.type === "RDS").filter((c) => c.data.migrator).filter((c) => c.data.types).map((c) => ({
5509
+ migratorID: constructs.find(
5504
5510
  (fn) => fn.addr == c.data.migrator?.node
5505
5511
  ).addr,
5506
5512
  clusterArn: c.data.clusterArn,
@@ -5512,6 +5518,8 @@ var useKyselyTypeGenerator = Context.memo(async () => {
5512
5518
  databases.map((db) => generate2(db));
5513
5519
  });
5514
5520
  bus.subscribe("function.success", async (evt) => {
5521
+ if (!evt.properties.body?.results)
5522
+ return;
5515
5523
  const db = databases.find(
5516
5524
  (db2) => db2.migratorID === evt.properties.functionID
5517
5525
  );
@@ -5519,6 +5527,7 @@ var useKyselyTypeGenerator = Context.memo(async () => {
5519
5527
  return;
5520
5528
  generate2(db);
5521
5529
  });
5530
+ Logger.debug("Loaded kyseley type generator");
5522
5531
  });
5523
5532
 
5524
5533
  // src/cli/commands/plugins/warmer.ts
@@ -5556,6 +5565,7 @@ var useRDSWarmer = Context.memo(async () => {
5556
5565
 
5557
5566
  // src/cli/commands/dev.tsx
5558
5567
  init_project();
5568
+ init_metadata();
5559
5569
  var dev = (program2) => program2.command(
5560
5570
  ["start", "dev"],
5561
5571
  "Work on your SST app locally",
@@ -5756,6 +5766,7 @@ var dev = (program2) => program2.command(
5756
5766
  useIOTBridge2(),
5757
5767
  useRuntimeServer2(),
5758
5768
  usePothosBuilder(),
5769
+ useMetadata(),
5759
5770
  useKyselyTypeGenerator(),
5760
5771
  useRDSWarmer(),
5761
5772
  useFunctionLogger(),