sst 2.5.4 → 2.5.6
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/bind.js +89 -64
- package/cli/commands/version.js +1 -0
- package/config.js +10 -10
- package/constructs/Api.d.ts +1 -1
- package/constructs/Api.js +1 -1
- package/constructs/ApiGatewayV1Api.d.ts +1 -1
- package/constructs/ApiGatewayV1Api.js +1 -1
- package/constructs/AppSyncApi.d.ts +1 -1
- package/constructs/AppSyncApi.js +1 -1
- package/constructs/Auth.d.ts +1 -1
- package/constructs/Auth.js +1 -1
- package/constructs/Bucket.d.ts +1 -1
- package/constructs/Bucket.js +1 -1
- package/constructs/Cognito.d.ts +1 -1
- package/constructs/Cognito.js +1 -1
- package/constructs/Cron.d.ts +1 -1
- package/constructs/Cron.js +1 -1
- package/constructs/EventBus.d.ts +1 -1
- package/constructs/EventBus.js +1 -1
- package/constructs/Function.d.ts +1 -1
- package/constructs/Function.js +1 -1
- package/constructs/Job.d.ts +38 -2
- package/constructs/Job.js +4 -2
- package/constructs/KinesisStream.d.ts +1 -1
- package/constructs/KinesisStream.js +1 -1
- package/constructs/Parameter.d.ts +1 -1
- package/constructs/Parameter.js +1 -1
- package/constructs/Queue.d.ts +1 -1
- package/constructs/Queue.js +1 -1
- package/constructs/RDS.d.ts +2 -2
- package/constructs/RDS.js +1 -1
- package/constructs/Script.d.ts +2 -2
- package/constructs/Script.js +1 -1
- package/constructs/Secret.d.ts +1 -1
- package/constructs/Secret.js +1 -1
- package/constructs/SsrSite.js +5 -1
- package/constructs/Stack.d.ts +1 -1
- package/constructs/Stack.js +1 -1
- package/constructs/StaticSite.d.ts +1 -1
- package/constructs/StaticSite.js +1 -1
- package/constructs/Table.d.ts +1 -1
- package/constructs/Table.js +1 -1
- package/constructs/Topic.d.ts +1 -1
- package/constructs/Topic.js +1 -1
- package/constructs/WebSocketApi.d.ts +1 -1
- package/constructs/WebSocketApi.js +1 -1
- package/constructs/future/Auth.d.ts +1 -1
- package/constructs/future/Auth.js +1 -1
- package/package.json +1 -1
- package/project.d.ts +7 -0
- package/project.js +35 -8
- package/sst.mjs +126 -82
- package/support/bootstrap-metadata-function/index.mjs +238 -238
- package/support/custom-resources/index.mjs +238 -238
package/constructs/Script.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface ScriptProps {
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```js
|
|
11
|
-
* import { Script } from "
|
|
11
|
+
* import { Script } from "sst/constructs";
|
|
12
12
|
*
|
|
13
13
|
* new Script(stack, "Script", {
|
|
14
14
|
* onCreate: "src/script.create",
|
|
@@ -76,7 +76,7 @@ export interface ScriptProps {
|
|
|
76
76
|
* @example
|
|
77
77
|
*
|
|
78
78
|
* ```js
|
|
79
|
-
* import { Script } from "
|
|
79
|
+
* import { Script } from "sst/constructs";
|
|
80
80
|
*
|
|
81
81
|
* new Script(stack, "Script", {
|
|
82
82
|
* onCreate: "src/function.create",
|
package/constructs/Script.js
CHANGED
|
@@ -14,7 +14,7 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
|
14
14
|
* @example
|
|
15
15
|
*
|
|
16
16
|
* ```js
|
|
17
|
-
* import { Script } from "
|
|
17
|
+
* import { Script } from "sst/constructs";
|
|
18
18
|
*
|
|
19
19
|
* new Script(stack, "Script", {
|
|
20
20
|
* onCreate: "src/function.create",
|
package/constructs/Secret.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
|
8
8
|
* ### Using the minimal config
|
|
9
9
|
*
|
|
10
10
|
* ```js
|
|
11
|
-
* import { Config } from "
|
|
11
|
+
* import { Config } from "sst/constructs";
|
|
12
12
|
*
|
|
13
13
|
* new Config.Secret(stack, "STRIPE_KEY");
|
|
14
14
|
* ```
|
package/constructs/Secret.js
CHANGED
|
@@ -8,7 +8,7 @@ import { getParameterPath, getParameterFallbackPath, } from "./util/functionBind
|
|
|
8
8
|
* ### Using the minimal config
|
|
9
9
|
*
|
|
10
10
|
* ```js
|
|
11
|
-
* import { Config } from "
|
|
11
|
+
* import { Config } from "sst/constructs";
|
|
12
12
|
*
|
|
13
13
|
* new Config.Secret(stack, "STRIPE_KEY");
|
|
14
14
|
* ```
|
package/constructs/SsrSite.js
CHANGED
|
@@ -165,10 +165,11 @@ export class SsrSite extends Construct {
|
|
|
165
165
|
* ```
|
|
166
166
|
*/
|
|
167
167
|
attachPermissions(permissions) {
|
|
168
|
+
this.serverLambdaForDev?.attachPermissions(permissions);
|
|
169
|
+
this.serverLambdaForEdge?.attachPermissions(permissions);
|
|
168
170
|
if (this.serverLambdaForRegional) {
|
|
169
171
|
attachPermissionsToRole(this.serverLambdaForRegional.role, permissions);
|
|
170
172
|
}
|
|
171
|
-
this.serverLambdaForEdge?.attachPermissions(permissions);
|
|
172
173
|
}
|
|
173
174
|
/** @internal */
|
|
174
175
|
getConstructMetadata() {
|
|
@@ -432,6 +433,9 @@ export class SsrSite extends Construct {
|
|
|
432
433
|
environment,
|
|
433
434
|
permissions,
|
|
434
435
|
role,
|
|
436
|
+
// Force enable live dev to prevent the function handler to be built
|
|
437
|
+
// in the case user set "enableLiveDev: false" on the app or stack.
|
|
438
|
+
enableLiveDev: true,
|
|
435
439
|
});
|
|
436
440
|
fn._doNotAllowOthersToBind = true;
|
|
437
441
|
return fn;
|
package/constructs/Stack.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type StackProps = cdk.StackProps;
|
|
|
11
11
|
* @example
|
|
12
12
|
*
|
|
13
13
|
* ```js
|
|
14
|
-
* import { StackContext } from "
|
|
14
|
+
* import { StackContext } from "sst/constructs";
|
|
15
15
|
*
|
|
16
16
|
* export function MyStack({ stack }: StackContext) {
|
|
17
17
|
* // Define your stack
|
package/constructs/Stack.js
CHANGED
|
@@ -13,7 +13,7 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
|
13
13
|
* @example
|
|
14
14
|
*
|
|
15
15
|
* ```js
|
|
16
|
-
* import { StackContext } from "
|
|
16
|
+
* import { StackContext } from "sst/constructs";
|
|
17
17
|
*
|
|
18
18
|
* export function MyStack({ stack }: StackContext) {
|
|
19
19
|
* // Define your stack
|
|
@@ -273,7 +273,7 @@ export interface StaticSiteCdkDistributionProps extends BaseSiteCdkDistributionP
|
|
|
273
273
|
* Deploys a plain HTML website in the `path/to/src` directory.
|
|
274
274
|
*
|
|
275
275
|
* ```js
|
|
276
|
-
* import { StaticSite } from "
|
|
276
|
+
* import { StaticSite } from "sst/constructs";
|
|
277
277
|
*
|
|
278
278
|
* new StaticSite(stack, "Site", {
|
|
279
279
|
* path: "path/to/src",
|
package/constructs/StaticSite.js
CHANGED
|
@@ -34,7 +34,7 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
|
34
34
|
* Deploys a plain HTML website in the `path/to/src` directory.
|
|
35
35
|
*
|
|
36
36
|
* ```js
|
|
37
|
-
* import { StaticSite } from "
|
|
37
|
+
* import { StaticSite } from "sst/constructs";
|
|
38
38
|
*
|
|
39
39
|
* new StaticSite(stack, "Site", {
|
|
40
40
|
* path: "path/to/src",
|
package/constructs/Table.d.ts
CHANGED
|
@@ -259,7 +259,7 @@ export interface TableProps {
|
|
|
259
259
|
* Deploys a plain HTML website in the `path/to/src` directory.
|
|
260
260
|
*
|
|
261
261
|
* ```js
|
|
262
|
-
* import { Table } from "
|
|
262
|
+
* import { Table } from "sst/constructs";
|
|
263
263
|
*
|
|
264
264
|
* new Table(stack, "Notes", {
|
|
265
265
|
* fields: {
|
package/constructs/Table.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Function as Fn, } from "./Function.js";
|
|
|
15
15
|
* Deploys a plain HTML website in the `path/to/src` directory.
|
|
16
16
|
*
|
|
17
17
|
* ```js
|
|
18
|
-
* import { Table } from "
|
|
18
|
+
* import { Table } from "sst/constructs";
|
|
19
19
|
*
|
|
20
20
|
* new Table(stack, "Notes", {
|
|
21
21
|
* fields: {
|
package/constructs/Topic.d.ts
CHANGED
package/constructs/Topic.js
CHANGED
|
@@ -202,7 +202,7 @@ export interface WebSocketApiCdkStageProps extends Omit<apig.WebSocketStageProps
|
|
|
202
202
|
*
|
|
203
203
|
* @example
|
|
204
204
|
* ```js
|
|
205
|
-
* import { WebSocketApi } from "
|
|
205
|
+
* import { WebSocketApi } from "sst/constructs";
|
|
206
206
|
*
|
|
207
207
|
* new WebSocketApi(stack, "Api", {
|
|
208
208
|
* routes: {
|
|
@@ -18,7 +18,7 @@ import * as apigV2AccessLog from "./util/apiGatewayV2AccessLog.js";
|
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```js
|
|
21
|
-
* import { WebSocketApi } from "
|
|
21
|
+
* import { WebSocketApi } from "sst/constructs";
|
|
22
22
|
*
|
|
23
23
|
* new WebSocketApi(stack, "Api", {
|
|
24
24
|
* routes: {
|
|
@@ -55,7 +55,7 @@ export interface ApiAttachmentProps {
|
|
|
55
55
|
* SST Auth is a lightweight authentication solution for your applications. With a simple set of configuration you can deploy a function attached to your API that can handle various authentication flows. *
|
|
56
56
|
* @example
|
|
57
57
|
* ```
|
|
58
|
-
* import { Auth } from "
|
|
58
|
+
* import { Auth } from "sst/constructs"
|
|
59
59
|
*
|
|
60
60
|
* new Auth(stack, "auth", {
|
|
61
61
|
* authenticator: "functions/authenticator.handler"
|
|
@@ -9,7 +9,7 @@ import { CustomResource } from "aws-cdk-lib";
|
|
|
9
9
|
* SST Auth is a lightweight authentication solution for your applications. With a simple set of configuration you can deploy a function attached to your API that can handle various authentication flows. *
|
|
10
10
|
* @example
|
|
11
11
|
* ```
|
|
12
|
-
* import { Auth } from "
|
|
12
|
+
* import { Auth } from "sst/constructs"
|
|
13
13
|
*
|
|
14
14
|
* new Auth(stack, "auth", {
|
|
15
15
|
* authenticator: "functions/authenticator.handler"
|
package/package.json
CHANGED
package/project.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ interface Project {
|
|
|
33
33
|
}>;
|
|
34
34
|
version: string;
|
|
35
35
|
cdkVersion: string;
|
|
36
|
+
constructsVersion: string;
|
|
36
37
|
paths: {
|
|
37
38
|
root: string;
|
|
38
39
|
config: string;
|
|
@@ -55,4 +56,10 @@ interface GlobalOptions {
|
|
|
55
56
|
region?: string;
|
|
56
57
|
}
|
|
57
58
|
export declare function initProject(globals: GlobalOptions): Promise<void>;
|
|
59
|
+
declare function sanitizeStageName(stage: string): string;
|
|
60
|
+
declare function isValidStageName(stage: string): boolean;
|
|
61
|
+
export declare const exportedForTesting: {
|
|
62
|
+
sanitizeStageName: typeof sanitizeStageName;
|
|
63
|
+
isValidStageName: typeof isValidStageName;
|
|
64
|
+
};
|
|
58
65
|
export {};
|
package/project.js
CHANGED
|
@@ -47,12 +47,16 @@ export async function initProject(globals) {
|
|
|
47
47
|
config.stage ||
|
|
48
48
|
(await usePersonalStage(out)) ||
|
|
49
49
|
(await promptPersonalStage(out));
|
|
50
|
-
const [version, cdkVersion] = await (async () => {
|
|
50
|
+
const [version, cdkVersion, constructsVersion] = await (async () => {
|
|
51
51
|
try {
|
|
52
52
|
const packageJson = JSON.parse(await fs
|
|
53
53
|
.readFile(url.fileURLToPath(new URL("./package.json", import.meta.url)))
|
|
54
54
|
.then((x) => x.toString()));
|
|
55
|
-
return [
|
|
55
|
+
return [
|
|
56
|
+
packageJson.version,
|
|
57
|
+
packageJson.dependencies["aws-cdk-lib"],
|
|
58
|
+
packageJson.dependencies["constructs"],
|
|
59
|
+
];
|
|
56
60
|
}
|
|
57
61
|
catch {
|
|
58
62
|
return ["unknown", "unknown"];
|
|
@@ -61,6 +65,7 @@ export async function initProject(globals) {
|
|
|
61
65
|
const project = {
|
|
62
66
|
version,
|
|
63
67
|
cdkVersion,
|
|
68
|
+
constructsVersion,
|
|
64
69
|
config: {
|
|
65
70
|
...config,
|
|
66
71
|
stage,
|
|
@@ -112,21 +117,29 @@ async function usePersonalStage(out) {
|
|
|
112
117
|
return;
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
async function promptPersonalStage(out) {
|
|
120
|
+
async function promptPersonalStage(out, isRetry) {
|
|
116
121
|
const readline = await import("readline");
|
|
117
122
|
const rl = readline.createInterface({
|
|
118
123
|
input: process.stdin,
|
|
119
124
|
output: process.stdout,
|
|
120
125
|
});
|
|
121
|
-
|
|
122
|
-
const suggested = os.userInfo().username;
|
|
123
|
-
|
|
126
|
+
const stage = await new Promise((resolve) => {
|
|
127
|
+
const suggested = sanitizeStageName(os.userInfo().username) || "local";
|
|
128
|
+
const instruction = !isRetry
|
|
129
|
+
? `Please enter a name you’d like to use for your personal stage.`
|
|
130
|
+
: `Please enter a name that starts with a letter, followed by letters, numbers, or hyphens.`;
|
|
131
|
+
rl.question(`${instruction} Or hit enter to use ${blue(suggested)}: `, async (input) => {
|
|
124
132
|
rl.close();
|
|
125
|
-
const result = input
|
|
126
|
-
await fs.writeFile(path.join(out, "stage"), result);
|
|
133
|
+
const result = input === "" ? suggested : input;
|
|
127
134
|
resolve(result);
|
|
128
135
|
});
|
|
129
136
|
});
|
|
137
|
+
// Validate stage name
|
|
138
|
+
if (isValidStageName(stage)) {
|
|
139
|
+
await fs.writeFile(path.join(out, "stage"), stage);
|
|
140
|
+
return stage;
|
|
141
|
+
}
|
|
142
|
+
return await promptPersonalStage(out, true);
|
|
130
143
|
}
|
|
131
144
|
async function findRoot() {
|
|
132
145
|
async function find(dir) {
|
|
@@ -143,3 +156,17 @@ async function findRoot() {
|
|
|
143
156
|
const result = await find(process.cwd());
|
|
144
157
|
return result;
|
|
145
158
|
}
|
|
159
|
+
function sanitizeStageName(stage) {
|
|
160
|
+
return (stage
|
|
161
|
+
.replace(/[^A-Za-z0-9-]/g, "-")
|
|
162
|
+
.replace(/--+/g, "-")
|
|
163
|
+
.replace(/^[^A-Za-z]/, "")
|
|
164
|
+
.replace(/-$/, "") || "local");
|
|
165
|
+
}
|
|
166
|
+
function isValidStageName(stage) {
|
|
167
|
+
return Boolean(stage.match(/^[A-Za-z][A-Za-z0-9-]*$/));
|
|
168
|
+
}
|
|
169
|
+
export const exportedForTesting = {
|
|
170
|
+
sanitizeStageName,
|
|
171
|
+
isValidStageName,
|
|
172
|
+
};
|