sst 3.9.28 → 3.9.29

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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Creates an OpenControl tool that lists the resources in the current SST app. You can add
3
+ * this tool to your OpenControl app by passing it to the `tools` option when creating an
4
+ * OpenControl app.
5
+ *
6
+ * @example
7
+ * ```js title="src/app.ts"
8
+ * import { create } from "opencontrol";
9
+ * import { tools } from "sst/opencontrol";
10
+ *
11
+ * const app = create({
12
+ * key: process.env.OPENCONTROL_KEY,
13
+ * tools: [...tools],
14
+ * });
15
+ * ```
16
+ */
17
+ export declare const tools: import("opencontrol/tool").Tool<any>[];
@@ -0,0 +1,72 @@
1
+ import { tool } from "opencontrol/tool";
2
+ import { client } from "../aws/client.js";
3
+ import { Resource } from "../resource.js";
4
+ /**
5
+ * Creates an OpenControl tool that lists the resources in the current SST app. You can add
6
+ * this tool to your OpenControl app by passing it to the `tools` option when creating an
7
+ * OpenControl app.
8
+ *
9
+ * @example
10
+ * ```js title="src/app.ts"
11
+ * import { create } from "opencontrol";
12
+ * import { tools } from "sst/opencontrol";
13
+ *
14
+ * const app = create({
15
+ * key: process.env.OPENCONTROL_KEY,
16
+ * tools: [...tools],
17
+ * });
18
+ * ```
19
+ */
20
+ export const tools = [
21
+ tool({
22
+ name: "sst",
23
+ description: "Get the resources in the current SST app",
24
+ async run() {
25
+ const c = await client();
26
+ const stateBucket = await getStateBucket();
27
+ if (!stateBucket)
28
+ return {
29
+ error: "Failed to find the SST state bucket in user's AWS account. Ask the user to make sure the AWS account has been bootstrapped with SST.",
30
+ };
31
+ const state = await getStateFile();
32
+ if (!state)
33
+ return {
34
+ error: "Failed to find the SST state file in user's AWS account.",
35
+ };
36
+ const resources = state["checkpoint"]["latest"]["resources"];
37
+ return resources
38
+ .filter((r) => r.type !== "sst:sst:LinkRef" &&
39
+ !r.type.startsWith("pulumi:provider:"))
40
+ .map((r) => ({
41
+ urn: r.urn,
42
+ type: r.type,
43
+ id: r.id,
44
+ parent: r.parent,
45
+ }));
46
+ async function getStateBucket() {
47
+ const res = await c.fetch(`https://ssm.${c.region}.amazonaws.com/`, {
48
+ method: "POST",
49
+ headers: {
50
+ "X-Amz-Target": "AmazonSSM.GetParameter",
51
+ "Content-Type": "application/x-amz-json-1.1",
52
+ },
53
+ body: JSON.stringify({
54
+ Name: "/sst/bootstrap",
55
+ }),
56
+ });
57
+ if (!res.ok)
58
+ return;
59
+ const data = (await res.json());
60
+ return JSON.parse(data.Parameter.Value)["state"];
61
+ }
62
+ async function getStateFile() {
63
+ const res = await c.fetch(`https://${stateBucket}.s3.${c.region}.amazonaws.com/app/${Resource.App.name}/${Resource.App.stage}.json`, {
64
+ method: "GET",
65
+ });
66
+ if (!res.ok)
67
+ return;
68
+ return (await res.json());
69
+ }
70
+ },
71
+ }),
72
+ ];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "sst",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
- "version": "3.9.28",
6
+ "version": "3.9.29",
7
7
  "main": "./dist/index.js",
8
8
  "repository": {
9
9
  "type": "git",
@@ -41,15 +41,16 @@
41
41
  "sst": "./bin/sst.mjs"
42
42
  },
43
43
  "optionalDependencies": {
44
- "sst-linux-x64": "3.9.28",
45
- "sst-linux-x86": "3.9.28",
46
- "sst-linux-arm64": "3.9.28",
47
- "sst-darwin-x64": "3.9.28",
48
- "sst-darwin-arm64": "3.9.28"
44
+ "sst-linux-x64": "3.9.29",
45
+ "sst-linux-x86": "3.9.29",
46
+ "sst-linux-arm64": "3.9.29",
47
+ "sst-darwin-x64": "3.9.29",
48
+ "sst-darwin-arm64": "3.9.29"
49
49
  },
50
50
  "dependencies": {
51
51
  "aws4fetch": "^1.0.18",
52
52
  "jose": "5.2.3",
53
+ "opencontrol": "0.0.6",
53
54
  "openid-client": "5.6.4"
54
55
  }
55
56
  }