sst 2.13.1 → 2.13.3
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/config.d.ts +4 -4
- package/constructs/AstroSite.d.ts +11 -0
- package/constructs/AstroSite.js +6 -0
- package/constructs/Job.d.ts +3 -1
- package/constructs/Job.js +3 -1
- package/constructs/Metadata.d.ts +13 -6
- package/constructs/NextjsSite.d.ts +11 -0
- package/constructs/NextjsSite.js +14 -3
- package/constructs/RemixSite.d.ts +11 -0
- package/constructs/RemixSite.js +6 -0
- package/constructs/Script.d.ts +22 -1
- package/constructs/Script.js +30 -4
- package/constructs/SolidStartSite.d.ts +11 -0
- package/constructs/SolidStartSite.js +6 -0
- package/constructs/SsrSite.d.ts +8 -7
- package/constructs/SsrSite.js +33 -14
- package/constructs/Stack.js +7 -7
- package/constructs/StaticSite.js +3 -0
- package/constructs/SvelteKitSite.d.ts +11 -0
- package/constructs/SvelteKitSite.js +6 -0
- package/node/api/index.d.ts +1 -0
- package/node/api/index.js +6 -0
- package/node/future/auth/adapter/code.d.ts +16 -0
- package/node/future/auth/adapter/code.js +67 -0
- package/node/future/auth/encryption.d.ts +2 -0
- package/node/future/auth/encryption.js +30 -0
- package/node/future/auth/handler.d.ts +2 -1
- package/node/future/auth/handler.js +24 -9
- package/node/future/auth/index.d.ts +2 -0
- package/node/future/auth/index.js +2 -0
- package/package.json +1 -1
- package/support/custom-resources/index.mjs +2 -0
- package/support/script-function/index.mjs +16404 -184
package/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionMetadata,
|
|
1
|
+
import { FunctionMetadata, NextjsSiteMetadata, AstroSiteMetadata, RemixSiteMetadata, SolidStartSiteMetadata, SvelteKitSiteMetadata, SSRSiteMetadata } from "./constructs/Metadata.js";
|
|
2
2
|
declare module "./bus.js" {
|
|
3
3
|
interface Events {
|
|
4
4
|
"config.secret.updated": {
|
|
@@ -47,9 +47,9 @@ export declare namespace Config {
|
|
|
47
47
|
fallback?: boolean;
|
|
48
48
|
}): Promise<void>;
|
|
49
49
|
function restart(keys: string[]): Promise<{
|
|
50
|
-
edgeSites:
|
|
51
|
-
sites:
|
|
52
|
-
placeholderSites:
|
|
50
|
+
edgeSites: (NextjsSiteMetadata | AstroSiteMetadata | RemixSiteMetadata | SolidStartSiteMetadata | SvelteKitSiteMetadata)[];
|
|
51
|
+
sites: SSRSiteMetadata[];
|
|
52
|
+
placeholderSites: (NextjsSiteMetadata | AstroSiteMetadata | RemixSiteMetadata | SolidStartSiteMetadata | SvelteKitSiteMetadata)[];
|
|
53
53
|
functions: FunctionMetadata[];
|
|
54
54
|
}>;
|
|
55
55
|
}
|
|
@@ -22,4 +22,15 @@ export declare class AstroSite extends SsrSite {
|
|
|
22
22
|
protected validateBuildOutput(): void;
|
|
23
23
|
protected createFunctionForRegional(): CdkFunction;
|
|
24
24
|
protected createFunctionForEdge(): EdgeFunction;
|
|
25
|
+
getConstructMetadata(): {
|
|
26
|
+
data: {
|
|
27
|
+
mode: "placeholder" | "deployed";
|
|
28
|
+
path: string;
|
|
29
|
+
customDomainUrl: string | undefined;
|
|
30
|
+
edge: boolean | undefined;
|
|
31
|
+
server: string;
|
|
32
|
+
secrets: string[];
|
|
33
|
+
};
|
|
34
|
+
type: "AstroSite";
|
|
35
|
+
};
|
|
25
36
|
}
|
package/constructs/AstroSite.js
CHANGED
package/constructs/Job.d.ts
CHANGED
|
@@ -211,7 +211,9 @@ export declare class Job extends Construct implements SSTConstruct {
|
|
|
211
211
|
constructor(scope: Construct, id: string, props: JobProps);
|
|
212
212
|
getConstructMetadata(): {
|
|
213
213
|
type: "Job";
|
|
214
|
-
data: {
|
|
214
|
+
data: {
|
|
215
|
+
handler: string;
|
|
216
|
+
};
|
|
215
217
|
};
|
|
216
218
|
/** @internal */
|
|
217
219
|
getFunctionBinding(): FunctionBindingProps;
|
package/constructs/Job.js
CHANGED
package/constructs/Metadata.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type ApiMetadata = ExtractMetadata<Api<any>>;
|
|
|
9
9
|
import type { ApiGatewayV1Api } from "./ApiGatewayV1Api.js";
|
|
10
10
|
export type ApiGatewayV1ApiMetadata = ExtractMetadata<ApiGatewayV1Api<any>>;
|
|
11
11
|
import type { Cognito } from "./Cognito.js";
|
|
12
|
-
export type
|
|
12
|
+
export type CognitoMetadata = ExtractMetadata<Cognito>;
|
|
13
13
|
import type { AppSyncApi } from "./AppSyncApi.js";
|
|
14
14
|
export type AppSyncApiMetadata = ExtractMetadata<AppSyncApi>;
|
|
15
15
|
import type { Bucket } from "./Bucket.js";
|
|
@@ -22,16 +22,12 @@ import type { Function as Fn } from "./Function.js";
|
|
|
22
22
|
export type FunctionMetadata = ExtractMetadata<Fn>;
|
|
23
23
|
import type { KinesisStream } from "./KinesisStream.js";
|
|
24
24
|
export type KinesisStreamMetadata = ExtractMetadata<KinesisStream>;
|
|
25
|
-
import type { NextjsSite } from "./NextjsSite.js";
|
|
26
|
-
export type NextjsMetadata = ExtractMetadata<NextjsSite>;
|
|
27
25
|
import type { NextjsSite as SlsNextjsSite } from "./deprecated/NextjsSite.js";
|
|
28
26
|
export type SlsNextjsMetadata = ExtractMetadata<SlsNextjsSite>;
|
|
29
27
|
import type { Queue } from "./Queue.js";
|
|
30
28
|
export type QueueMetadata = ExtractMetadata<Queue>;
|
|
31
29
|
import type { StaticSite } from "./StaticSite.js";
|
|
32
30
|
export type StaticSiteMetadata = ExtractMetadata<StaticSite>;
|
|
33
|
-
import type { SsrSite } from "./SsrSite.js";
|
|
34
|
-
export type SsrSiteMetadata = ExtractMetadata<SsrSite>;
|
|
35
31
|
import type { Table } from "./Table.js";
|
|
36
32
|
export type TableMetadata = ExtractMetadata<Table>;
|
|
37
33
|
import type { Topic } from "./Topic.js";
|
|
@@ -40,5 +36,16 @@ import type { WebSocketApi } from "./WebSocketApi.js";
|
|
|
40
36
|
export type WebSocketApiMetadata = ExtractMetadata<WebSocketApi>;
|
|
41
37
|
import type { RDS } from "./RDS.js";
|
|
42
38
|
export type RDSMetadata = ExtractMetadata<RDS>;
|
|
43
|
-
|
|
39
|
+
import type { NextjsSite } from "./NextjsSite.js";
|
|
40
|
+
export type NextjsSiteMetadata = ExtractMetadata<NextjsSite>;
|
|
41
|
+
import type { AstroSite } from "./AstroSite.js";
|
|
42
|
+
export type AstroSiteMetadata = ExtractMetadata<AstroSite>;
|
|
43
|
+
import type { RemixSite } from "./RemixSite.js";
|
|
44
|
+
export type RemixSiteMetadata = ExtractMetadata<RemixSite>;
|
|
45
|
+
import type { SvelteKitSite } from "./SvelteKitSite.js";
|
|
46
|
+
export type SvelteKitSiteMetadata = ExtractMetadata<SvelteKitSite>;
|
|
47
|
+
import type { SolidStartSite } from "./SolidStartSite.js";
|
|
48
|
+
export type SolidStartSiteMetadata = ExtractMetadata<SolidStartSite>;
|
|
49
|
+
export type SSRSiteMetadata = NextjsSiteMetadata | AstroSiteMetadata | RemixSiteMetadata | SolidStartSiteMetadata | SvelteKitSiteMetadata;
|
|
50
|
+
export type Metadata = ApiMetadata | ApiGatewayV1ApiMetadata | CognitoMetadata | AppSyncApiMetadata | BucketMetadata | CronMetadata | EventBusMetadata | FunctionMetadata | KinesisStreamMetadata | SlsNextjsMetadata | QueueMetadata | StaticSiteMetadata | TableMetadata | TopicMetadata | WebSocketApiMetadata | RDSMetadata | SSRSiteMetadata;
|
|
44
51
|
export {};
|
|
@@ -61,4 +61,15 @@ export declare class NextjsSite extends SsrSite {
|
|
|
61
61
|
private buildDefaultNextjsBehaviorForRegional;
|
|
62
62
|
private buildDefaultNextjsBehaviorForEdge;
|
|
63
63
|
protected generateBuildId(): string;
|
|
64
|
+
getConstructMetadata(): {
|
|
65
|
+
data: {
|
|
66
|
+
mode: "placeholder" | "deployed";
|
|
67
|
+
path: string;
|
|
68
|
+
customDomainUrl: string | undefined;
|
|
69
|
+
edge: boolean | undefined;
|
|
70
|
+
server: string;
|
|
71
|
+
secrets: string[];
|
|
72
|
+
};
|
|
73
|
+
type: "NextjsSite";
|
|
74
|
+
};
|
|
64
75
|
}
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -13,6 +13,7 @@ import { SsrFunction } from "./SsrFunction.js";
|
|
|
13
13
|
import { EdgeFunction } from "./EdgeFunction.js";
|
|
14
14
|
import { SsrSite } from "./SsrSite.js";
|
|
15
15
|
import { toCdkSize } from "./util/size.js";
|
|
16
|
+
import { toCdkDuration } from "./util/duration.js";
|
|
16
17
|
/**
|
|
17
18
|
* The `NextjsSite` construct is a higher level CDK construct that makes it easy to create a Next.js app.
|
|
18
19
|
* @example
|
|
@@ -198,13 +199,17 @@ export class NextjsSite extends SsrSite {
|
|
|
198
199
|
* - Cache-Control: public, max-age=0, must-revalidate
|
|
199
200
|
* - x-vercel-cache: MISS
|
|
200
201
|
*/
|
|
201
|
-
const { cdk } = this.props;
|
|
202
|
+
const { timeout, cdk } = this.props;
|
|
202
203
|
const cfDistributionProps = cdk?.distribution || {};
|
|
203
204
|
const s3Origin = new S3Origin(this.cdk.bucket);
|
|
204
205
|
const serverFnUrl = this.serverLambdaForRegional.addFunctionUrl({
|
|
205
206
|
authType: FunctionUrlAuthType.NONE,
|
|
206
207
|
});
|
|
207
|
-
const serverOrigin = new HttpOrigin(Fn.parseDomainName(serverFnUrl.url)
|
|
208
|
+
const serverOrigin = new HttpOrigin(Fn.parseDomainName(serverFnUrl.url), {
|
|
209
|
+
readTimeout: typeof timeout === "string"
|
|
210
|
+
? toCdkDuration(timeout)
|
|
211
|
+
: CdkDuration.seconds(timeout),
|
|
212
|
+
});
|
|
208
213
|
const cachePolicy = cdk?.serverCachePolicy ??
|
|
209
214
|
this.buildServerCachePolicy([
|
|
210
215
|
"accept",
|
|
@@ -244,7 +249,7 @@ export class NextjsSite extends SsrSite {
|
|
|
244
249
|
"next-router-state-tree",
|
|
245
250
|
]);
|
|
246
251
|
const originRequestPolicy = this.buildServerOriginRequestPolicy();
|
|
247
|
-
const functionVersion = this.
|
|
252
|
+
const functionVersion = this.serverEdgeFunction.currentVersion;
|
|
248
253
|
const serverBehavior = this.buildServerBehaviorForEdge(functionVersion, s3Origin, cachePolicy, originRequestPolicy);
|
|
249
254
|
return new Distribution(this, "Distribution", {
|
|
250
255
|
// these values can be overwritten by cfDistributionProps
|
|
@@ -378,4 +383,10 @@ export class NextjsSite extends SsrSite {
|
|
|
378
383
|
const filePath = path.join(this.props.path, ".next/BUILD_ID");
|
|
379
384
|
return fs.readFileSync(filePath).toString();
|
|
380
385
|
}
|
|
386
|
+
getConstructMetadata() {
|
|
387
|
+
return {
|
|
388
|
+
type: "NextjsSite",
|
|
389
|
+
...this.getConstructMetadataBase(),
|
|
390
|
+
};
|
|
391
|
+
}
|
|
381
392
|
}
|
|
@@ -24,4 +24,15 @@ export declare class RemixSite extends SsrSite {
|
|
|
24
24
|
private createServerLambdaBundle;
|
|
25
25
|
protected createFunctionForRegional(): CdkFunction;
|
|
26
26
|
protected createFunctionForEdge(): EdgeFunction;
|
|
27
|
+
getConstructMetadata(): {
|
|
28
|
+
data: {
|
|
29
|
+
mode: "placeholder" | "deployed";
|
|
30
|
+
path: string;
|
|
31
|
+
customDomainUrl: string | undefined;
|
|
32
|
+
edge: boolean | undefined;
|
|
33
|
+
server: string;
|
|
34
|
+
secrets: string[];
|
|
35
|
+
};
|
|
36
|
+
type: "RemixSite";
|
|
37
|
+
};
|
|
27
38
|
}
|
package/constructs/RemixSite.js
CHANGED
package/constructs/Script.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export interface ScriptProps {
|
|
|
99
99
|
* });
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
|
-
export declare class Script extends Construct {
|
|
102
|
+
export declare class Script extends Construct implements SSTConstruct {
|
|
103
103
|
/**
|
|
104
104
|
* The internally created onCreate `Function` instance.
|
|
105
105
|
*/
|
|
@@ -113,6 +113,7 @@ export declare class Script extends Construct {
|
|
|
113
113
|
*/
|
|
114
114
|
readonly deleteFunction?: Fn;
|
|
115
115
|
protected readonly props: ScriptProps;
|
|
116
|
+
readonly id: string;
|
|
116
117
|
constructor(scope: Construct, id: string, props: ScriptProps);
|
|
117
118
|
/**
|
|
118
119
|
* Binds additional resources to the script
|
|
@@ -136,4 +137,24 @@ export declare class Script extends Construct {
|
|
|
136
137
|
private createCustomResourceFunction;
|
|
137
138
|
private createCustomResource;
|
|
138
139
|
private checkDeprecatedFunction;
|
|
140
|
+
/** @internal */
|
|
141
|
+
getConstructMetadata(): {
|
|
142
|
+
type: "Script";
|
|
143
|
+
data: {
|
|
144
|
+
createfn: {
|
|
145
|
+
node: string;
|
|
146
|
+
stack: string;
|
|
147
|
+
} | undefined;
|
|
148
|
+
deletefn: {
|
|
149
|
+
node: string;
|
|
150
|
+
stack: string;
|
|
151
|
+
} | undefined;
|
|
152
|
+
updatefn: {
|
|
153
|
+
node: string;
|
|
154
|
+
stack: string;
|
|
155
|
+
} | undefined;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/** @internal */
|
|
159
|
+
getFunctionBinding(): undefined;
|
|
139
160
|
}
|
package/constructs/Script.js
CHANGED
|
@@ -2,8 +2,11 @@ import path from "path";
|
|
|
2
2
|
import url from "url";
|
|
3
3
|
import { Construct } from "constructs";
|
|
4
4
|
import { CustomResource, Duration } from "aws-cdk-lib/core";
|
|
5
|
-
import
|
|
5
|
+
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
6
|
+
import { Code, Runtime, Function as CdkFunction } from "aws-cdk-lib/aws-lambda";
|
|
7
|
+
import { Stack } from "./Stack.js";
|
|
6
8
|
import { Function as Fn, } from "./Function.js";
|
|
9
|
+
import { getFunctionRef, } from "./Construct.js";
|
|
7
10
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
8
11
|
/////////////////////
|
|
9
12
|
// Construct
|
|
@@ -37,8 +40,10 @@ export class Script extends Construct {
|
|
|
37
40
|
*/
|
|
38
41
|
deleteFunction;
|
|
39
42
|
props;
|
|
43
|
+
id;
|
|
40
44
|
constructor(scope, id, props) {
|
|
41
45
|
super(scope, id);
|
|
46
|
+
this.id = id;
|
|
42
47
|
if (props.function)
|
|
43
48
|
this.checkDeprecatedFunction();
|
|
44
49
|
// Validate deprecated "function" prop
|
|
@@ -112,12 +117,18 @@ export class Script extends Construct {
|
|
|
112
117
|
});
|
|
113
118
|
}
|
|
114
119
|
createCustomResourceFunction() {
|
|
115
|
-
const handler = new
|
|
116
|
-
code:
|
|
117
|
-
runtime:
|
|
120
|
+
const handler = new CdkFunction(this, "ScriptHandler", {
|
|
121
|
+
code: Code.fromAsset(path.join(__dirname, "../support/script-function")),
|
|
122
|
+
runtime: Runtime.NODEJS_16_X,
|
|
118
123
|
handler: "index.handler",
|
|
119
124
|
timeout: Duration.minutes(15),
|
|
120
125
|
memorySize: 1024,
|
|
126
|
+
initialPolicy: [
|
|
127
|
+
new PolicyStatement({
|
|
128
|
+
actions: ["cloudformation:DescribeStacks"],
|
|
129
|
+
resources: [Stack.of(this).stackId],
|
|
130
|
+
}),
|
|
131
|
+
],
|
|
121
132
|
});
|
|
122
133
|
this.createFunction?.grantInvoke(handler);
|
|
123
134
|
this.updateFunction?.grantInvoke(handler);
|
|
@@ -151,4 +162,19 @@ export class Script extends Construct {
|
|
|
151
162
|
checkDeprecatedFunction() {
|
|
152
163
|
throw new Error(`The "function" property has been replaced by "onCreate" and "onUpdate". More details on upgrading - https://docs.sst.dev/constructs/Script#upgrading-to-v0460`);
|
|
153
164
|
}
|
|
165
|
+
/** @internal */
|
|
166
|
+
getConstructMetadata() {
|
|
167
|
+
return {
|
|
168
|
+
type: "Script",
|
|
169
|
+
data: {
|
|
170
|
+
createfn: getFunctionRef(this.createFunction),
|
|
171
|
+
deletefn: getFunctionRef(this.deleteFunction),
|
|
172
|
+
updatefn: getFunctionRef(this.updateFunction),
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** @internal */
|
|
177
|
+
getFunctionBinding() {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
154
180
|
}
|
|
@@ -21,4 +21,15 @@ export declare class SolidStartSite extends SsrSite {
|
|
|
21
21
|
};
|
|
22
22
|
protected createFunctionForRegional(): CdkFunction;
|
|
23
23
|
protected createFunctionForEdge(): EdgeFunction;
|
|
24
|
+
getConstructMetadata(): {
|
|
25
|
+
data: {
|
|
26
|
+
mode: "placeholder" | "deployed";
|
|
27
|
+
path: string;
|
|
28
|
+
customDomainUrl: string | undefined;
|
|
29
|
+
edge: boolean | undefined;
|
|
30
|
+
server: string;
|
|
31
|
+
secrets: string[];
|
|
32
|
+
};
|
|
33
|
+
type: "SolidStartSite";
|
|
34
|
+
};
|
|
24
35
|
}
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ import { Size } from "./util/size.js";
|
|
|
12
12
|
import { Duration } from "./util/duration.js";
|
|
13
13
|
import { Permissions } from "./util/permission.js";
|
|
14
14
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
15
|
-
type SsrSiteType = "NextjsSite" | "RemixSite" | "AstroSite" | "SolidStartSite" | "SvelteKitSite";
|
|
16
15
|
export type SsrBuildConfig = {
|
|
17
16
|
typesPath: string;
|
|
18
17
|
serverBuildOutputFile: string;
|
|
@@ -209,12 +208,13 @@ type SsrSiteNormalizedProps = SsrSiteProps & {
|
|
|
209
208
|
* });
|
|
210
209
|
* ```
|
|
211
210
|
*/
|
|
212
|
-
export declare class SsrSite extends Construct implements SSTConstruct {
|
|
211
|
+
export declare abstract class SsrSite extends Construct implements SSTConstruct {
|
|
213
212
|
readonly id: string;
|
|
214
213
|
protected props: SsrSiteNormalizedProps;
|
|
215
214
|
private doNotDeploy;
|
|
216
215
|
protected buildConfig: SsrBuildConfig;
|
|
217
|
-
protected
|
|
216
|
+
protected serverEdgeFunction?: EdgeFunction;
|
|
217
|
+
private serverLambdaForEdge?;
|
|
218
218
|
protected serverLambdaForRegional?: CdkFunction;
|
|
219
219
|
private serverLambdaForDev?;
|
|
220
220
|
private bucket;
|
|
@@ -253,8 +253,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
253
253
|
*/
|
|
254
254
|
attachPermissions(permissions: Permissions): void;
|
|
255
255
|
/** @internal */
|
|
256
|
-
|
|
257
|
-
type: SsrSiteType;
|
|
256
|
+
protected getConstructMetadataBase(): {
|
|
258
257
|
data: {
|
|
259
258
|
mode: "placeholder" | "deployed";
|
|
260
259
|
path: string;
|
|
@@ -264,6 +263,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
264
263
|
secrets: string[];
|
|
265
264
|
};
|
|
266
265
|
};
|
|
266
|
+
abstract getConstructMetadata(): ReturnType<SSTConstruct["getConstructMetadata"]>;
|
|
267
267
|
/** @internal */
|
|
268
268
|
getFunctionBinding(): FunctionBindingProps;
|
|
269
269
|
protected initBuildConfig(): SsrBuildConfig;
|
|
@@ -300,14 +300,15 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
300
300
|
protected createRoute53Records(): void;
|
|
301
301
|
private getS3ContentReplaceValues;
|
|
302
302
|
private validateSiteExists;
|
|
303
|
+
private validateTimeout;
|
|
303
304
|
private writeTypesFile;
|
|
304
305
|
protected generateBuildId(): string;
|
|
305
306
|
}
|
|
306
307
|
export declare const useSites: () => {
|
|
307
|
-
add(name: string, type:
|
|
308
|
+
add(name: string, type: string, props: SsrSiteNormalizedProps): void;
|
|
308
309
|
readonly all: {
|
|
309
310
|
name: string;
|
|
310
|
-
type:
|
|
311
|
+
type: string;
|
|
311
312
|
props: SsrSiteNormalizedProps;
|
|
312
313
|
}[];
|
|
313
314
|
};
|
package/constructs/SsrSite.js
CHANGED
|
@@ -25,6 +25,7 @@ import { SsrFunction } from "./SsrFunction.js";
|
|
|
25
25
|
import { getBuildCmdEnvironment, } from "./BaseSite.js";
|
|
26
26
|
import { HttpsRedirect } from "./cdk/website-redirect.js";
|
|
27
27
|
import { DnsValidatedCertificate } from "./cdk/dns-validated-certificate.js";
|
|
28
|
+
import { toCdkDuration } from "./util/duration.js";
|
|
28
29
|
import { attachPermissionsToRole } from "./util/permission.js";
|
|
29
30
|
import { getParameterPath, } from "./util/functionBinding.js";
|
|
30
31
|
import { useProject } from "../project.js";
|
|
@@ -45,6 +46,7 @@ export class SsrSite extends Construct {
|
|
|
45
46
|
props;
|
|
46
47
|
doNotDeploy;
|
|
47
48
|
buildConfig;
|
|
49
|
+
serverEdgeFunction;
|
|
48
50
|
serverLambdaForEdge;
|
|
49
51
|
serverLambdaForRegional;
|
|
50
52
|
serverLambdaForDev;
|
|
@@ -70,6 +72,7 @@ export class SsrSite extends Construct {
|
|
|
70
72
|
!stack.isActive || (app.mode === "dev" && !this.props.dev?.deploy);
|
|
71
73
|
this.buildConfig = this.initBuildConfig();
|
|
72
74
|
this.validateSiteExists();
|
|
75
|
+
this.validateTimeout();
|
|
73
76
|
this.writeTypesFile();
|
|
74
77
|
useSites().add(id, this.constructor.name, this.props);
|
|
75
78
|
if (this.doNotDeploy) {
|
|
@@ -85,7 +88,11 @@ export class SsrSite extends Construct {
|
|
|
85
88
|
this.bucket = this.createS3Bucket();
|
|
86
89
|
// Create Server functions
|
|
87
90
|
if (this.props.edge) {
|
|
88
|
-
this.
|
|
91
|
+
this.serverEdgeFunction = this.createFunctionForEdge();
|
|
92
|
+
this.serverLambdaForEdge = CdkFunction.fromFunctionAttributes(this, "IEdgeFunction", {
|
|
93
|
+
functionArn: this.serverEdgeFunction.functionArn,
|
|
94
|
+
role: this.serverEdgeFunction.role,
|
|
95
|
+
});
|
|
89
96
|
this.createFunctionPermissionsForEdge();
|
|
90
97
|
}
|
|
91
98
|
else {
|
|
@@ -147,7 +154,7 @@ export class SsrSite extends Construct {
|
|
|
147
154
|
if (this.doNotDeploy)
|
|
148
155
|
return;
|
|
149
156
|
return {
|
|
150
|
-
function: this.serverLambdaForRegional,
|
|
157
|
+
function: this.serverLambdaForEdge || this.serverLambdaForRegional,
|
|
151
158
|
bucket: this.bucket,
|
|
152
159
|
distribution: this.distribution,
|
|
153
160
|
hostedZone: this.hostedZone,
|
|
@@ -167,18 +174,14 @@ export class SsrSite extends Construct {
|
|
|
167
174
|
* ```
|
|
168
175
|
*/
|
|
169
176
|
attachPermissions(permissions) {
|
|
170
|
-
this.serverLambdaForEdge
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (this.serverLambdaForRegional) {
|
|
175
|
-
attachPermissionsToRole(this.serverLambdaForRegional.role, permissions);
|
|
176
|
-
}
|
|
177
|
+
const server = this.serverLambdaForEdge ||
|
|
178
|
+
this.serverLambdaForRegional ||
|
|
179
|
+
this.serverLambdaForDev;
|
|
180
|
+
attachPermissionsToRole(server?.role, permissions);
|
|
177
181
|
}
|
|
178
182
|
/** @internal */
|
|
179
|
-
|
|
183
|
+
getConstructMetadataBase() {
|
|
180
184
|
return {
|
|
181
|
-
type: this.constructor.name,
|
|
182
185
|
data: {
|
|
183
186
|
mode: this.doNotDeploy
|
|
184
187
|
? "placeholder"
|
|
@@ -535,14 +538,18 @@ function handler(event) {
|
|
|
535
538
|
return domainNames;
|
|
536
539
|
}
|
|
537
540
|
buildDefaultBehaviorForRegional() {
|
|
538
|
-
const { cdk } = this.props;
|
|
541
|
+
const { timeout, cdk } = this.props;
|
|
539
542
|
const cfDistributionProps = cdk?.distribution || {};
|
|
540
543
|
const fnUrl = this.serverLambdaForRegional.addFunctionUrl({
|
|
541
544
|
authType: FunctionUrlAuthType.NONE,
|
|
542
545
|
});
|
|
543
546
|
return {
|
|
544
547
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
545
|
-
origin: new HttpOrigin(Fn.parseDomainName(fnUrl.url)
|
|
548
|
+
origin: new HttpOrigin(Fn.parseDomainName(fnUrl.url), {
|
|
549
|
+
readTimeout: typeof timeout === "string"
|
|
550
|
+
? toCdkDuration(timeout)
|
|
551
|
+
: CdkDuration.seconds(timeout),
|
|
552
|
+
}),
|
|
546
553
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
547
554
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
548
555
|
compress: true,
|
|
@@ -577,7 +584,7 @@ function handler(event) {
|
|
|
577
584
|
{
|
|
578
585
|
includeBody: true,
|
|
579
586
|
eventType: LambdaEdgeEventType.ORIGIN_REQUEST,
|
|
580
|
-
functionVersion: this.
|
|
587
|
+
functionVersion: this.serverEdgeFunction.currentVersion,
|
|
581
588
|
},
|
|
582
589
|
...(cfDistributionProps.defaultBehavior?.edgeLambdas || []),
|
|
583
590
|
],
|
|
@@ -817,6 +824,18 @@ function handler(event) {
|
|
|
817
824
|
throw new Error(`No site found at "${path.resolve(sitePath)}"`);
|
|
818
825
|
}
|
|
819
826
|
}
|
|
827
|
+
validateTimeout() {
|
|
828
|
+
const { edge, timeout } = this.props;
|
|
829
|
+
const num = typeof timeout === "number"
|
|
830
|
+
? timeout
|
|
831
|
+
: toCdkDuration(timeout).toSeconds();
|
|
832
|
+
const limit = edge ? 30 : 180;
|
|
833
|
+
if (num > limit) {
|
|
834
|
+
throw new Error(edge
|
|
835
|
+
? `Timeout must be less than or equal to 30 seconds when the "edge" flag is enabled.`
|
|
836
|
+
: `Timeout must be less than or equal to 180 seconds.`);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
820
839
|
writeTypesFile() {
|
|
821
840
|
const typesPath = path.resolve(this.props.path, this.buildConfig.typesPath, "sst-env.d.ts");
|
|
822
841
|
// Do not override the types file if it already exists
|
package/constructs/Stack.js
CHANGED
|
@@ -202,12 +202,8 @@ export class Stack extends CDKStack {
|
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
static buildSynthesizer() {
|
|
205
|
-
const config = useProject()
|
|
206
|
-
const
|
|
207
|
-
if (customSynethesizerKeys.length === 0) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
return new DefaultStackSynthesizer({
|
|
205
|
+
const { config } = useProject();
|
|
206
|
+
const props = {
|
|
211
207
|
qualifier: config.cdk?.qualifier,
|
|
212
208
|
fileAssetsBucketName: config.cdk?.fileAssetsBucketName,
|
|
213
209
|
deployRoleArn: config.cdk?.deployRoleArn,
|
|
@@ -215,7 +211,11 @@ export class Stack extends CDKStack {
|
|
|
215
211
|
imageAssetPublishingRoleArn: config.cdk?.imageAssetPublishingRoleArn,
|
|
216
212
|
cloudFormationExecutionRole: config.cdk?.cloudFormationExecutionRole,
|
|
217
213
|
lookupRoleArn: config.cdk?.lookupRoleArn,
|
|
218
|
-
}
|
|
214
|
+
};
|
|
215
|
+
const isEmpty = Object.values(props).every((v) => v === undefined);
|
|
216
|
+
if (isEmpty)
|
|
217
|
+
return;
|
|
218
|
+
return new DefaultStackSynthesizer(props);
|
|
219
219
|
}
|
|
220
220
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
221
221
|
static checkForPropsIsConstruct(id, props) {
|
package/constructs/StaticSite.js
CHANGED
|
@@ -466,6 +466,9 @@ interface ImportMeta {
|
|
|
466
466
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
467
467
|
functionAssociations: [
|
|
468
468
|
{
|
|
469
|
+
// Note: this is required in Frameworks like Astro where `index.html`
|
|
470
|
+
// is required in the URL path.
|
|
471
|
+
// https://docs.astro.build/en/guides/deploy/aws/#cloudfront-functions-setup
|
|
469
472
|
function: new CfFunction(this, "CloudFrontFunction", {
|
|
470
473
|
code: CfFunctionCode.fromInline(`
|
|
471
474
|
function handler(event) {
|
|
@@ -24,4 +24,15 @@ export declare class SvelteKitSite extends SsrSite {
|
|
|
24
24
|
protected createFunctionForRegional(): CdkFunction;
|
|
25
25
|
protected createFunctionForEdge(): EdgeFunction;
|
|
26
26
|
protected generateBuildId(): string;
|
|
27
|
+
getConstructMetadata(): {
|
|
28
|
+
data: {
|
|
29
|
+
mode: "placeholder" | "deployed";
|
|
30
|
+
path: string;
|
|
31
|
+
customDomainUrl: string | undefined;
|
|
32
|
+
edge: boolean | undefined;
|
|
33
|
+
server: string;
|
|
34
|
+
secrets: string[];
|
|
35
|
+
};
|
|
36
|
+
type: "SvelteKitSite";
|
|
37
|
+
};
|
|
27
38
|
}
|
|
@@ -98,4 +98,10 @@ export class SvelteKitSite extends SsrSite {
|
|
|
98
98
|
const content = fs.readFileSync(filePath).toString();
|
|
99
99
|
return JSON.parse(content).version;
|
|
100
100
|
}
|
|
101
|
+
getConstructMetadata() {
|
|
102
|
+
return {
|
|
103
|
+
type: "SvelteKitSite",
|
|
104
|
+
...this.getConstructMetadataBase(),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
101
107
|
}
|
package/node/api/index.d.ts
CHANGED
package/node/api/index.js
CHANGED
|
@@ -75,6 +75,12 @@ export const useResponse = /* @__PURE__ */ Context.memo(() => {
|
|
|
75
75
|
return result;
|
|
76
76
|
},
|
|
77
77
|
cookie(input) {
|
|
78
|
+
input = {
|
|
79
|
+
secure: true,
|
|
80
|
+
sameSite: "None",
|
|
81
|
+
httpOnly: true,
|
|
82
|
+
...input,
|
|
83
|
+
};
|
|
78
84
|
const value = encodeURIComponent(input.value);
|
|
79
85
|
const parts = [input.key + "=" + value];
|
|
80
86
|
if (input.domain)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { APIGatewayProxyStructuredResultV2 } from "aws-lambda";
|
|
2
|
+
export declare function CodeAdapter(config: {
|
|
3
|
+
length?: number;
|
|
4
|
+
onCode: (code: string, claims: Record<string, any>) => Promise<APIGatewayProxyStructuredResultV2>;
|
|
5
|
+
}): () => Promise<{
|
|
6
|
+
type: "step";
|
|
7
|
+
properties: APIGatewayProxyStructuredResultV2;
|
|
8
|
+
} | {
|
|
9
|
+
type: "error";
|
|
10
|
+
properties?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
type: "success";
|
|
13
|
+
properties: {
|
|
14
|
+
claims: any;
|
|
15
|
+
};
|
|
16
|
+
}>;
|