sst 2.26.2 → 2.26.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.
Files changed (46) hide show
  1. package/cli/commands/types.js +3 -7
  2. package/constructs/Api.js +2 -0
  3. package/constructs/ApiGatewayV1Api.js +2 -0
  4. package/constructs/App.d.ts +3 -1
  5. package/constructs/App.js +63 -62
  6. package/constructs/AppSyncApi.js +2 -0
  7. package/constructs/AstroSite.d.ts +50 -11
  8. package/constructs/AstroSite.js +69 -51
  9. package/constructs/Auth.js +2 -0
  10. package/constructs/Bucket.js +2 -0
  11. package/constructs/Cognito.js +2 -0
  12. package/constructs/Cron.js +2 -0
  13. package/constructs/EdgeFunction.d.ts +3 -4
  14. package/constructs/EdgeFunction.js +13 -9
  15. package/constructs/EventBus.js +2 -0
  16. package/constructs/Function.d.ts +5 -1
  17. package/constructs/Function.js +8 -6
  18. package/constructs/Job.js +3 -3
  19. package/constructs/KinesisStream.js +2 -0
  20. package/constructs/NextjsSite.d.ts +84 -22
  21. package/constructs/NextjsSite.js +150 -254
  22. package/constructs/Parameter.js +2 -0
  23. package/constructs/Queue.js +2 -0
  24. package/constructs/RDS.js +5 -4
  25. package/constructs/RemixSite.d.ts +65 -11
  26. package/constructs/RemixSite.js +112 -71
  27. package/constructs/Script.js +2 -0
  28. package/constructs/Secret.js +2 -0
  29. package/constructs/Service.js +4 -3
  30. package/constructs/SolidStartSite.d.ts +48 -9
  31. package/constructs/SolidStartSite.js +68 -40
  32. package/constructs/SsrFunction.d.ts +4 -5
  33. package/constructs/SsrFunction.js +18 -13
  34. package/constructs/SsrSite.d.ts +74 -68
  35. package/constructs/SsrSite.js +657 -682
  36. package/constructs/StaticSite.js +2 -0
  37. package/constructs/SvelteKitSite.d.ts +80 -12
  38. package/constructs/SvelteKitSite.js +90 -64
  39. package/constructs/Table.js +2 -0
  40. package/constructs/Topic.js +2 -0
  41. package/constructs/WebSocketApi.js +2 -0
  42. package/constructs/deprecated/NextjsSite.js +1 -0
  43. package/constructs/future/Auth.js +1 -0
  44. package/package.json +1 -1
  45. package/support/remix-site-function/edge-server.js +2 -4
  46. package/support/remix-site-function/regional-server.js +2 -4
@@ -59,6 +59,7 @@ export class StaticSite extends Construct {
59
59
  if (this.doNotDeploy) {
60
60
  // @ts-ignore
61
61
  this.bucket = this.distribution = null;
62
+ app.registerTypes(this);
62
63
  return;
63
64
  }
64
65
  this.bucket = this.createS3Bucket();
@@ -75,6 +76,7 @@ export class StaticSite extends Construct {
75
76
  // Invalidate CloudFront
76
77
  this.distribution.createInvalidation(this.generateInvalidationId(assets));
77
78
  });
79
+ app.registerTypes(this);
78
80
  }
79
81
  /**
80
82
  * The CloudFront URL of the website.
@@ -1,6 +1,4 @@
1
1
  import { SsrSite } from "./SsrSite.js";
2
- import { SsrFunction } from "./SsrFunction.js";
3
- import { EdgeFunction } from "./EdgeFunction.js";
4
2
  /**
5
3
  * The `SvelteKitSite` construct is a higher level CDK construct that makes it easy to create a SvelteKit app.
6
4
  * @example
@@ -13,17 +11,87 @@ import { EdgeFunction } from "./EdgeFunction.js";
13
11
  * ```
14
12
  */
15
13
  export declare class SvelteKitSite extends SsrSite {
16
- protected initBuildConfig(): {
17
- typesPath: string;
18
- serverBuildOutputFile: string;
19
- serverCFFunctionInjection: string;
20
- clientBuildOutputDir: string;
21
- clientBuildVersionedSubDir: string;
22
- prerenderedBuildOutputDir: string;
14
+ protected typesPath: string;
15
+ protected plan(): {
16
+ cloudFrontFunctions?: {
17
+ serverCfFunction: {
18
+ constructId: string;
19
+ injections: string[];
20
+ };
21
+ } | undefined;
22
+ edgeFunctions?: {
23
+ edgeServer: {
24
+ constructId: string;
25
+ function: {
26
+ description: string;
27
+ handler: string;
28
+ nodejs: {
29
+ esbuild: {
30
+ minify: boolean;
31
+ sourcemap: boolean | "inline";
32
+ define: {
33
+ "process.env.SST_DEBUG": string;
34
+ };
35
+ };
36
+ };
37
+ copyFiles: {
38
+ from: string;
39
+ to: string;
40
+ }[];
41
+ scopeOverride: SvelteKitSite;
42
+ };
43
+ };
44
+ } | undefined;
45
+ origins: {
46
+ s3: {
47
+ type: "s3";
48
+ copy: ({
49
+ from: string;
50
+ to: string;
51
+ cached: true;
52
+ versionedSubDir: string;
53
+ } | {
54
+ from: string;
55
+ to: string;
56
+ cached: false;
57
+ versionedSubDir?: undefined;
58
+ })[];
59
+ };
60
+ regionalServer?: {
61
+ type: "function";
62
+ constructId: string;
63
+ function: {
64
+ description: string;
65
+ handler: string;
66
+ nodejs: {
67
+ esbuild: {
68
+ minify: boolean;
69
+ sourcemap: boolean | "inline";
70
+ define: {
71
+ "process.env.SST_DEBUG": string;
72
+ };
73
+ };
74
+ };
75
+ copyFiles: {
76
+ from: string;
77
+ to: string;
78
+ }[];
79
+ };
80
+ } | undefined;
81
+ };
82
+ behaviors: {
83
+ cacheType: "server" | "static";
84
+ pattern?: string | undefined;
85
+ origin: "s3" | "regionalServer";
86
+ cfFunction?: "serverCfFunction" | undefined;
87
+ edgeFunction?: "edgeServer" | undefined;
88
+ }[];
89
+ cachePolicyAllowedHeaders?: string[] | undefined;
90
+ buildId?: string | undefined;
91
+ warmerConfig?: {
92
+ function: string;
93
+ } | undefined;
23
94
  };
24
- protected createFunctionForRegional(): SsrFunction;
25
- protected createFunctionForEdge(): EdgeFunction;
26
- protected generateBuildId(): any;
27
95
  getConstructMetadata(): {
28
96
  data: {
29
97
  mode: "placeholder" | "deployed";
@@ -1,8 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import { SsrSite } from "./SsrSite.js";
4
- import { SsrFunction } from "./SsrFunction.js";
5
- import { EdgeFunction } from "./EdgeFunction.js";
6
4
  /**
7
5
  * The `SvelteKitSite` construct is a higher level CDK construct that makes it easy to create a SvelteKit app.
8
6
  * @example
@@ -15,88 +13,116 @@ import { EdgeFunction } from "./EdgeFunction.js";
15
13
  * ```
16
14
  */
17
15
  export class SvelteKitSite extends SsrSite {
18
- initBuildConfig() {
19
- return {
20
- typesPath: "src",
21
- serverBuildOutputFile: ".svelte-kit/svelte-kit-sst/server/lambda-handler/index.js",
22
- // Note: form action requests contain "/" in request query string
23
- // ie. POST request with query string "?/action"
24
- // CloudFront does not allow query string with "/". It needs to be encoded.
25
- serverCFFunctionInjection: `
26
- for (var key in request.querystring) {
27
- if (key.includes("/")) {
28
- request.querystring[encodeURIComponent(key)] = request.querystring[key];
29
- delete request.querystring[key];
30
- }
31
- }
32
- `,
33
- clientBuildOutputDir: ".svelte-kit/svelte-kit-sst/client",
34
- clientBuildVersionedSubDir: "_app",
35
- prerenderedBuildOutputDir: ".svelte-kit/svelte-kit-sst/prerendered",
36
- };
37
- }
38
- createFunctionForRegional() {
39
- const { runtime, timeout, memorySize, permissions, environment, nodejs, bind, cdk, } = this.props;
40
- return new SsrFunction(this, `ServerFunction`, {
16
+ typesPath = "src";
17
+ plan() {
18
+ const { path: sitePath, edge } = this.props;
19
+ const serverDir = ".svelte-kit/svelte-kit-sst/server";
20
+ const clientDir = ".svelte-kit/svelte-kit-sst/client";
21
+ const prerenderedDir = ".svelte-kit/svelte-kit-sst/prerendered";
22
+ const serverConfig = {
41
23
  description: "Server handler for SvelteKit",
42
- handler: path.join(this.props.path, ".svelte-kit", "svelte-kit-sst", "server", "lambda-handler", "index.handler"),
43
- runtime,
44
- memorySize,
45
- timeout,
46
- bind,
47
- environment,
48
- permissions,
24
+ handler: path.join(sitePath, serverDir, "lambda-handler", "index.handler"),
49
25
  nodejs: {
50
- format: "esm",
51
- ...nodejs,
52
26
  esbuild: {
53
27
  minify: process.env.SST_DEBUG ? false : true,
54
28
  sourcemap: process.env.SST_DEBUG ? "inline" : false,
55
29
  define: {
56
30
  "process.env.SST_DEBUG": process.env.SST_DEBUG ? "true" : "false",
57
31
  },
58
- ...nodejs?.esbuild,
59
32
  },
60
33
  },
61
34
  copyFiles: [
62
35
  {
63
- from: path.join(this.props.path, ".svelte-kit", "svelte-kit-sst", "prerendered"),
36
+ from: path.join(sitePath, prerenderedDir),
64
37
  to: "prerendered",
65
38
  },
66
39
  ],
67
- ...cdk?.server,
68
- });
69
- }
70
- createFunctionForEdge() {
71
- const { runtime, timeout, memorySize, bind, permissions, environment, nodejs, } = this.props;
72
- return new EdgeFunction(this, `Server`, {
73
- scopeOverride: this,
74
- handler: path.join(this.props.path, ".svelte-kit", "svelte-kit-sst", "server", "lambda-handler", "index.handler"),
75
- runtime,
76
- timeout,
77
- memorySize,
78
- bind,
79
- environment,
80
- permissions,
81
- nodejs: {
82
- format: "esm",
83
- ...nodejs,
84
- esbuild: {
85
- minify: process.env.SST_DEBUG ? false : true,
86
- sourcemap: process.env.SST_DEBUG ? "inline" : false,
87
- define: {
88
- "process.env.SST_DEBUG": process.env.SST_DEBUG ? "true" : "false",
40
+ };
41
+ return this.validatePlan({
42
+ buildId: JSON.parse(fs
43
+ .readFileSync(path.join(sitePath, clientDir, "_app/version.json"))
44
+ .toString()).version,
45
+ cloudFrontFunctions: {
46
+ serverCfFunction: {
47
+ constructId: "CloudFrontFunction",
48
+ injections: [
49
+ this.useCloudFrontFunctionHostHeaderInjection(),
50
+ // Note: form action requests contain "/" in request query string
51
+ // ie. POST request with query string "?/action"
52
+ // CloudFront does not allow query string with "/". It needs to be encoded.
53
+ `for (var key in request.querystring) {`,
54
+ ` if (key.includes("/")) {`,
55
+ ` request.querystring[encodeURIComponent(key)] = request.querystring[key];`,
56
+ ` delete request.querystring[key];`,
57
+ ` }`,
58
+ `}`,
59
+ ],
60
+ },
61
+ },
62
+ edgeFunctions: edge
63
+ ? {
64
+ edgeServer: {
65
+ constructId: "Server",
66
+ function: {
67
+ scopeOverride: this,
68
+ ...serverConfig,
69
+ },
89
70
  },
90
- ...nodejs?.esbuild,
71
+ }
72
+ : undefined,
73
+ origins: {
74
+ ...(edge
75
+ ? {}
76
+ : {
77
+ regionalServer: {
78
+ type: "function",
79
+ constructId: "ServerFunction",
80
+ function: serverConfig,
81
+ },
82
+ }),
83
+ s3: {
84
+ type: "s3",
85
+ copy: [
86
+ {
87
+ from: clientDir,
88
+ to: "",
89
+ cached: true,
90
+ versionedSubDir: "_app",
91
+ },
92
+ {
93
+ from: prerenderedDir,
94
+ to: "",
95
+ cached: false,
96
+ },
97
+ ],
91
98
  },
92
99
  },
100
+ behaviors: [
101
+ edge
102
+ ? {
103
+ cacheType: "server",
104
+ cfFunction: "serverCfFunction",
105
+ edgeFunction: "edgeServer",
106
+ origin: "s3",
107
+ }
108
+ : {
109
+ cacheType: "server",
110
+ cfFunction: "serverCfFunction",
111
+ origin: "regionalServer",
112
+ },
113
+ // create 1 behaviour for each top level asset file/folder
114
+ ...fs.readdirSync(path.join(sitePath, clientDir)).map((item) => ({
115
+ cacheType: "static",
116
+ pattern: fs
117
+ .statSync(path.join(sitePath, clientDir, item))
118
+ .isDirectory()
119
+ ? `${item}/*`
120
+ : item,
121
+ origin: "s3",
122
+ })),
123
+ ],
93
124
  });
94
125
  }
95
- generateBuildId() {
96
- const filePath = path.join(this.props.path, ".svelte-kit/svelte-kit-sst/client/_app/version.json");
97
- const content = fs.readFileSync(filePath).toString();
98
- return JSON.parse(content).version;
99
- }
100
126
  getConstructMetadata() {
101
127
  return {
102
128
  type: "SvelteKitSite",
@@ -60,6 +60,8 @@ export class Table extends Construct {
60
60
  }
61
61
  // Create Kinesis Stream
62
62
  this.buildKinesisStreamSpec(kinesisStream);
63
+ const app = this.node.root;
64
+ app.registerTypes(this);
63
65
  }
64
66
  /**
65
67
  * The ARN of the internally created DynamoDB Table.
@@ -37,6 +37,8 @@ export class Topic extends Construct {
37
37
  this.cdk = {};
38
38
  this.createTopic();
39
39
  this.addSubscribers(this, props?.subscribers || {});
40
+ const app = this.node.root;
41
+ app.registerTypes(this);
40
42
  }
41
43
  /**
42
44
  * The ARN of the internally created SNS Topic.
@@ -57,6 +57,8 @@ export class WebSocketApi extends Construct {
57
57
  resources: [this._connectionsArn],
58
58
  }),
59
59
  ]);
60
+ const app = this.node.root;
61
+ app.registerTypes(this);
60
62
  }
61
63
  /**
62
64
  * Url of the WebSocket API
@@ -167,6 +167,7 @@ export class NextjsSite extends Construct {
167
167
  invalidationCR.node.addDependency(this.cdk.distribution);
168
168
  // Connect Custom Domain to CloudFront Distribution
169
169
  this.createRoute53Records();
170
+ app.registerTypes(this);
170
171
  }
171
172
  /**
172
173
  * The CloudFront URL of the website.
@@ -91,6 +91,7 @@ export class Auth extends Construct {
91
91
  },
92
92
  });
93
93
  resource.node.addDependency(policy);
94
+ app.registerTypes(this);
94
95
  }
95
96
  get url() {
96
97
  return this.api.customDomainUrl || this.api.url;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.26.2",
4
+ "version": "2.26.4",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -7,8 +7,6 @@ import { installGlobals } from "@remix-run/node";
7
7
  installGlobals();
8
8
 
9
9
  import {
10
- Headers as NodeHeaders,
11
- Request as NodeRequest,
12
10
  createRequestHandler as createNodeRequestHandler,
13
11
  readableStreamToString,
14
12
  } from "@remix-run/node";
@@ -96,7 +94,7 @@ function convertCfRequestToNode(event) {
96
94
  );
97
95
 
98
96
  // Build headers
99
- const headers = new NodeHeaders();
97
+ const headers = new Headers();
100
98
  for (const [key, values] of Object.entries(request.headers)) {
101
99
  for (const { value } of values) {
102
100
  if (value) {
@@ -105,7 +103,7 @@ function convertCfRequestToNode(event) {
105
103
  }
106
104
  }
107
105
 
108
- return new NodeRequest(url.toString(), {
106
+ return new Request(url.toString(), {
109
107
  method: request.method,
110
108
  headers,
111
109
  body: request.body?.data
@@ -7,8 +7,6 @@ import { installGlobals } from "@remix-run/node";
7
7
  installGlobals();
8
8
 
9
9
  import {
10
- Headers as NodeHeaders,
11
- Request as NodeRequest,
12
10
  createRequestHandler as createNodeRequestHandler,
13
11
  readableStreamToString,
14
12
  } from "@remix-run/node";
@@ -94,14 +92,14 @@ function convertApigRequestToNode(event) {
94
92
  );
95
93
 
96
94
  // Build headers
97
- const headers = new NodeHeaders();
95
+ const headers = new Headers();
98
96
  for (let [header, value] of Object.entries(event.headers)) {
99
97
  if (value) {
100
98
  headers.append(header, value);
101
99
  }
102
100
  }
103
101
 
104
- return new NodeRequest(url.href, {
102
+ return new Request(url.href, {
105
103
  method: event.requestContext.http.method,
106
104
  headers,
107
105
  body: