sst 2.0.0-rc.2 → 2.0.0-rc.21
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/bootstrap.js +3 -3
- package/bus.d.ts +3 -3
- package/cache.js +1 -1
- package/cdk/deploy-stack.d.ts +2 -2
- package/cdk/deploy-stack.js +24 -16
- package/cli/commands/bind.js +2 -2
- package/cli/commands/build.js +4 -4
- package/cli/commands/deploy.js +11 -6
- package/cli/commands/dev.js +14 -16
- package/cli/commands/env.js +4 -3
- package/cli/commands/plugins/kysely.js +2 -2
- package/cli/commands/remove.js +4 -5
- package/cli/commands/update.js +12 -6
- package/cli/local/router.d.ts +6 -6
- package/cli/local/router.js +3 -3
- package/cli/local/server.d.ts +1 -1
- package/cli/local/server.js +7 -12
- package/cli/program.d.ts +1 -1
- package/cli/program.js +1 -1
- package/cli/telemetry/environment.d.ts +1 -1
- package/cli/telemetry/environment.js +1 -1
- package/cli/ui/deploy.js +2 -2
- package/config.js +5 -5
- package/constructs/Api.d.ts +3 -3
- package/constructs/ApiGatewayV1Api.d.ts +2 -2
- package/constructs/App.d.ts +2 -2
- package/constructs/App.js +1 -1
- package/constructs/AppSyncApi.d.ts +1 -1
- package/constructs/AppSyncApi.js +1 -1
- package/constructs/Function.d.ts +4 -5
- package/constructs/Function.js +6 -14
- package/constructs/FunctionalStack.d.ts +2 -2
- package/constructs/Job.d.ts +1 -1
- package/constructs/Job.js +2 -2
- package/constructs/Metadata.d.ts +19 -19
- package/constructs/NextjsSite.d.ts +1 -1
- package/constructs/NextjsSite.js +21 -4
- package/constructs/RDS.d.ts +1 -1
- package/constructs/RDS.js +1 -1
- package/constructs/ReactStaticSite.d.ts +2 -2
- package/constructs/ReactStaticSite.js +2 -1
- package/constructs/Script.js +1 -1
- package/constructs/SsrSite.d.ts +11 -6
- package/constructs/SsrSite.js +56 -43
- package/constructs/Stack.d.ts +1 -1
- package/constructs/Stack.js +1 -1
- package/constructs/StaticSite.d.ts +3 -3
- package/constructs/StaticSite.js +9 -9
- package/constructs/Table.d.ts +1 -1
- package/constructs/ViteStaticSite.d.ts +1 -1
- package/constructs/ViteStaticSite.js +2 -1
- package/constructs/deferred_task.d.ts +1 -1
- package/constructs/deprecated/NextjsSite.js +1 -1
- package/constructs/util/apiGatewayV1AccessLog.d.ts +1 -1
- package/constructs/util/duration.d.ts +1 -1
- package/constructs/util/permission.d.ts +3 -3
- package/constructs/util/size.d.ts +1 -1
- package/context/handler.d.ts +1 -1
- package/credentials.d.ts +1 -1
- package/credentials.js +8 -6
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/iot.js +2 -2
- package/logger.js +1 -1
- package/node/api/index.d.ts +2 -0
- package/node/api/index.js +8 -0
- package/node/auth/adapter/adapter.d.ts +1 -1
- package/node/auth/adapter/github.js +4 -4
- package/node/auth/adapter/google.d.ts +1 -1
- package/node/auth/session.d.ts +1 -1
- package/node/config/index.d.ts +2 -2
- package/node/job/index.d.ts +2 -2
- package/package.json +8 -13
- package/project.d.ts +44 -0
- package/{app.js → project.js} +56 -51
- package/runtime/handlers/dotnet.js +1 -1
- package/runtime/handlers/java.js +1 -1
- package/runtime/handlers/node.js +6 -5
- package/runtime/handlers.js +14 -11
- package/runtime/runtime.d.ts +4 -0
- package/runtime/workers.js +4 -0
- package/site-env.js +1 -1
- package/sst.mjs +807 -16608
- package/stacks/build.d.ts +1 -1
- package/stacks/build.js +13 -21
- package/stacks/metadata.js +5 -5
- package/stacks/monitor.d.ts +1 -1
- package/stacks/synth.js +4 -4
- package/support/base-site-archiver.mjs +79 -0
- package/support/bridge/bridge.mjs +83 -22
- package/support/custom-resources/index.mjs +22 -1
- package/support/edge-function/edge-lambda.mjs +2 -2
- package/support/nodejs-runtime/index.mjs +79 -72
- package/support/rds-migrator/index.mjs +27 -23
- package/support/script-function/index.mjs +30485 -0
- package/support/ssr-site-function-archiver.mjs +96 -0
- package/watcher.js +1 -1
- package/app.d.ts +0 -36
- package/constructs/Script/cfn-response.d.ts +0 -19
- package/constructs/Script/cfn-response.js +0 -77
- package/constructs/Script/index.d.ts +0 -1
- package/constructs/Script/index.js +0 -78
- package/constructs/Script/outbound.d.ts +0 -10
- package/constructs/Script/outbound.js +0 -42
- package/constructs/Script/util.d.ts +0 -2
- package/constructs/Script/util.js +0 -11
- package/support/base-site-archiver.cjs +0 -116
package/project.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Metafile } from "esbuild";
|
|
2
|
+
import { App } from "./constructs/App.js";
|
|
3
|
+
export interface SSTConfig {
|
|
4
|
+
config: (globals: GlobalOptions) => Promise<ConfigOptions> | ConfigOptions;
|
|
5
|
+
stacks: (app: App) => Promise<void> | void;
|
|
6
|
+
}
|
|
7
|
+
export interface ConfigOptions {
|
|
8
|
+
name: string;
|
|
9
|
+
region?: string;
|
|
10
|
+
stage?: string;
|
|
11
|
+
profile?: string;
|
|
12
|
+
ssmPrefix?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const DEFAULTS: {
|
|
15
|
+
readonly stage: undefined;
|
|
16
|
+
readonly ssmPrefix: undefined;
|
|
17
|
+
};
|
|
18
|
+
interface Project {
|
|
19
|
+
config: ConfigOptions & Required<{
|
|
20
|
+
[key in keyof typeof DEFAULTS]: Exclude<ConfigOptions[key], undefined>;
|
|
21
|
+
}>;
|
|
22
|
+
version: string;
|
|
23
|
+
paths: {
|
|
24
|
+
root: string;
|
|
25
|
+
config: string;
|
|
26
|
+
out: string;
|
|
27
|
+
artifacts: string;
|
|
28
|
+
};
|
|
29
|
+
metafile: Metafile;
|
|
30
|
+
stacks: SSTConfig["stacks"];
|
|
31
|
+
}
|
|
32
|
+
export declare const ProjectContext: {
|
|
33
|
+
use(): Project;
|
|
34
|
+
provide(value: Project): void;
|
|
35
|
+
};
|
|
36
|
+
export declare function useProject(): Project;
|
|
37
|
+
interface GlobalOptions {
|
|
38
|
+
profile?: string;
|
|
39
|
+
stage?: string;
|
|
40
|
+
root?: string;
|
|
41
|
+
region?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function initProject(globals: GlobalOptions): Promise<void>;
|
|
44
|
+
export {};
|
package/{app.js → project.js}
RENAMED
|
@@ -7,10 +7,9 @@ import { Logger } from "./logger.js";
|
|
|
7
7
|
import { Context } from "./context/context.js";
|
|
8
8
|
import { VisibleError } from "./error.js";
|
|
9
9
|
import { blue } from "colorette";
|
|
10
|
-
import { dynamicImport } from "./util/module.js";
|
|
11
10
|
import dotenv from "dotenv";
|
|
11
|
+
import { Stacks } from "./stacks/index.js";
|
|
12
12
|
const DEFAULTS = {
|
|
13
|
-
main: "stacks/index.ts",
|
|
14
13
|
stage: undefined,
|
|
15
14
|
ssmPrefix: undefined,
|
|
16
15
|
};
|
|
@@ -18,65 +17,71 @@ export const ProjectContext = Context.create();
|
|
|
18
17
|
export function useProject() {
|
|
19
18
|
return ProjectContext.use();
|
|
20
19
|
}
|
|
21
|
-
const CONFIG_EXTENSIONS = [
|
|
20
|
+
const CONFIG_EXTENSIONS = [
|
|
21
|
+
".config.ts",
|
|
22
|
+
".config.mts",
|
|
23
|
+
".config.cts",
|
|
24
|
+
".config.cjs",
|
|
25
|
+
".config.mjs",
|
|
26
|
+
".config.js",
|
|
27
|
+
];
|
|
22
28
|
export async function initProject(globals) {
|
|
23
29
|
const root = globals.root || (await findRoot());
|
|
24
30
|
const out = path.join(root, ".sst");
|
|
25
31
|
await fs.mkdir(out, {
|
|
26
32
|
recursive: true,
|
|
27
33
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (file.endsWith("js")) {
|
|
39
|
-
const fn = await dynamicImport(file);
|
|
40
|
-
return await fn.default(globals);
|
|
41
|
-
}
|
|
42
|
-
if (file.endsWith(".json")) {
|
|
43
|
-
const data = await fs.readFile(file);
|
|
44
|
-
return Object.assign(DEFAULTS, JSON.parse(data.toString("utf8")));
|
|
45
|
-
}
|
|
34
|
+
let file;
|
|
35
|
+
const [metafile, sstConfig] = await (async function () {
|
|
36
|
+
for (const ext of CONFIG_EXTENSIONS) {
|
|
37
|
+
file = path.join(root, "sst" + ext);
|
|
38
|
+
try {
|
|
39
|
+
await fs.access(file);
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const project =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
catch {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const [metafile, config] = await Stacks.load(file);
|
|
45
|
+
return [metafile, config];
|
|
46
|
+
}
|
|
47
|
+
throw new VisibleError("Could not found a configuration file", "Make sure one of the following exists", ...CONFIG_EXTENSIONS.map((x) => ` - sst${x}`));
|
|
48
|
+
})();
|
|
49
|
+
const config = await Promise.resolve(sstConfig.config(globals));
|
|
50
|
+
const stage = config.stage ||
|
|
51
|
+
globals.stage ||
|
|
52
|
+
(await usePersonalStage(out)) ||
|
|
53
|
+
(await promptPersonalStage(out));
|
|
54
|
+
const project = {
|
|
55
|
+
version: await (async () => {
|
|
56
|
+
try {
|
|
57
|
+
const packageJson = JSON.parse(await fs
|
|
58
|
+
.readFile(url.fileURLToPath(new URL("./package.json", import.meta.url)))
|
|
59
|
+
.then((x) => x.toString()));
|
|
60
|
+
return packageJson.version;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return "unknown";
|
|
64
|
+
}
|
|
65
|
+
})(),
|
|
66
|
+
config: {
|
|
67
|
+
...config,
|
|
68
|
+
stage,
|
|
69
|
+
profile: config.profile || globals.profile,
|
|
70
|
+
region: config.region || globals.region,
|
|
71
|
+
ssmPrefix: config.ssmPrefix || `/sst/${config.name}/${stage}/`,
|
|
72
|
+
},
|
|
73
|
+
stacks: sstConfig.stacks,
|
|
74
|
+
metafile,
|
|
75
|
+
paths: {
|
|
76
|
+
config: file,
|
|
77
|
+
root,
|
|
78
|
+
out,
|
|
79
|
+
artifacts: path.join(out, "artifacts"),
|
|
80
|
+
},
|
|
67
81
|
};
|
|
68
|
-
try {
|
|
69
|
-
const packageJson = JSON.parse(await fs
|
|
70
|
-
.readFile(url.fileURLToPath(new URL("./package.json", import.meta.url)))
|
|
71
|
-
.then((x) => x.toString()));
|
|
72
|
-
project.version = packageJson.version;
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
project.version = "unknown";
|
|
76
|
-
}
|
|
77
82
|
ProjectContext.provide(project);
|
|
78
83
|
dotenv.config({
|
|
79
|
-
path: path.join(project.paths.root, `.env.${project.stage}`),
|
|
84
|
+
path: path.join(project.paths.root, `.env.${project.config.stage}`),
|
|
80
85
|
});
|
|
81
86
|
Logger.debug("Config loaded", project);
|
|
82
87
|
}
|
|
@@ -4,7 +4,7 @@ import { Context } from "../../context/context.js";
|
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
5
|
import { useRuntimeServerConfig } from "../server.js";
|
|
6
6
|
import { findBelow, isChild } from "../../util/fs.js";
|
|
7
|
-
import { useProject } from "../../
|
|
7
|
+
import { useProject } from "../../project.js";
|
|
8
8
|
import { execAsync } from "../../util/process.js";
|
|
9
9
|
import url from "url";
|
|
10
10
|
const FRAMEWORK_MAP = {
|
package/runtime/handlers/java.js
CHANGED
|
@@ -8,7 +8,7 @@ import zipLocal from "zip-local";
|
|
|
8
8
|
import { spawn } from "child_process";
|
|
9
9
|
import { useRuntimeServerConfig } from "../server.js";
|
|
10
10
|
import { existsAsync, findBelow, isChild } from "../../util/fs.js";
|
|
11
|
-
import { useProject } from "../../
|
|
11
|
+
import { useProject } from "../../project.js";
|
|
12
12
|
import { execAsync } from "../../util/process.js";
|
|
13
13
|
import url from "url";
|
|
14
14
|
export const useJavaHandler = Context.memo(() => {
|
package/runtime/handlers/node.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from "path";
|
|
|
2
2
|
import fs from "fs/promises";
|
|
3
3
|
import { exec } from "child_process";
|
|
4
4
|
import fsSync from "fs";
|
|
5
|
-
import { useProject } from "../../
|
|
5
|
+
import { useProject } from "../../project.js";
|
|
6
6
|
import esbuild from "esbuild";
|
|
7
7
|
import url from "url";
|
|
8
8
|
import { Worker } from "worker_threads";
|
|
@@ -93,9 +93,7 @@ export const useNodeHandler = Context.memo(() => {
|
|
|
93
93
|
entryPoints: [file],
|
|
94
94
|
platform: "node",
|
|
95
95
|
external: [
|
|
96
|
-
...(
|
|
97
|
-
? []
|
|
98
|
-
: ["aws-sdk"]),
|
|
96
|
+
...(isESM || input.props.runtime === "nodejs18.x" ? [] : ["aws-sdk"]),
|
|
99
97
|
...(nodejs.install || []),
|
|
100
98
|
...(external || []),
|
|
101
99
|
],
|
|
@@ -159,7 +157,10 @@ export const useNodeHandler = Context.memo(() => {
|
|
|
159
157
|
}
|
|
160
158
|
if (input.mode === "start") {
|
|
161
159
|
const dir = path.join(await find(parsed.dir, "package.json"), "node_modules");
|
|
162
|
-
|
|
160
|
+
try {
|
|
161
|
+
await fs.symlink(path.resolve(dir), path.resolve(path.join(input.out, "node_modules")), "dir");
|
|
162
|
+
}
|
|
163
|
+
catch { }
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
cache[input.functionID] = result;
|
package/runtime/handlers.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import fs from "fs/promises";
|
|
5
5
|
import { useWatcher } from "../watcher.js";
|
|
6
6
|
import { useBus } from "../bus.js";
|
|
7
|
-
import { useProject } from "../
|
|
7
|
+
import { useProject } from "../project.js";
|
|
8
8
|
import { useFunctions } from "../constructs/Function.js";
|
|
9
9
|
export const useRuntimeHandlers = Context.memo(() => {
|
|
10
10
|
const handlers = [];
|
|
@@ -101,17 +101,20 @@ export const useFunctionBuilder = Context.memo(() => {
|
|
|
101
101
|
};
|
|
102
102
|
const watcher = useWatcher();
|
|
103
103
|
watcher.subscribe("file.changed", async (evt) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
try {
|
|
105
|
+
const functions = useFunctions();
|
|
106
|
+
for (const [functionID, props] of Object.entries(functions.all)) {
|
|
107
|
+
const handler = handlers.for(props.runtime);
|
|
108
|
+
if (!handler?.shouldBuild({
|
|
109
|
+
functionID,
|
|
110
|
+
file: evt.properties.file,
|
|
111
|
+
}))
|
|
112
|
+
continue;
|
|
113
|
+
await result.build(functionID);
|
|
114
|
+
Logger.debug("Rebuilt function", functionID);
|
|
115
|
+
}
|
|
114
116
|
}
|
|
117
|
+
catch { }
|
|
115
118
|
});
|
|
116
119
|
return result;
|
|
117
120
|
});
|
package/runtime/runtime.d.ts
CHANGED
package/runtime/workers.js
CHANGED
|
@@ -21,6 +21,10 @@ export const useRuntimeWorkers = Context.memo(() => {
|
|
|
21
21
|
});
|
|
22
22
|
const lastRequestId = new Map();
|
|
23
23
|
bus.subscribe("function.invoked", async (evt) => {
|
|
24
|
+
bus.publish("function.ack", {
|
|
25
|
+
functionID: evt.properties.functionID,
|
|
26
|
+
workerID: evt.properties.workerID,
|
|
27
|
+
});
|
|
24
28
|
let worker = workers.get(evt.properties.workerID);
|
|
25
29
|
lastRequestId.set(evt.properties.workerID, evt.properties.context.awsRequestId);
|
|
26
30
|
if (worker)
|
package/site-env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * as SiteEnv from "./site-env.js";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { useProject } from "./
|
|
4
|
+
import { useProject } from "./project.js";
|
|
5
5
|
function keysFile() {
|
|
6
6
|
return path.join(useProject().paths.out, "site-environment-keys.jsonl");
|
|
7
7
|
}
|