sst 2.5.4 → 2.5.5
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/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/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 +1 -0
- package/project.js +7 -2
- package/sst.mjs +93 -63
- package/support/bootstrap-metadata-function/index.mjs +238 -238
- package/support/custom-resources/index.mjs +238 -238
|
@@ -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
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,
|
package/sst.mjs
CHANGED
|
@@ -353,14 +353,18 @@ async function initProject(globals) {
|
|
|
353
353
|
}();
|
|
354
354
|
const config = await Promise.resolve(sstConfig.config(globals));
|
|
355
355
|
const stage = globals.stage || config.stage || await usePersonalStage(out) || await promptPersonalStage(out);
|
|
356
|
-
const [version2, cdkVersion] = await (async () => {
|
|
356
|
+
const [version2, cdkVersion, constructsVersion] = await (async () => {
|
|
357
357
|
try {
|
|
358
358
|
const packageJson = JSON.parse(
|
|
359
359
|
await fs4.readFile(
|
|
360
360
|
url2.fileURLToPath(new URL("./package.json", import.meta.url))
|
|
361
361
|
).then((x) => x.toString())
|
|
362
362
|
);
|
|
363
|
-
return [
|
|
363
|
+
return [
|
|
364
|
+
packageJson.version,
|
|
365
|
+
packageJson.dependencies["aws-cdk-lib"],
|
|
366
|
+
packageJson.dependencies["constructs"]
|
|
367
|
+
];
|
|
364
368
|
} catch {
|
|
365
369
|
return ["unknown", "unknown"];
|
|
366
370
|
}
|
|
@@ -368,6 +372,7 @@ async function initProject(globals) {
|
|
|
368
372
|
const project = {
|
|
369
373
|
version: version2,
|
|
370
374
|
cdkVersion,
|
|
375
|
+
constructsVersion,
|
|
371
376
|
config: {
|
|
372
377
|
...config,
|
|
373
378
|
stage,
|
|
@@ -7113,12 +7118,7 @@ Are you sure you want to run this stage in dev mode? [y/N] `,
|
|
|
7113
7118
|
// src/cli/commands/bind.ts
|
|
7114
7119
|
init_error();
|
|
7115
7120
|
import path18 from "path";
|
|
7116
|
-
var
|
|
7117
|
-
NextjsSite: "next.config",
|
|
7118
|
-
AstroSite: "astro.config",
|
|
7119
|
-
RemixSite: "remix.config",
|
|
7120
|
-
SolidStartSite: "vite.config",
|
|
7121
|
-
SlsNextjsSite: "next.config"
|
|
7121
|
+
var OutdatedMetadataError = class extends Error {
|
|
7122
7122
|
};
|
|
7123
7123
|
var bind = (program2) => program2.command(
|
|
7124
7124
|
["bind <command..>", "env <command..>"],
|
|
@@ -7147,21 +7147,32 @@ var bind = (program2) => program2.command(
|
|
|
7147
7147
|
const bus = useBus2();
|
|
7148
7148
|
const project = useProject2();
|
|
7149
7149
|
const command = args.command?.join(" ");
|
|
7150
|
-
const
|
|
7150
|
+
const isSite = await isRunningInSite();
|
|
7151
7151
|
let p;
|
|
7152
7152
|
let timer;
|
|
7153
7153
|
let siteConfigCache;
|
|
7154
7154
|
if (!command) {
|
|
7155
7155
|
throw new VisibleError(
|
|
7156
|
-
`Command is required, e.g. sst bind ${
|
|
7156
|
+
`Command is required, e.g. sst bind ${isSite ? "next dev" : "vitest run"}`
|
|
7157
7157
|
);
|
|
7158
7158
|
}
|
|
7159
|
-
|
|
7160
|
-
if (!initialMetadata && !isSsrSite) {
|
|
7159
|
+
if (!isSite) {
|
|
7161
7160
|
Logger2.debug("Running in script mode.");
|
|
7162
7161
|
return await bindScript();
|
|
7163
7162
|
}
|
|
7164
|
-
|
|
7163
|
+
try {
|
|
7164
|
+
await bindSite("init");
|
|
7165
|
+
} catch (e) {
|
|
7166
|
+
if (e instanceof OutdatedMetadataError) {
|
|
7167
|
+
Colors2.line(
|
|
7168
|
+
Colors2.warning(
|
|
7169
|
+
"Warning: This was deployed with an old version of SST. Run `sst dev` or `sst deploy` to update."
|
|
7170
|
+
)
|
|
7171
|
+
);
|
|
7172
|
+
return await bindScript();
|
|
7173
|
+
}
|
|
7174
|
+
throw e;
|
|
7175
|
+
}
|
|
7165
7176
|
bus.subscribe(
|
|
7166
7177
|
"stacks.metadata.updated",
|
|
7167
7178
|
() => bindSite("metadata_updated")
|
|
@@ -7172,9 +7183,7 @@ var bind = (program2) => program2.command(
|
|
|
7172
7183
|
);
|
|
7173
7184
|
bus.subscribe("config.secret.updated", (payload) => {
|
|
7174
7185
|
const secretName = payload.properties.name;
|
|
7175
|
-
if (siteConfigCache?.secrets
|
|
7176
|
-
return;
|
|
7177
|
-
if (!siteConfigCache.secrets.includes(secretName))
|
|
7186
|
+
if (!(siteConfigCache?.secrets || []).includes(secretName))
|
|
7178
7187
|
return;
|
|
7179
7188
|
Colors2.line(
|
|
7180
7189
|
`
|
|
@@ -7183,26 +7192,47 @@ var bind = (program2) => program2.command(
|
|
|
7183
7192
|
);
|
|
7184
7193
|
bindSite("secrets_updated");
|
|
7185
7194
|
});
|
|
7186
|
-
async function
|
|
7195
|
+
async function isRunningInSite() {
|
|
7187
7196
|
const { existsAsync: existsAsync3 } = await Promise.resolve().then(() => (init_fs(), fs_exports));
|
|
7188
7197
|
const { readFile } = await import("fs/promises");
|
|
7198
|
+
const SITE_CONFIGS = [
|
|
7199
|
+
{ file: "next.config", multiExtension: true },
|
|
7200
|
+
{ file: "astro.config", multiExtension: true },
|
|
7201
|
+
{ file: "remix.config", multiExtension: true },
|
|
7202
|
+
{ file: "svelte.config", multiExtension: true },
|
|
7203
|
+
{ file: "gatsby-config", multiExtension: true },
|
|
7204
|
+
{ file: "angular.json" },
|
|
7205
|
+
{ file: "ember-cli-build.js" },
|
|
7206
|
+
{
|
|
7207
|
+
file: "vite.config",
|
|
7208
|
+
multiExtension: true,
|
|
7209
|
+
match: /solid-start|plugin-vue|plugin-react|@preact\/preset-vite/
|
|
7210
|
+
},
|
|
7211
|
+
{ file: "package.json", match: /react-scripts/ },
|
|
7212
|
+
{ file: "index.html" }
|
|
7213
|
+
];
|
|
7189
7214
|
const results = await Promise.all(
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7215
|
+
SITE_CONFIGS.map((site) => {
|
|
7216
|
+
const files = site.multiExtension ? [".js", ".cjs", ".mjs", ".ts"].map(
|
|
7217
|
+
(ext) => `${site.file}${ext}`
|
|
7218
|
+
) : [site.file];
|
|
7219
|
+
return files.map(async (file) => {
|
|
7220
|
+
const exists = await existsAsync3(file);
|
|
7221
|
+
if (!exists)
|
|
7222
|
+
return false;
|
|
7223
|
+
if (site.match) {
|
|
7224
|
+
const content = await readFile(file);
|
|
7225
|
+
return content.toString().match(site.match);
|
|
7196
7226
|
}
|
|
7197
|
-
return
|
|
7198
|
-
})
|
|
7199
|
-
).flat()
|
|
7227
|
+
return true;
|
|
7228
|
+
});
|
|
7229
|
+
}).flat()
|
|
7200
7230
|
);
|
|
7201
7231
|
return results.some(Boolean);
|
|
7202
7232
|
}
|
|
7203
7233
|
async function bindSite(reason) {
|
|
7204
|
-
const siteMetadata =
|
|
7205
|
-
const siteConfig = await
|
|
7234
|
+
const siteMetadata = await getSiteMetadataUntilAvailable();
|
|
7235
|
+
const siteConfig = await parseSiteMetadata(siteMetadata);
|
|
7206
7236
|
if (reason === "metadata_updated") {
|
|
7207
7237
|
if (areEnvsSame(siteConfig.envs, siteConfigCache?.envs || {}))
|
|
7208
7238
|
return;
|
|
@@ -7247,42 +7277,13 @@ var bind = (program2) => program2.command(
|
|
|
7247
7277
|
...await localIamCredentials()
|
|
7248
7278
|
});
|
|
7249
7279
|
}
|
|
7250
|
-
async function parseSiteConfig(metadata3) {
|
|
7251
|
-
const { LambdaClient: LambdaClient2, GetFunctionCommand } = await import("@aws-sdk/client-lambda");
|
|
7252
|
-
const { useAWSClient: useAWSClient2 } = await Promise.resolve().then(() => (init_credentials(), credentials_exports));
|
|
7253
|
-
const isBindSupported = metadata3.type !== "StaticSite" && metadata3.type !== "SlsNextjsSite";
|
|
7254
|
-
if (!isBindSupported) {
|
|
7255
|
-
return { envs: metadata3.data.environment };
|
|
7256
|
-
}
|
|
7257
|
-
const lambda = useAWSClient2(LambdaClient2);
|
|
7258
|
-
const { Configuration: functionConfig } = await lambda.send(
|
|
7259
|
-
new GetFunctionCommand({
|
|
7260
|
-
FunctionName: metadata3.data.server
|
|
7261
|
-
})
|
|
7262
|
-
);
|
|
7263
|
-
return {
|
|
7264
|
-
role: functionConfig?.Role,
|
|
7265
|
-
envs: functionConfig?.Environment?.Variables || {},
|
|
7266
|
-
secrets: metadata3.data.secrets
|
|
7267
|
-
};
|
|
7268
|
-
}
|
|
7269
7280
|
async function getSiteMetadataUntilAvailable() {
|
|
7270
7281
|
const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
|
|
7271
7282
|
const spinner = createSpinner2({});
|
|
7272
7283
|
while (true) {
|
|
7273
7284
|
const data2 = await getSiteMetadata();
|
|
7274
7285
|
if (!data2) {
|
|
7275
|
-
spinner.start(
|
|
7276
|
-
"Make sure `sst dev` is running..."
|
|
7277
|
-
);
|
|
7278
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
7279
|
-
continue;
|
|
7280
|
-
}
|
|
7281
|
-
const isBindSupported = data2.type !== "StaticSite" && data2.type !== "SlsNextjsSite";
|
|
7282
|
-
if (isBindSupported && !data2.data.server || !isBindSupported && !data2.data.environment) {
|
|
7283
|
-
spinner.start(
|
|
7284
|
-
"This was deployed with an old version of SST. Make sure to restart `sst dev`..."
|
|
7285
|
-
);
|
|
7286
|
+
spinner.start("Make sure `sst dev` is running...");
|
|
7286
7287
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
7287
7288
|
continue;
|
|
7288
7289
|
}
|
|
@@ -7294,12 +7295,40 @@ var bind = (program2) => program2.command(
|
|
|
7294
7295
|
const { metadata: metadata3 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
|
|
7295
7296
|
const metadataData = await metadata3();
|
|
7296
7297
|
return Object.values(metadataData).flat().filter(
|
|
7297
|
-
(c) =>
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7298
|
+
(c) => [
|
|
7299
|
+
"StaticSite",
|
|
7300
|
+
"NextjsSite",
|
|
7301
|
+
"AstroSite",
|
|
7302
|
+
"RemixSite",
|
|
7303
|
+
"SolidStartSite",
|
|
7304
|
+
"SlsNextjsSite"
|
|
7305
|
+
].includes(c.type)
|
|
7306
|
+
).find((c) => {
|
|
7307
|
+
const isSsr = c.type !== "StaticSite" && c.type !== "SlsNextjsSite";
|
|
7308
|
+
if (!c.data.path || isSsr && !c.data.server || !isSsr && !c.data.environment) {
|
|
7309
|
+
throw new OutdatedMetadataError();
|
|
7310
|
+
}
|
|
7311
|
+
return path18.resolve(project.paths.root, c.data.path) === process.cwd();
|
|
7312
|
+
});
|
|
7313
|
+
}
|
|
7314
|
+
async function parseSiteMetadata(metadata3) {
|
|
7315
|
+
const { LambdaClient: LambdaClient2, GetFunctionCommand } = await import("@aws-sdk/client-lambda");
|
|
7316
|
+
const { useAWSClient: useAWSClient2 } = await Promise.resolve().then(() => (init_credentials(), credentials_exports));
|
|
7317
|
+
const isBindSupported = metadata3.type !== "StaticSite" && metadata3.type !== "SlsNextjsSite";
|
|
7318
|
+
if (!isBindSupported) {
|
|
7319
|
+
return { envs: metadata3.data.environment };
|
|
7320
|
+
}
|
|
7321
|
+
const lambda = useAWSClient2(LambdaClient2);
|
|
7322
|
+
const { Configuration: functionConfig } = await lambda.send(
|
|
7323
|
+
new GetFunctionCommand({
|
|
7324
|
+
FunctionName: metadata3.data.server
|
|
7325
|
+
})
|
|
7302
7326
|
);
|
|
7327
|
+
return {
|
|
7328
|
+
role: functionConfig?.Role,
|
|
7329
|
+
envs: functionConfig?.Environment?.Variables || {},
|
|
7330
|
+
secrets: metadata3.data.secrets
|
|
7331
|
+
};
|
|
7303
7332
|
}
|
|
7304
7333
|
async function assumeSsrRole(roleArn) {
|
|
7305
7334
|
const { STSClient: STSClient2, AssumeRoleCommand } = await import("@aws-sdk/client-sts");
|
|
@@ -8034,6 +8063,7 @@ var version = (program2) => program2.command(
|
|
|
8034
8063
|
const project = useProject2();
|
|
8035
8064
|
Colors2.line(Colors2.bold(`SST:`), `v${project.version}`);
|
|
8036
8065
|
Colors2.line(Colors2.bold(`CDK:`), `v${project.cdkVersion}`);
|
|
8066
|
+
Colors2.line(Colors2.bold(`Constructs:`), `v${project.constructsVersion}`);
|
|
8037
8067
|
}
|
|
8038
8068
|
);
|
|
8039
8069
|
|