sst 2.1.16 → 2.1.18

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.
Files changed (53) hide show
  1. package/bootstrap.js +1 -1
  2. package/cli/commands/bind.js +1 -1
  3. package/cli/commands/env.js +1 -1
  4. package/constructs/App.js +3 -3
  5. package/constructs/AstroSite.js +8 -41
  6. package/constructs/EdgeFunction.d.ts +19 -21
  7. package/constructs/EdgeFunction.js +235 -167
  8. package/constructs/Function.d.ts +1 -1
  9. package/constructs/Function.js +3 -3
  10. package/constructs/Job.js +2 -2
  11. package/constructs/NextjsSite.d.ts +6 -5
  12. package/constructs/NextjsSite.js +5 -3
  13. package/constructs/RDS.js +1 -1
  14. package/constructs/RemixSite.d.ts +2 -3
  15. package/constructs/RemixSite.js +42 -71
  16. package/constructs/SolidStartSite.js +8 -41
  17. package/constructs/SsrFunction.d.ts +9 -6
  18. package/constructs/SsrFunction.js +61 -50
  19. package/constructs/SsrSite.d.ts +6 -4
  20. package/constructs/SsrSite.js +0 -4
  21. package/constructs/Stack.js +2 -1
  22. package/constructs/future/Auth.d.ts +79 -0
  23. package/constructs/future/Auth.js +116 -0
  24. package/constructs/future/index.d.ts +1 -0
  25. package/constructs/future/index.js +1 -0
  26. package/context/handler.d.ts +1 -1
  27. package/node/api/index.d.ts +27 -4
  28. package/node/api/index.js +64 -2
  29. package/node/auth/index.d.ts +3 -0
  30. package/node/auth/index.js +3 -0
  31. package/node/future/auth/adapter/adapter.d.ts +10 -0
  32. package/node/future/auth/adapter/adapter.js +1 -0
  33. package/node/future/auth/adapter/github.d.ts +16 -0
  34. package/node/future/auth/adapter/github.js +22 -0
  35. package/node/future/auth/adapter/google.d.ts +20 -0
  36. package/node/future/auth/adapter/google.js +10 -0
  37. package/node/future/auth/adapter/link.d.ts +11 -0
  38. package/node/future/auth/adapter/link.js +48 -0
  39. package/node/future/auth/adapter/oauth.d.ts +34 -0
  40. package/node/future/auth/adapter/oauth.js +66 -0
  41. package/node/future/auth/adapter/oidc.d.ts +26 -0
  42. package/node/future/auth/adapter/oidc.js +62 -0
  43. package/node/future/auth/handler.d.ts +18 -0
  44. package/node/future/auth/handler.js +189 -0
  45. package/node/future/auth/index.d.ts +10 -0
  46. package/node/future/auth/index.js +10 -0
  47. package/node/future/auth/session.d.ts +46 -0
  48. package/node/future/auth/session.js +99 -0
  49. package/node/util/index.js +1 -1
  50. package/package.json +4 -1
  51. package/runtime/handlers/node.js +1 -1
  52. package/sst.mjs +4 -4
  53. package/support/nodejs-runtime/index.mjs +62 -14629
package/bootstrap.js CHANGED
@@ -190,7 +190,7 @@ async function bootstrapCDK() {
190
190
  AWS_PROFILE: profile,
191
191
  },
192
192
  stdio: "pipe",
193
- shell: process.env.SHELL || true,
193
+ shell: true,
194
194
  });
195
195
  let stderr = "";
196
196
  proc.stdout.on("data", (data) => {
@@ -24,7 +24,7 @@ export const bind = (program) => program
24
24
  AWS_REGION: project.config.region,
25
25
  },
26
26
  stdio: "inherit",
27
- shell: process.env.SHELL || true,
27
+ shell: true,
28
28
  });
29
29
  process.exitCode = result.status || undefined;
30
30
  })
@@ -39,7 +39,7 @@ export const env = (program) => program
39
39
  AWS_REGION: project.config.region,
40
40
  },
41
41
  stdio: "inherit",
42
- shell: process.env.SHELL || true,
42
+ shell: true,
43
43
  });
44
44
  process.exitCode = result.status || undefined;
45
45
  break;
package/constructs/App.js CHANGED
@@ -247,7 +247,7 @@ export class App extends cdk.App {
247
247
  if (!isSSTConstruct(c)) {
248
248
  return;
249
249
  }
250
- if (c instanceof Function && c._disableBind) {
250
+ if (c instanceof Function && c._doNotAllowOthersToBind) {
251
251
  return;
252
252
  }
253
253
  bindParameters(c);
@@ -370,7 +370,7 @@ export class App extends cdk.App {
370
370
  if (!isSSTConstruct(c)) {
371
371
  return;
372
372
  }
373
- if (c instanceof Function && c._disableBind) {
373
+ if (c instanceof Function && c._doNotAllowOthersToBind) {
374
374
  return;
375
375
  }
376
376
  const className = c.constructor.name;
@@ -449,7 +449,7 @@ export class App extends cdk.App {
449
449
  if (!isSSTConstruct(c)) {
450
450
  return;
451
451
  }
452
- if (c instanceof Function && c._disableBind) {
452
+ if (c instanceof Function && c._doNotAllowOthersToBind) {
453
453
  return;
454
454
  }
455
455
  const binding = bindType(c);
@@ -1,13 +1,9 @@
1
1
  import fs from "fs";
2
- import url from "url";
3
2
  import path from "path";
4
- import { buildSync } from "esbuild";
5
3
  import { Architecture } from "aws-cdk-lib/aws-lambda";
6
4
  import { SsrSite } from "./SsrSite.js";
7
5
  import { Function } from "./Function.js";
8
- import { useProject } from "../project.js";
9
6
  import { EdgeFunction } from "./EdgeFunction.js";
10
- const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
11
7
  /**
12
8
  * The `AstroSite` construct is a higher level CDK construct that makes it easy to create a Astro app.
13
9
  * @example
@@ -36,12 +32,10 @@ export class AstroSite extends SsrSite {
36
32
  super.validateBuildOutput();
37
33
  }
38
34
  createFunctionForRegional() {
39
- const { runtime, memorySize, timeout, environment, bind, cdk } = this.props;
40
- // Create function
35
+ const { runtime, timeout, memorySize, permissions, environment, bind, cdk, } = this.props;
41
36
  const fn = new Function(this, `ServerFunction`, {
42
37
  description: "Server handler",
43
38
  handler: path.join(this.props.path, "dist", "server", "entry.handler"),
44
- bind,
45
39
  logRetention: "three_days",
46
40
  runtime,
47
41
  memorySize,
@@ -49,53 +43,26 @@ export class AstroSite extends SsrSite {
49
43
  nodejs: {
50
44
  format: "esm",
51
45
  },
46
+ bind,
52
47
  environment,
48
+ permissions,
53
49
  ...cdk?.server,
54
50
  architecture: cdk?.server?.architecture === Architecture.ARM_64 ? "arm_64" : "x86_64",
55
51
  });
56
- fn._disableBind = true;
52
+ fn._doNotAllowOthersToBind = true;
57
53
  return fn;
58
54
  }
59
55
  createFunctionForEdge() {
60
- const { runtime, timeout, memorySize, permissions, environment } = this.props;
61
- // Create a directory that we will use to create the bundled version
62
- // of the "core server build" along with our custom Lamba server handler.
63
- const outputPath = path.resolve(path.join(useProject().paths.artifacts, `AstroSiteFunction-${this.node.id}-${this.node.addr}`));
64
- const result = buildSync({
65
- entryPoints: [
66
- path.join(this.props.path, this.buildConfig.serverBuildOutputFile),
67
- ],
68
- target: "esnext",
69
- format: "esm",
70
- platform: "node",
71
- metafile: true,
72
- bundle: true,
73
- write: true,
74
- allowOverwrite: true,
75
- outfile: path.join(outputPath, "entry.mjs"),
76
- banner: {
77
- js: [
78
- `import { createRequire as topLevelCreateRequire } from 'module';`,
79
- `const require = topLevelCreateRequire(import.meta.url);`,
80
- ].join(""),
81
- },
82
- });
83
- if (result.errors.length > 0) {
84
- result.errors.forEach((error) => console.error(error));
85
- throw new Error(`There was a problem bundling the function code for the ${this.id} AstroSite.`);
86
- }
87
- // Create package.json
88
- fs.writeFileSync(path.join(outputPath, "package.json"), `{"type":"module"}`);
89
- // Create function
56
+ const { runtime, timeout, memorySize, bind, permissions, environment } = this.props;
90
57
  return new EdgeFunction(this, `Server`, {
91
58
  scopeOverride: this,
92
- bundlePath: outputPath,
93
- handler: "entry.handler",
59
+ handler: path.join(this.props.path, "dist", "server", "entry.handler"),
94
60
  runtime,
95
61
  timeout,
96
62
  memorySize,
97
- permissions,
63
+ bind,
98
64
  environment,
65
+ permissions,
99
66
  format: "esm",
100
67
  });
101
68
  }
@@ -1,25 +1,22 @@
1
+ import { BuildOptions } from "esbuild";
1
2
  import { Construct, IConstruct } from "constructs";
2
3
  import { Role } from "aws-cdk-lib/aws-iam";
3
- import * as lambda from "aws-cdk-lib/aws-lambda";
4
+ import { IVersion } from "aws-cdk-lib/aws-lambda";
5
+ import { SSTConstruct } from "./Construct.js";
4
6
  import { Size } from "./util/size.js";
5
7
  import { Duration } from "./util/duration.js";
6
8
  import { Permissions } from "./util/permission.js";
7
9
  export interface EdgeFunctionProps {
8
- bundlePath: string;
10
+ bundle?: string;
9
11
  handler: string;
10
- runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x";
12
+ runtime: "nodejs14.x" | "nodejs16.x" | "nodejs18.x";
11
13
  timeout: number | Duration;
12
14
  memorySize: number | Size;
13
15
  permissions?: Permissions;
14
- format: "cjs" | "esm";
15
16
  environment?: Record<string, string>;
16
- /**
17
- * This is intended to be used internally by SST to make constructs
18
- * backwards compatible when the hirechical structure of the constructs
19
- * changes. When the hirerchical structure changes, the child AWS
20
- * resources' logical ID will change. And CloudFormation will recreate
21
- * them.
22
- */
17
+ bind?: SSTConstruct[];
18
+ esbuild?: BuildOptions;
19
+ format: "cjs" | "esm";
23
20
  scopeOverride?: IConstruct;
24
21
  }
25
22
  export declare class EdgeFunction extends Construct {
@@ -27,20 +24,21 @@ export declare class EdgeFunction extends Construct {
27
24
  functionArn: string;
28
25
  private scope;
29
26
  private versionId;
27
+ private bindingEnvs;
30
28
  private props;
31
29
  constructor(scope: Construct, id: string, props: EdgeFunctionProps);
32
- get currentVersion(): lambda.IVersion;
30
+ get currentVersion(): IVersion;
33
31
  attachPermissions(permissions: Permissions): void;
34
- private wrapFunctionCode;
35
- private createAsset;
32
+ private buildBundle;
33
+ private updateBundleWithEnvWrapper;
34
+ private bind;
35
+ private createCodeAsset;
36
+ private createCodeReplacer;
36
37
  private createRole;
37
- private createFunction;
38
- private createLambdaCodeReplacer;
39
- private createSingletonBucketCR;
40
- private createFunctionCR;
41
- private createVersionCR;
42
- private getLambdaContentReplaceValues;
43
- private updateVersionLogicalId;
38
+ private createSingletonBucketInUsEast1;
39
+ private createFunctionInUsEast1;
40
+ private createVersionInUsEast1;
41
+ private getHandlerExtension;
44
42
  private trimFromStart;
45
43
  private calculateHash;
46
44
  }