sst 2.8.2 → 2.8.4

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.
@@ -10,6 +10,8 @@ export declare const bind: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  command: (string | number)[] | undefined;
15
17
  }>;
@@ -10,4 +10,6 @@ export declare const bootstrap: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  }>;
@@ -10,6 +10,8 @@ export declare const build: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  to: string | undefined;
15
17
  }>;
@@ -0,0 +1,15 @@
1
+ /// <reference types="yargs" />
2
+ import type { Program } from "../program.js";
3
+ export declare const connect: (program: Program) => import("yargs").Argv<{
4
+ stage: string | undefined;
5
+ } & {
6
+ profile: string | undefined;
7
+ } & {
8
+ region: string | undefined;
9
+ } & {
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
15
+ }>;
@@ -0,0 +1,37 @@
1
+ export const connect = (program) => program.command("connect", "", (yargs) => yargs, async (args) => {
2
+ if (!args.future)
3
+ throw new Error("This command is not yet available.");
4
+ const { useAWSClient } = await import("../../credentials.js");
5
+ const { useProject } = await import("../../project.js");
6
+ const { useSTSIdentity } = await import("../../credentials.js");
7
+ const { IAMClient, CreateRoleCommand, AttachRolePolicyCommand } = await import("@aws-sdk/client-iam");
8
+ const client = useAWSClient(IAMClient);
9
+ await client
10
+ .send(new CreateRoleCommand({
11
+ RoleName: "sst",
12
+ AssumeRolePolicyDocument: JSON.stringify({
13
+ Version: "2012-10-17",
14
+ Statement: [
15
+ {
16
+ Effect: "Allow",
17
+ Principal: {
18
+ AWS: "arn:aws:iam::917397401067:root",
19
+ },
20
+ Action: "sts:AssumeRole",
21
+ },
22
+ ],
23
+ }),
24
+ }))
25
+ .catch((e) => {
26
+ if (e.Error.Code === "EntityAlreadyExists")
27
+ return;
28
+ throw e;
29
+ });
30
+ await client.send(new AttachRolePolicyCommand({
31
+ RoleName: "sst",
32
+ PolicyArn: "arn:aws:iam::aws:policy/AdministratorAccess",
33
+ }));
34
+ const project = useProject();
35
+ const identity = await useSTSIdentity();
36
+ console.log(`http://localhost:3000/connect?app=${project.config.name}&stage=${project.config.stage}&aws_account_id=${identity.Account}`);
37
+ });
@@ -10,4 +10,6 @@ export declare const consoleCommand: (program: Program) => Promise<import("yargs
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  }>>;
@@ -10,6 +10,8 @@ export declare const deploy: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  from: string | undefined;
15
17
  } & {
@@ -10,6 +10,8 @@ export declare const dev: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  "increase-timeout": boolean | undefined;
15
17
  }>;
@@ -10,6 +10,8 @@ export declare const diff: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  dev: boolean | undefined;
15
17
  }>;
@@ -10,6 +10,8 @@ export declare const remove: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  from: string | undefined;
15
17
  } & {
@@ -10,6 +10,8 @@ export declare const get: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  name: string;
15
17
  } & {
@@ -10,6 +10,8 @@ export declare const list: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  format: string | undefined;
15
17
  }>;
@@ -10,6 +10,8 @@ export declare const load: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  filename: string;
15
17
  }>;
@@ -10,6 +10,8 @@ export declare const remove: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  name: string;
15
17
  } & {
@@ -10,6 +10,8 @@ export declare const set: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  name: string;
15
17
  } & {
@@ -10,6 +10,8 @@ export declare const telemetry: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  action: string;
15
17
  }>;
@@ -10,6 +10,8 @@ export declare const transform: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  mod: string;
15
17
  }>;
@@ -10,6 +10,8 @@ export declare const update: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  } & {
14
16
  version: string | undefined;
15
17
  }>;
@@ -10,4 +10,6 @@ export declare const version: (program: Program) => import("yargs").Argv<{
10
10
  verbose: boolean | undefined;
11
11
  } & {
12
12
  role: string | undefined;
13
+ } & {
14
+ future: boolean | undefined;
13
15
  }>;
package/cli/program.d.ts CHANGED
@@ -9,5 +9,7 @@ export declare const program: import("yargs").Argv<{
9
9
  verbose: boolean | undefined;
10
10
  } & {
11
11
  role: string | undefined;
12
+ } & {
13
+ future: boolean | undefined;
12
14
  }>;
13
15
  export type Program = typeof program;
package/cli/program.js CHANGED
@@ -21,6 +21,10 @@ export const program = yargs(hideBin(process.argv))
21
21
  .option("role", {
22
22
  type: "string",
23
23
  describe: "ARN of the IAM role to use when invoking AWS",
24
+ })
25
+ .option("future", {
26
+ type: "boolean",
27
+ describe: "DO NOT USE. For enabling untested, experimental features",
24
28
  })
25
29
  .group(["stage", "profile", "region", "role", "verbose", "help"], "Global:")
26
30
  .middleware(async (argv) => {
package/cli/sst.js CHANGED
@@ -25,6 +25,7 @@ import { transform } from "./commands/transform.js";
25
25
  import { diff } from "./commands/diff.js";
26
26
  import { version } from "./commands/version.js";
27
27
  import { telemetry } from "./commands/telemetry.js";
28
+ import { connect } from "./commands/connect.js";
28
29
  bootstrap(program);
29
30
  dev(program);
30
31
  deploy(program);
@@ -38,6 +39,7 @@ consoleCommand(program);
38
39
  diff(program);
39
40
  version(program);
40
41
  telemetry(program);
42
+ connect(program);
41
43
  if ("setSourceMapsEnabled" in process) {
42
44
  // @ts-expect-error
43
45
  process.setSourceMapsEnabled(true);
@@ -153,7 +153,13 @@ export class NextjsSite extends SsrSite {
153
153
  authType: FunctionUrlAuthType.NONE,
154
154
  });
155
155
  const serverOrigin = new HttpOrigin(Fn.parseDomainName(serverFnUrl.url));
156
- const cachePolicy = cdk?.serverCachePolicy ?? this.buildServerCachePolicy();
156
+ const cachePolicy = cdk?.serverCachePolicy ??
157
+ this.buildServerCachePolicy([
158
+ "accept",
159
+ "rsc",
160
+ "next-router-prefetch",
161
+ "next-router-state-tree",
162
+ ]);
157
163
  const originRequestPolicy = this.buildServerOriginRequestPolicy();
158
164
  const serverBehavior = this.buildServerBehaviorForRegional(serverOrigin, cachePolicy, originRequestPolicy);
159
165
  return new Distribution(this, "Distribution", {
@@ -178,7 +184,13 @@ export class NextjsSite extends SsrSite {
178
184
  const { cdk } = this.props;
179
185
  const cfDistributionProps = cdk?.distribution || {};
180
186
  const s3Origin = new S3Origin(this.cdk.bucket);
181
- const cachePolicy = cdk?.serverCachePolicy ?? this.buildServerCachePolicy();
187
+ const cachePolicy = cdk?.serverCachePolicy ??
188
+ this.buildServerCachePolicy([
189
+ "accept",
190
+ "rsc",
191
+ "next-router-prefetch",
192
+ "next-router-state-tree",
193
+ ]);
182
194
  const originRequestPolicy = this.buildServerOriginRequestPolicy();
183
195
  const functionVersion = this.serverLambdaForEdge.currentVersion;
184
196
  const serverBehavior = this.buildServerBehaviorForEdge(functionVersion, s3Origin, cachePolicy, originRequestPolicy);
@@ -276,7 +276,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
276
276
  function: CfFunction;
277
277
  }[];
278
278
  private buildStaticFileBehaviors;
279
- protected buildServerCachePolicy(): CachePolicy;
279
+ protected buildServerCachePolicy(allowedHeaders?: string[]): CachePolicy;
280
280
  protected buildServerOriginRequestPolicy(): import("aws-cdk-lib/aws-cloudfront").IOriginRequestPolicy;
281
281
  private createCloudFrontInvalidation;
282
282
  protected validateCustomDomainSettings(): void;
@@ -608,10 +608,12 @@ function handler(event) {
608
608
  }
609
609
  return staticsBehaviours;
610
610
  }
611
- buildServerCachePolicy() {
611
+ buildServerCachePolicy(allowedHeaders) {
612
612
  return new CachePolicy(this, "ServerCache", {
613
613
  queryStringBehavior: CacheQueryStringBehavior.all(),
614
- headerBehavior: CacheHeaderBehavior.none(),
614
+ headerBehavior: allowedHeaders && allowedHeaders.length > 0
615
+ ? CacheHeaderBehavior.allowList(...allowedHeaders)
616
+ : CacheHeaderBehavior.none(),
615
617
  cookieBehavior: CacheCookieBehavior.all(),
616
618
  defaultTtl: CdkDuration.days(0),
617
619
  maxTtl: CdkDuration.days(365),
@@ -9,7 +9,7 @@ export type JobType = {
9
9
  [T in keyof JobResources]: ReturnType<typeof JobControl<T>>;
10
10
  };
11
11
  export declare const Job: JobType;
12
- declare function JobControl<Name extends keyof JobResources>(name: Name): {
12
+ declare function JobControl<Name extends keyof JobResources>(name: Name, vars: Record<string, string>): {
13
13
  run(props: JobRunProps<Name>): Promise<void>;
14
14
  };
15
15
  /**
package/node/job/index.js CHANGED
@@ -5,17 +5,16 @@ export const Job = /* @__PURE__ */ (() => {
5
5
  const result = createProxy("Job");
6
6
  const vars = getVariables2("Job");
7
7
  Object.keys(vars).forEach((name) => {
8
- // @ts-ignore
9
- result[name] = JobControl(name);
8
+ // @ts-expect-error
9
+ result[name] = JobControl(name, vars[name]);
10
10
  });
11
11
  return result;
12
12
  })();
13
- function JobControl(name) {
13
+ function JobControl(name, vars) {
14
14
  return {
15
15
  async run(props) {
16
16
  // Handle job permission not granted
17
- // @ts-ignore
18
- const functionName = jobData[name].functionName;
17
+ const functionName = vars.functionName;
19
18
  // Invoke the Lambda function
20
19
  const ret = await lambda.send(new InvokeCommand({
21
20
  FunctionName: functionName,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.8.2",
4
+ "version": "2.8.4",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },