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.
- package/cli/commands/types.js +3 -7
- package/constructs/Api.js +2 -0
- package/constructs/ApiGatewayV1Api.js +2 -0
- package/constructs/App.d.ts +3 -1
- package/constructs/App.js +63 -62
- package/constructs/AppSyncApi.js +2 -0
- package/constructs/AstroSite.d.ts +50 -11
- package/constructs/AstroSite.js +69 -51
- package/constructs/Auth.js +2 -0
- package/constructs/Bucket.js +2 -0
- package/constructs/Cognito.js +2 -0
- package/constructs/Cron.js +2 -0
- package/constructs/EdgeFunction.d.ts +3 -4
- package/constructs/EdgeFunction.js +13 -9
- package/constructs/EventBus.js +2 -0
- package/constructs/Function.d.ts +5 -1
- package/constructs/Function.js +8 -6
- package/constructs/Job.js +3 -3
- package/constructs/KinesisStream.js +2 -0
- package/constructs/NextjsSite.d.ts +84 -22
- package/constructs/NextjsSite.js +150 -254
- package/constructs/Parameter.js +2 -0
- package/constructs/Queue.js +2 -0
- package/constructs/RDS.js +5 -4
- package/constructs/RemixSite.d.ts +65 -11
- package/constructs/RemixSite.js +112 -71
- package/constructs/Script.js +2 -0
- package/constructs/Secret.js +2 -0
- package/constructs/Service.js +4 -3
- package/constructs/SolidStartSite.d.ts +48 -9
- package/constructs/SolidStartSite.js +68 -40
- package/constructs/SsrFunction.d.ts +4 -5
- package/constructs/SsrFunction.js +18 -13
- package/constructs/SsrSite.d.ts +74 -68
- package/constructs/SsrSite.js +657 -682
- package/constructs/StaticSite.js +2 -0
- package/constructs/SvelteKitSite.d.ts +80 -12
- package/constructs/SvelteKitSite.js +90 -64
- package/constructs/Table.js +2 -0
- package/constructs/Topic.js +2 -0
- package/constructs/WebSocketApi.js +2 -0
- package/constructs/deprecated/NextjsSite.js +1 -0
- package/constructs/future/Auth.js +1 -0
- package/package.json +1 -1
- package/support/remix-site-function/edge-server.js +2 -4
- package/support/remix-site-function/regional-server.js +2 -4
package/constructs/StaticSite.js
CHANGED
|
@@ -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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
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(
|
|
36
|
+
from: path.join(sitePath, prerenderedDir),
|
|
64
37
|
to: "prerendered",
|
|
65
38
|
},
|
|
66
39
|
],
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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",
|
package/constructs/Table.js
CHANGED
package/constructs/Topic.js
CHANGED
|
@@ -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.
|
package/package.json
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
102
|
+
return new Request(url.href, {
|
|
105
103
|
method: event.requestContext.http.method,
|
|
106
104
|
headers,
|
|
107
105
|
body:
|