sst 2.5.2 → 2.5.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/bootstrap.js +1 -1
- package/cli/commands/dev.js +1 -1
- package/cli/telemetry/post-payload.js +2 -2
- package/cli/telemetry/telemetry.js +14 -11
- package/constructs/ApiGatewayV1Api.js +3 -1
- package/constructs/App.d.ts +1 -1
- package/constructs/App.js +1 -1
- package/constructs/Function.js +16 -7
- package/constructs/StaticSite.d.ts +1 -1
- package/iot.js +1 -1
- package/node/future/auth/adapter/github.d.ts +8 -1
- package/node/future/auth/adapter/github.js +2 -1
- package/node/graphql/index.d.ts +4 -0
- package/node/graphql/index.js +5 -0
- package/package.json +1 -1
- package/project.js +10 -0
- package/runtime/handlers/go.js +8 -2
- package/runtime/handlers/node.js +2 -2
- package/runtime/handlers.js +8 -3
- package/sst.mjs +45 -23
- package/support/bootstrap-metadata-function/index.mjs +238 -238
- package/support/custom-resources/index.mjs +238 -238
package/bootstrap.js
CHANGED
|
@@ -146,7 +146,7 @@ export async function bootstrapSST() {
|
|
|
146
146
|
const fn = new Function(stack, "MetadataHandler", {
|
|
147
147
|
code: Code.fromAsset(path.resolve(__dirname, "support/bootstrap-metadata-function")),
|
|
148
148
|
handler: "index.handler",
|
|
149
|
-
runtime: region?.startsWith("us-gov-")
|
|
149
|
+
runtime: region?.startsWith("us-gov-")
|
|
150
150
|
? Runtime.NODEJS_16_X
|
|
151
151
|
: Runtime.NODEJS_18_X,
|
|
152
152
|
environment: {
|
package/cli/commands/dev.js
CHANGED
|
@@ -69,7 +69,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
69
69
|
});
|
|
70
70
|
bus.subscribe("function.build.success", async (evt) => {
|
|
71
71
|
const info = useFunctions().fromID(evt.properties.functionID);
|
|
72
|
-
if (
|
|
72
|
+
if (info.enableLiveDev === false)
|
|
73
73
|
return;
|
|
74
74
|
Colors.line(Colors.dim(Colors.prefix, "Built", info.handler));
|
|
75
75
|
});
|
|
@@ -56,7 +56,7 @@ function notify() {
|
|
|
56
56
|
function willNotRecord() {
|
|
57
57
|
return !isEnabled() || !!process.env.SST_TELEMETRY_DISABLED;
|
|
58
58
|
}
|
|
59
|
-
function record(name, properties) {
|
|
59
|
+
async function record(name, properties) {
|
|
60
60
|
if (willNotRecord()) {
|
|
61
61
|
return Promise.resolve();
|
|
62
62
|
}
|
|
@@ -65,16 +65,19 @@ function record(name, properties) {
|
|
|
65
65
|
projectId,
|
|
66
66
|
sessionId,
|
|
67
67
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
try {
|
|
69
|
+
await postPayload(TELEMETRY_API, {
|
|
70
|
+
context,
|
|
71
|
+
environment: getEnvironmentData(),
|
|
72
|
+
events: [
|
|
73
|
+
{
|
|
74
|
+
name,
|
|
75
|
+
properties,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch { }
|
|
78
81
|
}
|
|
79
82
|
function getAnonymousId() {
|
|
80
83
|
const val = conf && conf.get(TELEMETRY_KEY_ID);
|
|
@@ -68,7 +68,9 @@ export class ApiGatewayV1Api extends Construct {
|
|
|
68
68
|
* The AWS generated URL of the Api.
|
|
69
69
|
*/
|
|
70
70
|
get url() {
|
|
71
|
-
|
|
71
|
+
const app = this.node.root;
|
|
72
|
+
return (this.cdk.restApi.url ??
|
|
73
|
+
`https://${this.cdk.restApi.restApiId}.execute-api.${app.region}.amazonaws.com/${app.stage}/`);
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
76
|
* If custom domain is enabled, this is the custom domain URL of the Api.
|
package/constructs/App.d.ts
CHANGED
package/constructs/App.js
CHANGED
package/constructs/Function.js
CHANGED
|
@@ -20,6 +20,7 @@ import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
|
20
20
|
import { Token, Size as CDKSize, Duration as CDKDuration } from "aws-cdk-lib";
|
|
21
21
|
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
22
22
|
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
23
|
+
import { useBootstrap } from "../bootstrap.js";
|
|
23
24
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
24
25
|
const supportedRuntimes = {
|
|
25
26
|
rust: CDKRuntime.PROVIDED_AL2,
|
|
@@ -159,13 +160,21 @@ export class Function extends CDKFunction {
|
|
|
159
160
|
...(debugOverrideProps || {}),
|
|
160
161
|
});
|
|
161
162
|
this.addEnvironment("SST_FUNCTION_ID", this.node.addr);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
useDeferredTasks().add(async () => {
|
|
164
|
+
const bootstrap = await useBootstrap();
|
|
165
|
+
this.attachPermissions([
|
|
166
|
+
new PolicyStatement({
|
|
167
|
+
actions: ["iot:*"],
|
|
168
|
+
effect: Effect.ALLOW,
|
|
169
|
+
resources: ["*"],
|
|
170
|
+
}),
|
|
171
|
+
new PolicyStatement({
|
|
172
|
+
actions: ["s3:*"],
|
|
173
|
+
effect: Effect.ALLOW,
|
|
174
|
+
resources: [`arn:aws:s3:::${bootstrap.bucket}`],
|
|
175
|
+
}),
|
|
176
|
+
]);
|
|
177
|
+
});
|
|
169
178
|
}
|
|
170
179
|
// Handle build
|
|
171
180
|
else {
|
|
@@ -226,7 +226,7 @@ export interface StaticSiteProps {
|
|
|
226
226
|
*/
|
|
227
227
|
id?: string;
|
|
228
228
|
/**
|
|
229
|
-
* Allows you to override default settings this construct uses internally to
|
|
229
|
+
* Allows you to override default settings this construct uses internally to create the bucket
|
|
230
230
|
*
|
|
231
231
|
* @example
|
|
232
232
|
* ```js
|
package/iot.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { OauthBasicConfig } from "./oauth.js";
|
|
2
|
-
|
|
2
|
+
import { OidcBasicConfig } from "./oidc.js";
|
|
3
|
+
type Config = ({
|
|
4
|
+
mode: "oauth";
|
|
5
|
+
} & OauthBasicConfig) | ({
|
|
6
|
+
mode: "oidc";
|
|
7
|
+
} & OidcBasicConfig);
|
|
8
|
+
export declare const GithubAdapter: (config: Config) => () => Promise<{
|
|
3
9
|
type: "success";
|
|
4
10
|
properties: {
|
|
5
11
|
tokenset: import("openid-client").TokenSet;
|
|
@@ -14,3 +20,4 @@ export declare const GithubAdapter: (config: OauthBasicConfig) => () => Promise<
|
|
|
14
20
|
};
|
|
15
21
|
};
|
|
16
22
|
}>;
|
|
23
|
+
export {};
|
|
@@ -9,7 +9,7 @@ const issuer = new Issuer({
|
|
|
9
9
|
export const GithubAdapter =
|
|
10
10
|
/* @__PURE__ */
|
|
11
11
|
(config) => {
|
|
12
|
-
if (config.
|
|
12
|
+
if (config.mode === "oauth") {
|
|
13
13
|
return OauthAdapter({
|
|
14
14
|
issuer,
|
|
15
15
|
...config,
|
|
@@ -17,6 +17,7 @@ export const GithubAdapter =
|
|
|
17
17
|
}
|
|
18
18
|
return OidcAdapter({
|
|
19
19
|
issuer,
|
|
20
|
+
scope: "openid email profile",
|
|
20
21
|
...config,
|
|
21
22
|
});
|
|
22
23
|
};
|
package/node/graphql/index.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ interface GraphQLHandlerConfig<C> {
|
|
|
23
23
|
* Override the GraphQL execute function, sometimes used by plugins
|
|
24
24
|
*/
|
|
25
25
|
execute?: ProcessRequestOptions<any, any>["execute"];
|
|
26
|
+
/**
|
|
27
|
+
* Disable introspection for production
|
|
28
|
+
*/
|
|
29
|
+
disableIntrospection?: boolean;
|
|
26
30
|
}
|
|
27
31
|
export declare function GraphQLHandler<C>(config: GraphQLHandlerConfig<C>): (event: APIGatewayProxyEventV2, context: Context) => Promise<{
|
|
28
32
|
statusCode: any;
|
package/node/graphql/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { specifiedRules, NoSchemaIntrospectionCustomRule, } from "graphql";
|
|
1
2
|
import { getGraphQLParameters, processRequest,
|
|
2
3
|
// @ts-expect-error
|
|
3
4
|
} from "graphql-helix";
|
|
@@ -12,11 +13,15 @@ export function GraphQLHandler(config) {
|
|
|
12
13
|
headers: useHeaders(),
|
|
13
14
|
};
|
|
14
15
|
const { operationName, query, variables } = getGraphQLParameters(request);
|
|
16
|
+
const validationRules = config.disableIntrospection
|
|
17
|
+
? [...specifiedRules, NoSchemaIntrospectionCustomRule]
|
|
18
|
+
: [...specifiedRules];
|
|
15
19
|
const result = await processRequest({
|
|
16
20
|
operationName,
|
|
17
21
|
query,
|
|
18
22
|
variables,
|
|
19
23
|
request,
|
|
24
|
+
validationRules,
|
|
20
25
|
execute: config.execute,
|
|
21
26
|
schema: config.schema,
|
|
22
27
|
formatPayload: config.formatPayload,
|
package/package.json
CHANGED
package/project.js
CHANGED
|
@@ -82,6 +82,16 @@ export async function initProject(globals) {
|
|
|
82
82
|
artifacts: path.join(out, "artifacts"),
|
|
83
83
|
},
|
|
84
84
|
};
|
|
85
|
+
// Cleanup old config files
|
|
86
|
+
(async function () {
|
|
87
|
+
const files = await fs.readdir(project.paths.root);
|
|
88
|
+
for (const file of files) {
|
|
89
|
+
if (file.startsWith(".sst.config")) {
|
|
90
|
+
await fs.unlink(path.join(project.paths.root, file));
|
|
91
|
+
Logger.debug(`Removed old config file ${file}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
85
95
|
ProjectContext.provide(project);
|
|
86
96
|
dotenv.config({
|
|
87
97
|
path: path.join(project.paths.root, `.env.${project.config.stage}`),
|
package/runtime/handlers/go.js
CHANGED
|
@@ -67,7 +67,10 @@ export const useGoHandler = Context.memo(async () => {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
catch (ex) {
|
|
70
|
-
|
|
70
|
+
return {
|
|
71
|
+
type: "error",
|
|
72
|
+
errors: [String(ex)],
|
|
73
|
+
};
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
if (input.mode === "deploy") {
|
|
@@ -85,7 +88,10 @@ export const useGoHandler = Context.memo(async () => {
|
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
90
|
catch (ex) {
|
|
88
|
-
|
|
91
|
+
return {
|
|
92
|
+
type: "error",
|
|
93
|
+
errors: [String(ex)],
|
|
94
|
+
};
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
return {
|
package/runtime/handlers/node.js
CHANGED
|
@@ -125,8 +125,8 @@ export const useNodeHandler = Context.memo(async () => {
|
|
|
125
125
|
js: [
|
|
126
126
|
`import { createRequire as topLevelCreateRequire } from 'module';`,
|
|
127
127
|
`const require = topLevelCreateRequire(import.meta.url);`,
|
|
128
|
-
`import { fileURLToPath as topLevelFileUrlToPath } from "url"`,
|
|
129
|
-
`const __dirname = topLevelFileUrlToPath(new
|
|
128
|
+
`import { fileURLToPath as topLevelFileUrlToPath, URL as topLevelURL } from "url"`,
|
|
129
|
+
`const __dirname = topLevelFileUrlToPath(new topLevelURL(".", import.meta.url))`,
|
|
130
130
|
nodejs.banner || "",
|
|
131
131
|
].join("\n"),
|
|
132
132
|
},
|
package/runtime/handlers.js
CHANGED
|
@@ -56,9 +56,14 @@ export const useRuntimeHandlers = Context.memo(() => {
|
|
|
56
56
|
recursive: true,
|
|
57
57
|
});
|
|
58
58
|
if (mode === "start") {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
try {
|
|
60
|
+
const dir = path.dirname(toPath);
|
|
61
|
+
await fs.mkdir(dir, { recursive: true });
|
|
62
|
+
await fs.symlink(fromPath, toPath);
|
|
63
|
+
}
|
|
64
|
+
catch (ex) {
|
|
65
|
+
Logger.debug("Failed to symlink", fromPath, toPath, ex);
|
|
66
|
+
}
|
|
62
67
|
}
|
|
63
68
|
}));
|
|
64
69
|
}
|
package/sst.mjs
CHANGED
|
@@ -387,6 +387,15 @@ async function initProject(globals) {
|
|
|
387
387
|
artifacts: path4.join(out, "artifacts")
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
|
+
(async function() {
|
|
391
|
+
const files = await fs4.readdir(project.paths.root);
|
|
392
|
+
for (const file2 of files) {
|
|
393
|
+
if (file2.startsWith(".sst.config")) {
|
|
394
|
+
await fs4.unlink(path4.join(project.paths.root, file2));
|
|
395
|
+
Logger.debug(`Removed old config file ${file2}`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
})();
|
|
390
399
|
ProjectContext.provide(project);
|
|
391
400
|
dotenv.config({
|
|
392
401
|
path: path4.join(project.paths.root, `.env.${project.config.stage}`),
|
|
@@ -488,8 +497,8 @@ function postPayload(endpoint, body) {
|
|
|
488
497
|
);
|
|
489
498
|
req.write(JSON.stringify(body));
|
|
490
499
|
req.end();
|
|
491
|
-
} catch {
|
|
492
|
-
|
|
500
|
+
} catch (ex) {
|
|
501
|
+
reject(ex);
|
|
493
502
|
}
|
|
494
503
|
});
|
|
495
504
|
}
|
|
@@ -636,7 +645,7 @@ function notify() {
|
|
|
636
645
|
function willNotRecord() {
|
|
637
646
|
return !isEnabled() || !!process.env.SST_TELEMETRY_DISABLED;
|
|
638
647
|
}
|
|
639
|
-
function record(name, properties) {
|
|
648
|
+
async function record(name, properties) {
|
|
640
649
|
if (willNotRecord()) {
|
|
641
650
|
return Promise.resolve();
|
|
642
651
|
}
|
|
@@ -645,16 +654,19 @@ function record(name, properties) {
|
|
|
645
654
|
projectId,
|
|
646
655
|
sessionId
|
|
647
656
|
};
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
657
|
+
try {
|
|
658
|
+
await postPayload(TELEMETRY_API, {
|
|
659
|
+
context,
|
|
660
|
+
environment: getEnvironmentData(),
|
|
661
|
+
events: [
|
|
662
|
+
{
|
|
663
|
+
name,
|
|
664
|
+
properties
|
|
665
|
+
}
|
|
666
|
+
]
|
|
667
|
+
});
|
|
668
|
+
} catch {
|
|
669
|
+
}
|
|
658
670
|
}
|
|
659
671
|
function getAnonymousId() {
|
|
660
672
|
const val = conf && conf.get(TELEMETRY_KEY_ID);
|
|
@@ -3571,9 +3583,13 @@ var init_handlers = __esm({
|
|
|
3571
3583
|
recursive: true
|
|
3572
3584
|
});
|
|
3573
3585
|
if (mode === "start") {
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3586
|
+
try {
|
|
3587
|
+
const dir = path7.dirname(toPath);
|
|
3588
|
+
await fs7.mkdir(dir, { recursive: true });
|
|
3589
|
+
await fs7.symlink(fromPath, toPath);
|
|
3590
|
+
} catch (ex) {
|
|
3591
|
+
Logger.debug("Failed to symlink", fromPath, toPath, ex);
|
|
3592
|
+
}
|
|
3577
3593
|
}
|
|
3578
3594
|
})
|
|
3579
3595
|
);
|
|
@@ -4209,8 +4225,8 @@ var init_node = __esm({
|
|
|
4209
4225
|
js: [
|
|
4210
4226
|
`import { createRequire as topLevelCreateRequire } from 'module';`,
|
|
4211
4227
|
`const require = topLevelCreateRequire(import.meta.url);`,
|
|
4212
|
-
`import { fileURLToPath as topLevelFileUrlToPath } from "url"`,
|
|
4213
|
-
`const __dirname = topLevelFileUrlToPath(new
|
|
4228
|
+
`import { fileURLToPath as topLevelFileUrlToPath, URL as topLevelURL } from "url"`,
|
|
4229
|
+
`const __dirname = topLevelFileUrlToPath(new topLevelURL(".", import.meta.url))`,
|
|
4214
4230
|
nodejs.banner || ""
|
|
4215
4231
|
].join("\n")
|
|
4216
4232
|
}
|
|
@@ -4407,7 +4423,10 @@ var init_go = __esm({
|
|
|
4407
4423
|
}
|
|
4408
4424
|
);
|
|
4409
4425
|
} catch (ex) {
|
|
4410
|
-
|
|
4426
|
+
return {
|
|
4427
|
+
type: "error",
|
|
4428
|
+
errors: [String(ex)]
|
|
4429
|
+
};
|
|
4411
4430
|
}
|
|
4412
4431
|
}
|
|
4413
4432
|
if (input.mode === "deploy") {
|
|
@@ -4427,7 +4446,10 @@ var init_go = __esm({
|
|
|
4427
4446
|
}
|
|
4428
4447
|
);
|
|
4429
4448
|
} catch (ex) {
|
|
4430
|
-
|
|
4449
|
+
return {
|
|
4450
|
+
type: "error",
|
|
4451
|
+
errors: [String(ex)]
|
|
4452
|
+
};
|
|
4431
4453
|
}
|
|
4432
4454
|
}
|
|
4433
4455
|
return {
|
|
@@ -5211,7 +5233,7 @@ async function bootstrapSST() {
|
|
|
5211
5233
|
path15.resolve(__dirname2, "support/bootstrap-metadata-function")
|
|
5212
5234
|
),
|
|
5213
5235
|
handler: "index.handler",
|
|
5214
|
-
runtime: region?.startsWith("us-gov-")
|
|
5236
|
+
runtime: region?.startsWith("us-gov-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
|
|
5215
5237
|
environment: {
|
|
5216
5238
|
BUCKET_NAME: bucket.bucketName
|
|
5217
5239
|
},
|
|
@@ -5777,7 +5799,7 @@ var init_iot = __esm({
|
|
|
5777
5799
|
}
|
|
5778
5800
|
];
|
|
5779
5801
|
}
|
|
5780
|
-
const parts = json.match(/.{1,
|
|
5802
|
+
const parts = json.match(/.{1,50000}/g);
|
|
5781
5803
|
if (!parts)
|
|
5782
5804
|
return [];
|
|
5783
5805
|
Logger.debug("Encoded iot message into", parts?.length, "parts");
|
|
@@ -6851,7 +6873,7 @@ var dev = (program2) => program2.command(
|
|
|
6851
6873
|
});
|
|
6852
6874
|
bus.subscribe("function.build.success", async (evt) => {
|
|
6853
6875
|
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
6854
|
-
if (
|
|
6876
|
+
if (info.enableLiveDev === false)
|
|
6855
6877
|
return;
|
|
6856
6878
|
Colors2.line(Colors2.dim(Colors2.prefix, "Built", info.handler));
|
|
6857
6879
|
});
|