sst 2.18.2 → 2.18.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/constructs/App.d.ts +2 -1
- package/constructs/App.js +46 -36
- package/constructs/Function.d.ts +1 -0
- package/constructs/Function.js +1 -0
- package/constructs/NextjsSite.js +3 -6
- package/constructs/SsrSite.d.ts +3 -2
- package/constructs/SsrSite.js +12 -8
- package/package.json +1 -1
- package/runtime/handlers/node.js +1 -1
- package/runtime/handlers/python.js +1 -0
- package/sst.mjs +3 -2
package/constructs/App.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export type AppProps = CDKAppProps;
|
|
|
42
42
|
*/
|
|
43
43
|
export declare class App extends CDKApp {
|
|
44
44
|
/**
|
|
45
|
-
* Whether or not the app is running locally under `sst
|
|
45
|
+
* Whether or not the app is running locally under `sst dev`
|
|
46
46
|
*/
|
|
47
47
|
readonly local: boolean;
|
|
48
48
|
/**
|
|
@@ -160,6 +160,7 @@ export declare class App extends CDKApp {
|
|
|
160
160
|
private removeGovCloudUnsupportedResourceProperties;
|
|
161
161
|
private ensureUniqueConstructIds;
|
|
162
162
|
private codegenTypes;
|
|
163
|
+
private foreachConstruct;
|
|
163
164
|
stack<T extends FunctionalStack<any>>(fn: T, props?: StackProps & {
|
|
164
165
|
id?: string;
|
|
165
166
|
}): ReturnType<T> extends Promise<any> ? Promise<void> : App;
|
package/constructs/App.js
CHANGED
|
@@ -26,7 +26,7 @@ function exitWithMessage(message) {
|
|
|
26
26
|
*/
|
|
27
27
|
export class App extends CDKApp {
|
|
28
28
|
/**
|
|
29
|
-
* Whether or not the app is running locally under `sst
|
|
29
|
+
* Whether or not the app is running locally under `sst dev`
|
|
30
30
|
*/
|
|
31
31
|
local = false;
|
|
32
32
|
/**
|
|
@@ -427,43 +427,53 @@ export class App extends CDKApp {
|
|
|
427
427
|
` }`,
|
|
428
428
|
`}`,
|
|
429
429
|
].join("\n"));
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
430
|
+
this.foreachConstruct((c) => {
|
|
431
|
+
if (!isSSTConstruct(c)) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (c instanceof Function && c._doNotAllowOthersToBind) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const binding = bindType(c);
|
|
438
|
+
if (!binding) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const className = c.constructor.name;
|
|
442
|
+
const id = c.id;
|
|
443
|
+
// Case 1: variable does not have properties, ie. Secrets and Parameters
|
|
444
|
+
fs.appendFileSync(`${typesPath}/index.ts`, (binding.variables[0] === "."
|
|
445
|
+
? [
|
|
446
|
+
`import "sst/node/${binding.clientPackage}";`,
|
|
447
|
+
`declare module "sst/node/${binding.clientPackage}" {`,
|
|
448
|
+
` export interface ${className}Resources {`,
|
|
449
|
+
` "${id}": string;`,
|
|
450
|
+
` }`,
|
|
451
|
+
`}`,
|
|
452
|
+
]
|
|
453
|
+
: [
|
|
454
|
+
`import "sst/node/${binding.clientPackage}";`,
|
|
455
|
+
`declare module "sst/node/${binding.clientPackage}" {`,
|
|
456
|
+
` export interface ${className}Resources {`,
|
|
457
|
+
` "${id}": {`,
|
|
458
|
+
...binding.variables.map((p) => ` ${p}: string;`),
|
|
459
|
+
` }`,
|
|
460
|
+
` }`,
|
|
461
|
+
`}`,
|
|
462
|
+
]).join("\n"));
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
foreachConstruct(fn) {
|
|
466
|
+
const loop = (parent) => {
|
|
467
|
+
for (const child of parent.node.children) {
|
|
468
|
+
fn(child);
|
|
469
|
+
loop(child);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
for (const child of this.node.children) {
|
|
473
|
+
if (child instanceof Stack) {
|
|
474
|
+
loop(child);
|
|
464
475
|
}
|
|
465
476
|
}
|
|
466
|
-
Aspects.of(this).add(new CodegenTypes());
|
|
467
477
|
}
|
|
468
478
|
// Functional Stack
|
|
469
479
|
// This is a magical global to avoid having to pass app everywhere.
|
package/constructs/Function.d.ts
CHANGED
package/constructs/Function.js
CHANGED
|
@@ -38,6 +38,7 @@ const supportedRuntimes = {
|
|
|
38
38
|
"python3.7": CDKRuntime.PYTHON_3_7,
|
|
39
39
|
"python3.8": CDKRuntime.PYTHON_3_8,
|
|
40
40
|
"python3.9": CDKRuntime.PYTHON_3_9,
|
|
41
|
+
"python3.10": CDKRuntime.PYTHON_3_10,
|
|
41
42
|
"dotnetcore1.0": CDKRuntime.DOTNET_CORE_1,
|
|
42
43
|
"dotnetcore2.0": CDKRuntime.DOTNET_CORE_2,
|
|
43
44
|
"dotnetcore2.1": CDKRuntime.DOTNET_CORE_2_1,
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
|
5
5
|
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
6
6
|
import { Code, Runtime, Architecture, Function as CdkFunction, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
|
|
7
7
|
import { Distribution, ViewerProtocolPolicy, AllowedMethods, CachedMethods, } from "aws-cdk-lib/aws-cloudfront";
|
|
8
|
-
import {
|
|
8
|
+
import { HttpOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
9
9
|
import { Rule, Schedule } from "aws-cdk-lib/aws-events";
|
|
10
10
|
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
|
|
11
11
|
import { Queue } from "aws-cdk-lib/aws-sqs";
|
|
@@ -29,7 +29,7 @@ import { toCdkSize } from "./util/size.js";
|
|
|
29
29
|
export class NextjsSite extends SsrSite {
|
|
30
30
|
constructor(scope, id, props) {
|
|
31
31
|
super(scope, id, {
|
|
32
|
-
buildCommand: "npx --yes open-next@2.0.
|
|
32
|
+
buildCommand: "npx --yes open-next@2.0.4 build",
|
|
33
33
|
...props,
|
|
34
34
|
});
|
|
35
35
|
this.deferredTaskCallbacks.push(() => {
|
|
@@ -282,9 +282,6 @@ export class NextjsSite extends SsrSite {
|
|
|
282
282
|
createCloudFrontDistributionForEdge() {
|
|
283
283
|
const { cdk } = this.props;
|
|
284
284
|
const cfDistributionProps = cdk?.distribution || {};
|
|
285
|
-
const s3Origin = new S3Origin(this.cdk.bucket, {
|
|
286
|
-
originPath: "/" + this.buildConfig.clientBuildS3KeyPrefix,
|
|
287
|
-
});
|
|
288
285
|
const cachePolicy = cdk?.serverCachePolicy ??
|
|
289
286
|
this.buildServerCachePolicy([
|
|
290
287
|
"accept",
|
|
@@ -292,7 +289,7 @@ export class NextjsSite extends SsrSite {
|
|
|
292
289
|
"next-router-prefetch",
|
|
293
290
|
"next-router-state-tree",
|
|
294
291
|
]);
|
|
295
|
-
const serverBehavior = this.buildDefaultBehaviorForEdge(
|
|
292
|
+
const serverBehavior = this.buildDefaultBehaviorForEdge(cachePolicy);
|
|
296
293
|
return new Distribution(this, "Distribution", {
|
|
297
294
|
// these values can be overwritten by cfDistributionProps
|
|
298
295
|
defaultRootObject: "",
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { IFunction as ICdkFunction, FunctionProps } from "aws-cdk-lib/aws-lambda
|
|
|
4
4
|
import { IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
5
5
|
import { Distribution, ICachePolicy, IResponseHeadersPolicy, BehaviorOptions, CachePolicy, Function as CfFunction, FunctionEventType as CfFunctionEventType } from "aws-cdk-lib/aws-cloudfront";
|
|
6
6
|
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
7
|
-
import { S3Origin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
8
7
|
import { SSTConstruct } from "./Construct.js";
|
|
9
8
|
import { NodeJSProps } from "./Function.js";
|
|
10
9
|
import { SsrFunction } from "./SsrFunction.js";
|
|
@@ -224,6 +223,7 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
224
223
|
private serverLambdaForDev?;
|
|
225
224
|
protected bucket: Bucket;
|
|
226
225
|
private cfFunction;
|
|
226
|
+
private s3Origin;
|
|
227
227
|
private distribution;
|
|
228
228
|
private hostedZone?;
|
|
229
229
|
private certificate?;
|
|
@@ -286,12 +286,13 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
286
286
|
private grantServerS3Permissions;
|
|
287
287
|
private grantServerCloudFrontPermissions;
|
|
288
288
|
private validateCloudFrontDistributionSettings;
|
|
289
|
+
private createCloudFrontS3Origin;
|
|
289
290
|
private createCloudFrontFunction;
|
|
290
291
|
protected createCloudFrontDistributionForRegional(): Distribution;
|
|
291
292
|
protected createCloudFrontDistributionForEdge(): Distribution;
|
|
292
293
|
protected buildDistributionDomainNames(): string[];
|
|
293
294
|
protected buildDefaultBehaviorForRegional(cachePolicy: ICachePolicy): BehaviorOptions;
|
|
294
|
-
protected buildDefaultBehaviorForEdge(
|
|
295
|
+
protected buildDefaultBehaviorForEdge(cachePolicy: ICachePolicy): BehaviorOptions;
|
|
295
296
|
protected buildBehaviorFunctionAssociations(): {
|
|
296
297
|
eventType: CfFunctionEventType;
|
|
297
298
|
function: CfFunction;
|
package/constructs/SsrSite.js
CHANGED
|
@@ -54,6 +54,7 @@ export class SsrSite extends Construct {
|
|
|
54
54
|
serverLambdaForDev;
|
|
55
55
|
bucket;
|
|
56
56
|
cfFunction;
|
|
57
|
+
s3Origin;
|
|
57
58
|
distribution;
|
|
58
59
|
hostedZone;
|
|
59
60
|
certificate;
|
|
@@ -79,7 +80,7 @@ export class SsrSite extends Construct {
|
|
|
79
80
|
useSites().add(id, this.constructor.name, this.props);
|
|
80
81
|
if (this.doNotDeploy) {
|
|
81
82
|
// @ts-ignore
|
|
82
|
-
this.cfFunction = this.bucket = this.distribution = null;
|
|
83
|
+
this.cfFunction = this.bucket = this.s3Origin = this.distribution = null;
|
|
83
84
|
this.serverLambdaForDev = this.createFunctionForDev();
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
@@ -103,6 +104,7 @@ export class SsrSite extends Construct {
|
|
|
103
104
|
this.certificate = this.createCertificate();
|
|
104
105
|
// Create CloudFront
|
|
105
106
|
this.validateCloudFrontDistributionSettings();
|
|
107
|
+
this.s3Origin = this.createCloudFrontS3Origin();
|
|
106
108
|
this.cfFunction = this.createCloudFrontFunction();
|
|
107
109
|
this.distribution = this.props.edge
|
|
108
110
|
? this.createCloudFrontDistributionForEdge()
|
|
@@ -502,6 +504,11 @@ export class SsrSite extends Construct {
|
|
|
502
504
|
throw new Error(`Do not configure the "cfDistribution.domainNames". Use the "customDomain" to configure the domain name.`);
|
|
503
505
|
}
|
|
504
506
|
}
|
|
507
|
+
createCloudFrontS3Origin() {
|
|
508
|
+
return new S3Origin(this.bucket, {
|
|
509
|
+
originPath: "/" + (this.buildConfig.clientBuildS3KeyPrefix ?? ""),
|
|
510
|
+
});
|
|
511
|
+
}
|
|
505
512
|
createCloudFrontFunction() {
|
|
506
513
|
return new CfFunction(this, "CloudFrontFunction", {
|
|
507
514
|
code: CfFunctionCode.fromInline(`
|
|
@@ -534,7 +541,6 @@ function handler(event) {
|
|
|
534
541
|
createCloudFrontDistributionForEdge() {
|
|
535
542
|
const { cdk } = this.props;
|
|
536
543
|
const cfDistributionProps = cdk?.distribution || {};
|
|
537
|
-
const s3Origin = new S3Origin(this.bucket);
|
|
538
544
|
const cachePolicy = cdk?.serverCachePolicy ?? this.buildServerCachePolicy();
|
|
539
545
|
return new Distribution(this, "Distribution", {
|
|
540
546
|
// these values can be overwritten by cfDistributionProps
|
|
@@ -544,7 +550,7 @@ function handler(event) {
|
|
|
544
550
|
// these values can NOT be overwritten by cfDistributionProps
|
|
545
551
|
domainNames: this.buildDistributionDomainNames(),
|
|
546
552
|
certificate: this.certificate,
|
|
547
|
-
defaultBehavior: this.buildDefaultBehaviorForEdge(
|
|
553
|
+
defaultBehavior: this.buildDefaultBehaviorForEdge(cachePolicy),
|
|
548
554
|
additionalBehaviors: {
|
|
549
555
|
...(cfDistributionProps.additionalBehaviors || {}),
|
|
550
556
|
},
|
|
@@ -595,12 +601,12 @@ function handler(event) {
|
|
|
595
601
|
],
|
|
596
602
|
};
|
|
597
603
|
}
|
|
598
|
-
buildDefaultBehaviorForEdge(
|
|
604
|
+
buildDefaultBehaviorForEdge(cachePolicy) {
|
|
599
605
|
const { cdk } = this.props;
|
|
600
606
|
const cfDistributionProps = cdk?.distribution || {};
|
|
601
607
|
return {
|
|
602
608
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
603
|
-
origin,
|
|
609
|
+
origin: this.s3Origin,
|
|
604
610
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
605
611
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
606
612
|
compress: true,
|
|
@@ -636,9 +642,7 @@ function handler(event) {
|
|
|
636
642
|
const publicDir = path.join(this.props.path, this.buildConfig.clientBuildOutputDir);
|
|
637
643
|
for (const item of fs.readdirSync(publicDir)) {
|
|
638
644
|
const isDir = fs.statSync(path.join(publicDir, item)).isDirectory();
|
|
639
|
-
this.distribution.addBehavior(isDir ? `${item}/*` : item,
|
|
640
|
-
originPath: "/" + (this.buildConfig.clientBuildS3KeyPrefix ?? ""),
|
|
641
|
-
}), {
|
|
645
|
+
this.distribution.addBehavior(isDir ? `${item}/*` : item, this.s3Origin, {
|
|
642
646
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
643
647
|
allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
|
|
644
648
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
package/package.json
CHANGED
package/runtime/handlers/node.js
CHANGED
|
@@ -177,7 +177,7 @@ export const useNodeHandler = Context.memo(async () => {
|
|
|
177
177
|
const json = JSON.parse(await fs
|
|
178
178
|
.readFile(path.join(src, "package.json"))
|
|
179
179
|
.then((x) => x.toString()));
|
|
180
|
-
fs.writeFile(path.join(input.out, "package.json"), JSON.stringify({
|
|
180
|
+
await fs.writeFile(path.join(input.out, "package.json"), JSON.stringify({
|
|
181
181
|
dependencies: Object.fromEntries(installPackages.map((x) => [x, json.dependencies?.[x] || "*"])),
|
|
182
182
|
}));
|
|
183
183
|
const cmd = ["npm install"];
|
|
@@ -17,6 +17,7 @@ const RUNTIME_MAP = {
|
|
|
17
17
|
"python3.7": Runtime.PYTHON_3_7,
|
|
18
18
|
"python3.8": Runtime.PYTHON_3_8,
|
|
19
19
|
"python3.9": Runtime.PYTHON_3_9,
|
|
20
|
+
"python3.10": Runtime.PYTHON_3_10,
|
|
20
21
|
};
|
|
21
22
|
export const usePythonHandler = Context.memo(async () => {
|
|
22
23
|
const workers = await useRuntimeWorkers();
|
package/sst.mjs
CHANGED
|
@@ -4505,7 +4505,7 @@ var init_node = __esm({
|
|
|
4505
4505
|
const json = JSON.parse(
|
|
4506
4506
|
await fs8.readFile(path8.join(src, "package.json")).then((x) => x.toString())
|
|
4507
4507
|
);
|
|
4508
|
-
fs8.writeFile(
|
|
4508
|
+
await fs8.writeFile(
|
|
4509
4509
|
path8.join(input.out, "package.json"),
|
|
4510
4510
|
JSON.stringify({
|
|
4511
4511
|
dependencies: Object.fromEntries(
|
|
@@ -4905,7 +4905,8 @@ var init_python = __esm({
|
|
|
4905
4905
|
"python3.6": Runtime.PYTHON_3_6,
|
|
4906
4906
|
"python3.7": Runtime.PYTHON_3_7,
|
|
4907
4907
|
"python3.8": Runtime.PYTHON_3_8,
|
|
4908
|
-
"python3.9": Runtime.PYTHON_3_9
|
|
4908
|
+
"python3.9": Runtime.PYTHON_3_9,
|
|
4909
|
+
"python3.10": Runtime.PYTHON_3_10
|
|
4909
4910
|
};
|
|
4910
4911
|
usePythonHandler = Context.memo(async () => {
|
|
4911
4912
|
const workers = await useRuntimeWorkers();
|