sst 2.32.1 → 2.33.0

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import { Stacks } from "../../stacks/index.js";
3
2
  import type { CloudAssembly } from "aws-cdk-lib/cx-api";
4
3
  interface Props {
@@ -1,2 +1 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  export declare function Functions(): JSX.Element;
@@ -67,6 +67,7 @@ export class AstroSite extends SsrSite {
67
67
  plan() {
68
68
  const { path: sitePath, edge, regional } = this.props;
69
69
  const buildMeta = AstroSite.getBuildMeta(join(sitePath, "dist", BUILD_META_FILE_NAME));
70
+ const isStatic = buildMeta.outputMode === "static";
70
71
  const serverConfig = {
71
72
  description: "Server handler for Astro",
72
73
  handler: join(sitePath, "dist", "server", "entry.handler"),
@@ -133,32 +134,41 @@ export class AstroSite extends SsrSite {
133
134
  })));
134
135
  }
135
136
  else {
136
- plan.origins.regionalServer = {
137
- type: "function",
138
- constructId: "ServerFunction",
139
- function: serverConfig,
140
- streaming: buildMeta.responseMode === "stream",
141
- };
142
- plan.origins.fallthroughServer = {
143
- type: "group",
144
- primaryOriginName: "staticsServer",
145
- fallbackOriginName: "regionalServer",
146
- fallbackStatusCodes: [403, 404],
147
- };
148
- plan.behaviors.push({
149
- cacheType: "server",
150
- cfFunction: "serverCfFunction",
151
- origin: "fallthroughServer",
152
- allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
153
- }, {
154
- cacheType: "static",
155
- pattern: `${buildMeta.clientBuildVersionedSubDir}/*`,
156
- origin: "staticsServer",
157
- }, ...(buildMeta.serverRoutes ?? regional?.serverRoutes ?? []).map((route) => ({
158
- cacheType: "server",
159
- pattern: route,
160
- origin: "regionalServer",
161
- })));
137
+ if (isStatic) {
138
+ plan.behaviors.push({
139
+ cacheType: "static",
140
+ cfFunction: "serverCfFunction",
141
+ origin: "staticsServer",
142
+ });
143
+ }
144
+ else {
145
+ plan.origins.regionalServer = {
146
+ type: "function",
147
+ constructId: "ServerFunction",
148
+ function: serverConfig,
149
+ streaming: buildMeta.responseMode === "stream",
150
+ };
151
+ plan.origins.fallthroughServer = {
152
+ type: "group",
153
+ primaryOriginName: "staticsServer",
154
+ fallbackOriginName: "regionalServer",
155
+ fallbackStatusCodes: [403, 404],
156
+ };
157
+ plan.behaviors.push({
158
+ cacheType: "server",
159
+ cfFunction: "serverCfFunction",
160
+ origin: "fallthroughServer",
161
+ allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
162
+ }, {
163
+ cacheType: "static",
164
+ pattern: `${buildMeta.clientBuildVersionedSubDir}/*`,
165
+ origin: "staticsServer",
166
+ }, ...(buildMeta.serverRoutes ?? regional?.serverRoutes ?? []).map((route) => ({
167
+ cacheType: "server",
168
+ pattern: route,
169
+ origin: "regionalServer",
170
+ })));
171
+ }
162
172
  buildMeta.routes
163
173
  .filter(({ type, route }) => type === "page" && /^\/\d{3}\/?$/.test(route))
164
174
  .forEach(({ route, prerender }) => {
@@ -170,6 +180,13 @@ export class AstroSite extends SsrSite {
170
180
  responsePagePath: prerender ? "/404.html" : "/404",
171
181
  responseHttpStatus: 404,
172
182
  });
183
+ if (isStatic) {
184
+ plan.errorResponses?.push({
185
+ httpStatus: 403,
186
+ responsePagePath: "/404.html",
187
+ responseHttpStatus: 404,
188
+ });
189
+ }
173
190
  break;
174
191
  case "/500":
175
192
  case "/500/":
@@ -44,6 +44,7 @@ export class Auth extends Construct {
44
44
  "ssm:GetParameter",
45
45
  "ssm:PutParameter",
46
46
  "ssm:DeleteParameter",
47
+ "ssm:DeleteParameters",
47
48
  ],
48
49
  resources: [
49
50
  `arn:${stack.partition}:ssm:${stack.region}:${stack.account}:parameter/*`,
@@ -472,6 +472,28 @@ export interface PythonProps {
472
472
  * ```
473
473
  */
474
474
  installCommands?: string[];
475
+ /**
476
+ * This options skips the Python bundle step. If you set this flag to `true`, you must ensure
477
+ * that either:
478
+ *
479
+ * 1. Your Python build does not require dependencies.
480
+ * 2. Or, you've already installed production dependencies before running `sst deploy`.
481
+ *
482
+ * One solution to accomplish this is to pre-compile your production dependencies to some
483
+ * temporary directory, using pip's `--platform` argument to ensure Python pre-built wheels are
484
+ * used and that your builds match your target Lambda runtime, and use SST's `copyFiles`
485
+ * option to make sure these dependencies make it into your final deployment build.
486
+ *
487
+ * This can also help speed up Python Lambdas which do not have external dependencies. By
488
+ * default, SST will still run a docker file that is essentially a no-op if you have no
489
+ * dependencies. This option will bypass that step, even if you have a `Pipfile`, a `poetry.toml`,
490
+ * a `pyproject.toml`, or a `requirements.txt` (which would normally trigger an all-dependencies
491
+ * Docker build).
492
+ *
493
+ * Enabling this option implies that you have accounted for all of the above and are handling
494
+ * your own build processes, and you are doing this for the sake of build optimization.
495
+ */
496
+ noDocker?: boolean;
475
497
  }
476
498
  /**
477
499
  * Used to configure Go bundling options
@@ -20,14 +20,14 @@ export interface ScriptProps {
20
20
  */
21
21
  params?: Record<string, any>;
22
22
  /**
23
- * By default, the script runs during each deployment. If a version is provided, the script will only run when the version changes.
23
+ * By default, the `onUpdate` function runs during each deployment. If a version is provided, it will only run when the version changes.
24
24
  *
25
25
  * @example
26
26
  * ```js
27
27
  * import { Script } from "sst/constructs";
28
28
  *
29
29
  * new Script(stack, "Script", {
30
- * onCreate: "src/script.create",
30
+ * onUpdate: "src/function.handler",
31
31
  * version: "v17",
32
32
  * });
33
33
  * ```
@@ -51,7 +51,7 @@ export interface ScriptProps {
51
51
  function?: FunctionProps;
52
52
  };
53
53
  /**
54
- * Specifies the function to be run once when the Script construct is created.
54
+ * Specifies the function to be run once when the Script construct is added to the stack or when the entire stack is deployed for the first time.
55
55
  * @example
56
56
  * ```js
57
57
  * new Script(stack, "Api", {
@@ -61,8 +61,7 @@ export interface ScriptProps {
61
61
  */
62
62
  onCreate?: FunctionDefinition;
63
63
  /**
64
- * Specifies the function to be run each time the Script construct is redeployed. If a version is provided,
65
- * the function is only executed when the version changes.
64
+ * Specifies the function to be run each time the Script construct is redeployed. If a version is provided, the function is only executed when the version changes.
66
65
  *
67
66
  * Note that the `onUpdate` function is not run during the initial creation of the Script construct.
68
67
  * For initial creation, use `onCreate`.
@@ -75,8 +74,7 @@ export interface ScriptProps {
75
74
  */
76
75
  onUpdate?: FunctionDefinition;
77
76
  /**
78
- * Specifies the function to be run once when the Script construct is deleted from the stack or
79
- * when the entire stack is removed from the app.
77
+ * Specifies the function to be run once when the Script construct is deleted from the stack or when the entire stack is removed from the app.
80
78
  * @example
81
79
  * ```js
82
80
  * new Script(stack, "Api", {
@@ -137,7 +137,7 @@ export interface StaticSiteProps {
137
137
  * @example
138
138
  * ```js
139
139
  * new StaticSite(stack, "frontend", {
140
- * purge: false
140
+ * purgeFiles: false
141
141
  * });
142
142
  * ```
143
143
  */
@@ -74,6 +74,7 @@ export class Auth extends Construct {
74
74
  "ssm:GetParameter",
75
75
  "ssm:PutParameter",
76
76
  "ssm:DeleteParameter",
77
+ "ssm:DeleteParameters",
77
78
  ],
78
79
  resources: [
79
80
  `arn:${stack.partition}:ssm:${stack.region}:${stack.account}:parameter/*`,
@@ -1,15 +1,13 @@
1
- export interface JobResources {
2
- }
3
1
  export interface JobTypes {
4
2
  }
5
- export type JobRunProps<T extends keyof JobResources> = {
3
+ export type JobRunProps<T extends keyof JobTypes> = {
6
4
  payload?: JobTypes[T];
7
5
  };
8
6
  export type JobType = {
9
- [T in keyof JobResources]: ReturnType<typeof JobControl<T>>;
7
+ [T in keyof JobTypes]: ReturnType<typeof JobControl<T>>;
10
8
  };
11
9
  export declare const Job: JobType;
12
- declare function JobControl<Name extends keyof JobResources>(name: Name, vars: Record<string, string>): {
10
+ declare function JobControl<Name extends keyof JobTypes>(name: Name, vars: Record<string, string>): {
13
11
  run(props: JobRunProps<Name>): Promise<{
14
12
  jobId: string;
15
13
  }>;
@@ -33,5 +31,5 @@ declare function JobControl<Name extends keyof JobResources>(name: Name, vars: R
33
31
  * })
34
32
  * ```
35
33
  */
36
- export declare function JobHandler<C extends keyof JobResources>(name: C, cb: (payload: JobTypes[C]) => void): (event: any) => void;
34
+ export declare function JobHandler<C extends keyof JobTypes>(name: C, cb: (payload: JobTypes[C]) => void): (event: any) => void;
37
35
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.32.1",
4
+ "version": "2.33.0",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -56,7 +56,7 @@
56
56
  "@trpc/server": "9.16.0",
57
57
  "adm-zip": "^0.5.10",
58
58
  "aws-cdk-lib": "2.101.1",
59
- "aws-iot-device-sdk": "^2.2.12",
59
+ "aws-iot-device-sdk": "^2.2.13",
60
60
  "aws-sdk": "^2.1326.0",
61
61
  "builtin-modules": "3.2.0",
62
62
  "cdk-assets": "2.101.1",
@@ -85,7 +85,7 @@
85
85
  "minimatch": "^6.1.6",
86
86
  "openid-client": "^5.1.8",
87
87
  "ora": "^6.1.2",
88
- "react": "18.2.0",
88
+ "react": "^18.0.0",
89
89
  "remeda": "^1.3.0",
90
90
  "sst-aws-cdk": "2.101.1",
91
91
  "tree-kill": "^1.2.2",
@@ -115,12 +115,12 @@
115
115
  "@types/cross-spawn": "^6.0.2",
116
116
  "@types/express": "^4.17.14",
117
117
  "@types/node": "^18.11.9",
118
- "@types/react": "^17.0.33",
118
+ "@types/react": "^18.0.28",
119
119
  "@types/uuid": "^8.3.4",
120
120
  "@types/ws": "^8.5.3",
121
121
  "@types/yargs": "^17.0.13",
122
122
  "archiver": "^5.3.1",
123
- "astro-sst": "2.32.1",
123
+ "astro-sst": "2.33.0",
124
124
  "async": "^3.2.4",
125
125
  "tsx": "^3.12.1",
126
126
  "typescript": "^5.2.2",
@@ -7,6 +7,7 @@ import { Runtime } from "aws-cdk-lib/aws-lambda";
7
7
  import { bundle } from "./pythonBundling.js";
8
8
  import os from "os";
9
9
  import url from "url";
10
+ import fs from "fs/promises";
10
11
  const RUNTIME_MAP = {
11
12
  "python2.7": Runtime.PYTHON_2_7,
12
13
  "python3.6": Runtime.PYTHON_3_6,
@@ -88,20 +89,21 @@ export const usePythonHandler = () => {
88
89
  type: "error",
89
90
  errors: [`Could not find src for ${input.props.handler}`],
90
91
  };
91
- bundle({
92
- installCommands: input.props.python?.installCommands,
93
- entry: src,
94
- runtime: RUNTIME_MAP[input.props.runtime],
95
- architecture: input.props.architecture,
96
- outputPathSuffix: ".",
97
- out: input.out,
98
- });
99
- /*
92
+ if (input.props.python?.noDocker !== true) {
93
+ bundle({
94
+ installCommands: input.props.python?.installCommands,
95
+ entry: src,
96
+ runtime: RUNTIME_MAP[input.props.runtime],
97
+ architecture: input.props.architecture,
98
+ outputPathSuffix: ".",
99
+ out: input.out,
100
+ });
101
+ }
100
102
  await fs.cp(src, input.out, {
101
- recursive: true,
102
- filter: (src) => !src.includes(".sst"),
103
+ recursive: true,
104
+ filter: (src) => !src.includes(".sst"),
103
105
  });
104
-
106
+ /*
105
107
  if (await existsAsync(path.join(src, "Pipfile"))) {
106
108
  await execAsync("pipenv requirements > requirements.txt", {
107
109
  cwd: input.out,
@@ -46,10 +46,6 @@ export function bundle(options) {
46
46
  if (hasDeps || hasInstallCommands) {
47
47
  image.cp(`${BUNDLER_DEPENDENCIES_CACHE}/.`, outputPath);
48
48
  }
49
- // Copy source code to the bundle.
50
- fs.cpSync(entry, outputPath, {
51
- recursive: true,
52
- });
53
49
  }
54
50
  /**
55
51
  * Checks to see if the `entry` directory contains a type of dependency that