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.
Files changed (107) hide show
  1. package/bootstrap.js +3 -3
  2. package/bus.d.ts +3 -3
  3. package/cache.js +1 -1
  4. package/cdk/deploy-stack.d.ts +2 -2
  5. package/cdk/deploy-stack.js +24 -16
  6. package/cli/commands/bind.js +2 -2
  7. package/cli/commands/build.js +4 -4
  8. package/cli/commands/deploy.js +11 -6
  9. package/cli/commands/dev.js +14 -16
  10. package/cli/commands/env.js +4 -3
  11. package/cli/commands/plugins/kysely.js +2 -2
  12. package/cli/commands/remove.js +4 -5
  13. package/cli/commands/update.js +12 -6
  14. package/cli/local/router.d.ts +6 -6
  15. package/cli/local/router.js +3 -3
  16. package/cli/local/server.d.ts +1 -1
  17. package/cli/local/server.js +7 -12
  18. package/cli/program.d.ts +1 -1
  19. package/cli/program.js +1 -1
  20. package/cli/telemetry/environment.d.ts +1 -1
  21. package/cli/telemetry/environment.js +1 -1
  22. package/cli/ui/deploy.js +2 -2
  23. package/config.js +5 -5
  24. package/constructs/Api.d.ts +3 -3
  25. package/constructs/ApiGatewayV1Api.d.ts +2 -2
  26. package/constructs/App.d.ts +2 -2
  27. package/constructs/App.js +1 -1
  28. package/constructs/AppSyncApi.d.ts +1 -1
  29. package/constructs/AppSyncApi.js +1 -1
  30. package/constructs/Function.d.ts +4 -5
  31. package/constructs/Function.js +6 -14
  32. package/constructs/FunctionalStack.d.ts +2 -2
  33. package/constructs/Job.d.ts +1 -1
  34. package/constructs/Job.js +2 -2
  35. package/constructs/Metadata.d.ts +19 -19
  36. package/constructs/NextjsSite.d.ts +1 -1
  37. package/constructs/NextjsSite.js +21 -4
  38. package/constructs/RDS.d.ts +1 -1
  39. package/constructs/RDS.js +1 -1
  40. package/constructs/ReactStaticSite.d.ts +2 -2
  41. package/constructs/ReactStaticSite.js +2 -1
  42. package/constructs/Script.js +1 -1
  43. package/constructs/SsrSite.d.ts +11 -6
  44. package/constructs/SsrSite.js +56 -43
  45. package/constructs/Stack.d.ts +1 -1
  46. package/constructs/Stack.js +1 -1
  47. package/constructs/StaticSite.d.ts +3 -3
  48. package/constructs/StaticSite.js +9 -9
  49. package/constructs/Table.d.ts +1 -1
  50. package/constructs/ViteStaticSite.d.ts +1 -1
  51. package/constructs/ViteStaticSite.js +2 -1
  52. package/constructs/deferred_task.d.ts +1 -1
  53. package/constructs/deprecated/NextjsSite.js +1 -1
  54. package/constructs/util/apiGatewayV1AccessLog.d.ts +1 -1
  55. package/constructs/util/duration.d.ts +1 -1
  56. package/constructs/util/permission.d.ts +3 -3
  57. package/constructs/util/size.d.ts +1 -1
  58. package/context/handler.d.ts +1 -1
  59. package/credentials.d.ts +1 -1
  60. package/credentials.js +8 -6
  61. package/index.d.ts +1 -0
  62. package/index.js +1 -0
  63. package/iot.js +2 -2
  64. package/logger.js +1 -1
  65. package/node/api/index.d.ts +2 -0
  66. package/node/api/index.js +8 -0
  67. package/node/auth/adapter/adapter.d.ts +1 -1
  68. package/node/auth/adapter/github.js +4 -4
  69. package/node/auth/adapter/google.d.ts +1 -1
  70. package/node/auth/session.d.ts +1 -1
  71. package/node/config/index.d.ts +2 -2
  72. package/node/job/index.d.ts +2 -2
  73. package/package.json +8 -13
  74. package/project.d.ts +44 -0
  75. package/{app.js → project.js} +56 -51
  76. package/runtime/handlers/dotnet.js +1 -1
  77. package/runtime/handlers/java.js +1 -1
  78. package/runtime/handlers/node.js +6 -5
  79. package/runtime/handlers.js +14 -11
  80. package/runtime/runtime.d.ts +4 -0
  81. package/runtime/workers.js +4 -0
  82. package/site-env.js +1 -1
  83. package/sst.mjs +807 -16608
  84. package/stacks/build.d.ts +1 -1
  85. package/stacks/build.js +13 -21
  86. package/stacks/metadata.js +5 -5
  87. package/stacks/monitor.d.ts +1 -1
  88. package/stacks/synth.js +4 -4
  89. package/support/base-site-archiver.mjs +79 -0
  90. package/support/bridge/bridge.mjs +83 -22
  91. package/support/custom-resources/index.mjs +22 -1
  92. package/support/edge-function/edge-lambda.mjs +2 -2
  93. package/support/nodejs-runtime/index.mjs +79 -72
  94. package/support/rds-migrator/index.mjs +27 -23
  95. package/support/script-function/index.mjs +30485 -0
  96. package/support/ssr-site-function-archiver.mjs +96 -0
  97. package/watcher.js +1 -1
  98. package/app.d.ts +0 -36
  99. package/constructs/Script/cfn-response.d.ts +0 -19
  100. package/constructs/Script/cfn-response.js +0 -77
  101. package/constructs/Script/index.d.ts +0 -1
  102. package/constructs/Script/index.js +0 -78
  103. package/constructs/Script/outbound.d.ts +0 -10
  104. package/constructs/Script/outbound.js +0 -42
  105. package/constructs/Script/util.d.ts +0 -2
  106. package/constructs/Script/util.js +0 -11
  107. package/support/base-site-archiver.cjs +0 -116
@@ -25,7 +25,7 @@ import { getBuildCmdEnvironment, buildErrorResponsesForRedirectToIndex, } from "
25
25
  import { attachPermissionsToRole } from "./util/permission.js";
26
26
  import { ENVIRONMENT_PLACEHOLDER, getParameterPath, } from "./util/functionBinding.js";
27
27
  import { SiteEnv } from "../site-env.js";
28
- import { useProject } from "../app.js";
28
+ import { useProject } from "../project.js";
29
29
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
30
30
  /**
31
31
  * The `SsrSite` construct is a higher level CDK construct that makes it easy to create modern web apps with Server Side Rendering capabilities.
@@ -60,13 +60,13 @@ export class SsrSite extends Construct {
60
60
  serverLambdaForRegional;
61
61
  awsCliLayer;
62
62
  constructor(scope, id, props) {
63
- super(scope, props.cdk?.id || id);
64
- this.id = id;
63
+ super(scope, props?.cdk?.id || id);
65
64
  const app = scope.node.root;
65
+ this.id = id;
66
+ this.props = { path: ".", ...props };
66
67
  this.isPlaceholder =
67
- (app.local || app.skipBuild) && !props.disablePlaceholder;
68
+ (app.local || app.skipBuild) && !this.props.disablePlaceholder;
68
69
  this.sstBuildDir = useProject().paths.artifacts;
69
- this.props = props;
70
70
  this.cdk = {};
71
71
  this.awsCliLayer = new AwsCliLayer(this, "AwsCliLayer");
72
72
  this.validateSiteExists();
@@ -79,7 +79,7 @@ export class SsrSite extends Construct {
79
79
  // Create Bucket which will be utilised to contain the statics
80
80
  this.cdk.bucket = this.createS3Bucket();
81
81
  // Create Server functions
82
- if (props.edge) {
82
+ if (this.props.edge) {
83
83
  this.serverLambdaForEdge = this.createFunctionForEdge();
84
84
  this.createFunctionPermissionsForEdge();
85
85
  }
@@ -94,12 +94,15 @@ export class SsrSite extends Construct {
94
94
  this.cdk.certificate = this.createCertificate();
95
95
  // Create S3 Deployment
96
96
  const assets = this.isPlaceholder
97
- ? this.createStaticsS3AssetsWithStub()
98
- : this.createStaticsS3Assets();
99
- const s3deployCR = this.createS3Deployment(assets);
97
+ ? this.createS3AssetsForStub()
98
+ : this.createS3Assets();
99
+ const assetFileOptions = this.isPlaceholder
100
+ ? this.createS3AssetFileOptionsForStub()
101
+ : this.createS3AssetFileOptions();
102
+ const s3deployCR = this.createS3Deployment(assets, assetFileOptions);
100
103
  // Create CloudFront
101
104
  this.validateCloudFrontDistributionSettings();
102
- if (props.edge) {
105
+ if (this.props.edge) {
103
106
  this.cdk.distribution = this.isPlaceholder
104
107
  ? this.createCloudFrontDistributionForStub()
105
108
  : this.createCloudFrontDistributionForEdge();
@@ -272,17 +275,17 @@ export class SsrSite extends Construct {
272
275
  /////////////////////
273
276
  // Bundle S3 Assets
274
277
  /////////////////////
275
- createStaticsS3Assets() {
278
+ createS3Assets() {
276
279
  // Create temp folder, clean up if exists
277
280
  const zipOutDir = path.resolve(path.join(this.sstBuildDir, `Site-${this.node.id}-${this.node.addr}`));
278
281
  fs.rmSync(zipOutDir, { recursive: true, force: true });
279
282
  // Create zip files
280
283
  const app = this.node.root;
281
- const script = path.resolve(__dirname, "../support/base-site-archiver.cjs");
284
+ const script = path.resolve(__dirname, "../support/base-site-archiver.mjs");
282
285
  const fileSizeLimit = app.isRunningSSTTest()
283
- ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
284
- // @ts-ignore: "sstTestFileSizeLimitOverride" not exposed in props
285
- this.props.sstTestFileSizeLimitOverride || 200
286
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
287
+ // @ts-ignore: "sstTestFileSizeLimitOverride" not exposed in props
288
+ ? this.props.sstTestFileSizeLimitOverride || 200
286
289
  : 200;
287
290
  const result = spawn.sync("node", [
288
291
  script,
@@ -308,13 +311,49 @@ export class SsrSite extends Construct {
308
311
  }
309
312
  return assets;
310
313
  }
311
- createStaticsS3AssetsWithStub() {
314
+ createS3AssetFileOptions() {
315
+ // Build file options
316
+ const fileOptions = [];
317
+ const clientPath = path.join(this.props.path, this.buildConfig.clientBuildOutputDir);
318
+ for (const item of fs.readdirSync(clientPath)) {
319
+ // Versioned files will be cached for 1 year (immutable) both at
320
+ // CDN and browser level.
321
+ if (item === this.buildConfig.clientBuildVersionedSubDir) {
322
+ fileOptions.push({
323
+ exclude: "*",
324
+ include: `${this.buildConfig.clientBuildVersionedSubDir}/*`,
325
+ cacheControl: "public,max-age=31536000,immutable",
326
+ });
327
+ }
328
+ // Un-versioned files will be cached for 1 year at the CDN level.
329
+ // But not at the browser level. CDN cache will be invalidated on deploy.
330
+ else {
331
+ const itemPath = path.join(clientPath, item);
332
+ fileOptions.push({
333
+ exclude: "*",
334
+ include: fs.statSync(itemPath).isDirectory()
335
+ ? `${item}/*`
336
+ : `${item}`,
337
+ cacheControl: "public,max-age=0,s-maxage=31536000,must-revalidate",
338
+ });
339
+ }
340
+ }
341
+ return fileOptions;
342
+ }
343
+ createS3AssetsForStub() {
312
344
  return [
313
345
  new s3Assets.Asset(this, "Asset", {
314
346
  path: this.buildConfig.siteStub,
315
347
  }),
316
348
  ];
317
349
  }
350
+ createS3AssetFileOptionsForStub() {
351
+ return [{
352
+ exclude: "*",
353
+ include: "*",
354
+ cacheControl: "public,max-age=0,s-maxage=31536000,must-revalidate",
355
+ }];
356
+ }
318
357
  createS3Bucket() {
319
358
  const { cdk } = this.props;
320
359
  // cdk.bucket is an imported construct
@@ -332,7 +371,7 @@ export class SsrSite extends Construct {
332
371
  });
333
372
  }
334
373
  }
335
- createS3Deployment(assets) {
374
+ createS3Deployment(assets, fileOptions) {
336
375
  // Create a Lambda function that will be doing the uploading
337
376
  const uploader = new lambda.Function(this, "S3Uploader", {
338
377
  code: lambda.Code.fromAsset(path.join(__dirname, "../support/base-site-custom-resource")),
@@ -358,32 +397,6 @@ export class SsrSite extends Construct {
358
397
  });
359
398
  this.cdk.bucket.grantReadWrite(handler);
360
399
  uploader.grantInvoke(handler);
361
- // Build file options
362
- const fileOptions = [];
363
- const clientPath = path.join(this.props.path, this.buildConfig.clientBuildOutputDir);
364
- for (const item of fs.readdirSync(clientPath)) {
365
- // Versioned files will be cached for 1 year (immutable) both at
366
- // CDN and browser level.
367
- if (item === this.buildConfig.clientBuildVersionedSubDir) {
368
- fileOptions.push({
369
- exclude: "*",
370
- include: `${this.buildConfig.clientBuildVersionedSubDir}/*`,
371
- cacheControl: "public,max-age=31536000,immutable",
372
- });
373
- }
374
- // Un-versioned files will be cached for 1 year at the CDN level.
375
- // But not at the browser level. CDN cache will be invalidated on deploy.
376
- else {
377
- const itemPath = path.join(clientPath, item);
378
- fileOptions.push({
379
- exclude: "*",
380
- include: fs.statSync(itemPath).isDirectory()
381
- ? `${item}/*`
382
- : `${item}`,
383
- cacheControl: "public,max-age=0,s-maxage=31536000,must-revalidate",
384
- });
385
- }
386
- }
387
400
  // Create custom resource
388
401
  return new CustomResource(this, "S3Deployment", {
389
402
  serviceToken: handler.functionArn,
@@ -5,7 +5,7 @@ import { FunctionProps, Function as Fn } from "./Function.js";
5
5
  import * as Config from "./Config.js";
6
6
  import { SSTConstruct } from "./Construct.js";
7
7
  import { Permissions } from "./util/permission.js";
8
- export declare type StackProps = cdk.StackProps;
8
+ export type StackProps = cdk.StackProps;
9
9
  /**
10
10
  * The Stack construct extends cdk.Stack. It automatically prefixes the stack names with the stage and app name to ensure that they can be deployed to multiple regions in the same AWS account. It also ensure that the stack uses the same AWS profile and region as the app. They're defined using functions that return resources that can be imported by other stacks.
11
11
  *
@@ -7,7 +7,7 @@ import { Function as Fn } from "./Function.js";
7
7
  import { isConstruct } from "./Construct.js";
8
8
  import { createRequire } from "module";
9
9
  import { useApp } from "./context.js";
10
- import { useProject } from "../app.js";
10
+ import { useProject } from "../project.js";
11
11
  const require = createRequire(import.meta.url);
12
12
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
13
13
  /**
@@ -14,7 +14,7 @@ export interface StaticSiteFileOptions {
14
14
  export interface StaticSiteProps {
15
15
  /**
16
16
  * Path to the directory where the website source is located.
17
- *
17
+ * @default "."
18
18
  * @example
19
19
  * ```js
20
20
  * new StaticSite(stack, "Site", {
@@ -22,7 +22,7 @@ export interface StaticSiteProps {
22
22
  * });
23
23
  * ```
24
24
  */
25
- path: string;
25
+ path?: string;
26
26
  /**
27
27
  * The name of the index page (e.g. "index.html") of the website.
28
28
  * @default "index.html"
@@ -300,7 +300,7 @@ export declare class StaticSite extends Construct implements SSTConstruct {
300
300
  private assets;
301
301
  private filenamesAsset?;
302
302
  private awsCliLayer;
303
- constructor(scope: Construct, id: string, props: StaticSiteProps);
303
+ constructor(scope: Construct, id: string, props?: StaticSiteProps);
304
304
  /**
305
305
  * The CloudFront URL of the website.
306
306
  */
@@ -21,7 +21,7 @@ import { getBuildCmdEnvironment, buildErrorResponsesFor404ErrorPage, buildErrorR
21
21
  import { isCDKConstruct } from "./Construct.js";
22
22
  import { ENVIRONMENT_PLACEHOLDER, getParameterPath, } from "./util/functionBinding.js";
23
23
  import { gray } from "colorette";
24
- import { useProject } from "../app.js";
24
+ import { useProject } from "../project.js";
25
25
  import { SiteEnv } from "../site-env.js";
26
26
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
27
27
  /////////////////////
@@ -51,19 +51,19 @@ export class StaticSite extends Construct {
51
51
  filenamesAsset;
52
52
  awsCliLayer;
53
53
  constructor(scope, id, props) {
54
- super(scope, props.cdk?.id || id);
54
+ super(scope, props?.cdk?.id || id);
55
+ const app = scope.node.root;
55
56
  this.id = id;
56
- const root = scope.node.root;
57
+ this.props = { path: ".", ...props };
58
+ this.cdk = {};
57
59
  // Local development or skip build => stub asset
58
60
  this.isPlaceholder =
59
- (root.local || root.skipBuild) && !props.disablePlaceholder;
60
- const fileSizeLimit = root.isRunningSSTTest()
61
+ (app.local || app.skipBuild) && !this.props.disablePlaceholder;
62
+ const fileSizeLimit = app.isRunningSSTTest()
61
63
  ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
62
64
  // @ts-ignore: "sstTestFileSizeLimitOverride" not exposed in props
63
- props.sstTestFileSizeLimitOverride || 200
65
+ this.props.sstTestFileSizeLimitOverride || 200
64
66
  : 200;
65
- this.props = props;
66
- this.cdk = {};
67
67
  this.awsCliLayer = new AwsCliLayer(this, "AwsCliLayer");
68
68
  this.registerSiteEnvironment();
69
69
  // Validate input
@@ -237,7 +237,7 @@ interface ImportMeta {
237
237
  throw new Error(`No build output found at "${siteOutputPath}" for the "${this.node.id}" StaticSite.`);
238
238
  }
239
239
  // create zip files
240
- const script = path.join(__dirname, "../support/base-site-archiver.cjs");
240
+ const script = path.join(__dirname, "../support/base-site-archiver.mjs");
241
241
  const zipPath = path.resolve(path.join(useProject().paths.artifacts, `StaticSite-${this.node.id}-${this.node.addr}`));
242
242
  // clear zip path to ensure no partX.zip remain from previous build
243
243
  fs.rmSync(zipPath, {
@@ -80,7 +80,7 @@ export interface TableGlobalIndexProps {
80
80
  index?: Omit<dynamodb.GlobalSecondaryIndexProps, "indexName" | "partitionKey" | "sortKey">;
81
81
  };
82
82
  }
83
- declare type TableFieldType = Lowercase<keyof typeof dynamodb.AttributeType>;
83
+ type TableFieldType = Lowercase<keyof typeof dynamodb.AttributeType>;
84
84
  export interface TableProps {
85
85
  /**
86
86
  * An object defining the fields of the table. Key is the name of the field and the value is the type.
@@ -28,5 +28,5 @@ export interface ViteStaticSiteProps extends StaticSiteProps {
28
28
  * ```
29
29
  */
30
30
  export declare class ViteStaticSite extends StaticSite {
31
- constructor(scope: Construct, id: string, props: ViteStaticSiteProps);
31
+ constructor(scope: Construct, id: string, props?: ViteStaticSiteProps);
32
32
  }
@@ -19,7 +19,8 @@ import { StaticSite } from "./StaticSite.js";
19
19
  */
20
20
  export class ViteStaticSite extends StaticSite {
21
21
  constructor(scope, id, props) {
22
- const { path: sitePath, environment, typesPath } = props || {};
22
+ const { path: pathRaw, environment, typesPath } = props || {};
23
+ const sitePath = pathRaw || ".";
23
24
  // generate buildCommand
24
25
  let defaultBuildCommand = "npm run build";
25
26
  if (fs.existsSync(path.join(sitePath, "yarn.lock"))) {
@@ -1,4 +1,4 @@
1
- declare type Task = () => Promise<void>;
1
+ type Task = () => Promise<void>;
2
2
  export declare const useDeferredTasks: () => {
3
3
  add(task: Task): void;
4
4
  run(): Promise<unknown>;
@@ -28,7 +28,7 @@ import { ENVIRONMENT_PLACEHOLDER, getParameterPath, } from "../util/functionBind
28
28
  import * as crossRegionHelper from "./cross-region-helper.js";
29
29
  import { gray, red } from "colorette";
30
30
  import { SiteEnv } from "../../site-env.js";
31
- import { useProject } from "../../app.js";
31
+ import { useProject } from "../../project.js";
32
32
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
33
33
  /////////////////////
34
34
  // Construct
@@ -6,7 +6,7 @@ export interface AccessLogProps {
6
6
  destinationArn?: string;
7
7
  retention?: Lowercase<keyof typeof logs.RetentionDays>;
8
8
  }
9
- export declare type AccessLogData = {
9
+ export type AccessLogData = {
10
10
  logGroup: logs.LogGroup | undefined;
11
11
  format: apig.AccessLogFormat;
12
12
  destination: apig.LogGroupLogDestination;
@@ -1,3 +1,3 @@
1
1
  import { Duration as CDKDuration } from "aws-cdk-lib";
2
- export declare type Duration = `${number} ${"second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days"}`;
2
+ export type Duration = `${number} ${"second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days"}`;
3
3
  export declare function toCdkDuration(duration: Duration): CDKDuration;
@@ -1,8 +1,8 @@
1
1
  import { IConstruct } from "constructs";
2
2
  import * as iam from "aws-cdk-lib/aws-iam";
3
- export declare type Permissions = "*" | Permission[];
4
- declare type SupportedPermissions = "execute-api" | "appsync" | "dynamodb" | "sns" | "sqs" | "events" | "kinesis" | "s3" | "rds-data" | "secretsmanager" | "lambda" | "ssm";
5
- declare type Permission = SupportedPermissions | Omit<string, SupportedPermissions> | IConstruct | [IConstruct, string] | iam.PolicyStatement;
3
+ export type Permissions = "*" | Permission[];
4
+ type SupportedPermissions = "execute-api" | "appsync" | "dynamodb" | "sns" | "sqs" | "events" | "kinesis" | "s3" | "rds-data" | "secretsmanager" | "lambda" | "ssm";
5
+ type Permission = SupportedPermissions | Omit<string, SupportedPermissions> | IConstruct | [IConstruct, string] | iam.PolicyStatement;
6
6
  export declare function attachPermissionsToRole(role: iam.Role, permissions: Permissions): void;
7
7
  export declare function attachPermissionsToPolicy(policy: iam.Policy, permissions: Permissions): void;
8
8
  export {};
@@ -1,3 +1,3 @@
1
1
  import * as cdk from "aws-cdk-lib";
2
- export declare type Size = `${number} ${"MB" | "GB"}`;
2
+ export type Size = `${number} ${"MB" | "GB"}`;
3
3
  export declare function toCdkSize(size: Size): cdk.Size;
@@ -9,7 +9,7 @@ export interface Handlers {
9
9
  response: SQSBatchResponse;
10
10
  };
11
11
  }
12
- declare type HandlerTypes = keyof Handlers;
12
+ type HandlerTypes = keyof Handlers;
13
13
  export declare function useEvent<Type extends HandlerTypes>(type: Type): Handlers[Type]["event"];
14
14
  export declare function useLambdaContext(): LambdaContext;
15
15
  export declare function Handler<Type extends HandlerTypes, Event = Handlers[Type]["event"], Response = Handlers[Type]["response"]>(type: Type, cb: (evt: Event, ctx: LambdaContext) => Promise<Response>): (event: Event, context: LambdaContext) => Promise<Response>;
package/credentials.d.ts CHANGED
@@ -4,7 +4,7 @@ import { RegionInputConfig } from "@aws-sdk/config-resolver";
4
4
  import { RetryInputConfig } from "@aws-sdk/middleware-retry";
5
5
  import { AwsAuthInputConfig } from "@aws-sdk/middleware-signing";
6
6
  import { SdkProvider } from "aws-cdk/lib/api/aws-auth/sdk-provider.js";
7
- declare type Config = RegionInputConfig & RetryInputConfig & AwsAuthInputConfig & HostHeaderConditionConfig;
7
+ type Config = RegionInputConfig & RetryInputConfig & AwsAuthInputConfig & HostHeaderConditionConfig;
8
8
  export declare const useAWSCredentialsProvider: () => import("@aws-sdk/types").CredentialProvider;
9
9
  export declare const useAWSCredentials: () => Promise<import("@aws-sdk/types").Credentials>;
10
10
  export declare const useSTSIdentity: () => Promise<import("@aws-sdk/client-sts").GetCallerIdentityCommandOutput>;
package/credentials.js CHANGED
@@ -7,9 +7,9 @@ import { SdkProvider } from "aws-cdk/lib/api/aws-auth/sdk-provider.js";
7
7
  import { StandardRetryStrategy } from "@aws-sdk/middleware-retry";
8
8
  export const useAWSCredentialsProvider = Context.memo(() => {
9
9
  const project = useProject();
10
- Logger.debug("Using AWS profile", project.profile);
10
+ Logger.debug("Using AWS profile", project.config.profile);
11
11
  const provider = fromNodeProviderChain({
12
- profile: project.profile,
12
+ profile: project.config.profile,
13
13
  });
14
14
  return provider;
15
15
  });
@@ -31,12 +31,14 @@ export function useAWSClient(client, force = false) {
31
31
  return existing;
32
32
  const [project, credentials] = [useProject(), useAWSCredentialsProvider()];
33
33
  const result = new client({
34
- region: project.region,
34
+ region: project.config.region,
35
35
  credentials: credentials,
36
36
  retryStrategy: new StandardRetryStrategy(async () => 10000, {
37
37
  retryDecider: (err) => {
38
38
  if (err.$fault === "client")
39
39
  return false;
40
+ if (err.name === "CredentialsProviderError")
41
+ return false;
40
42
  if (err.message === "Could not load credentials from any providers")
41
43
  return false;
42
44
  return true;
@@ -51,7 +53,7 @@ export function useAWSClient(client, force = false) {
51
53
  return result;
52
54
  }
53
55
  import aws from "aws-sdk";
54
- import { useProject } from "./app.js";
56
+ import { useProject } from "./project.js";
55
57
  const CredentialProviderChain = aws.CredentialProviderChain;
56
58
  /**
57
59
  * Do not use this. It is only used for AWS CDK compatibility.
@@ -81,9 +83,9 @@ export const useAWSProvider = Context.memo(async () => {
81
83
  secretAccessKey: creds.secretAccessKey,
82
84
  }),
83
85
  ]);
84
- const provider = new SdkProvider(chain, project.region, {
86
+ const provider = new SdkProvider(chain, project.config.region, {
85
87
  maxRetries: 10000,
86
- region: project.region,
88
+ region: project.config.region,
87
89
  });
88
90
  return provider;
89
91
  });
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export type { SSTConfig } from "./project.js";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/iot.js CHANGED
@@ -15,7 +15,7 @@ export const useIOTEndpoint = Context.memo(async () => {
15
15
  });
16
16
  import iot from "aws-iot-device-sdk";
17
17
  import { useBus } from "./bus.js";
18
- import { useProject } from "./app.js";
18
+ import { useProject } from "./project.js";
19
19
  import { Logger } from "./logger.js";
20
20
  export const useIOT = Context.memo(async () => {
21
21
  const bus = useBus();
@@ -29,7 +29,7 @@ export const useIOT = Context.memo(async () => {
29
29
  secretKey: creds.secretAccessKey,
30
30
  sessionToken: creds.sessionToken,
31
31
  });
32
- const PREFIX = `/sst/${project.name}/${project.stage}`;
32
+ const PREFIX = `/sst/${project.config.name}/${project.config.stage}`;
33
33
  device.subscribe(`${PREFIX}/events`);
34
34
  const fragments = new Map();
35
35
  device.on("error", (err) => {
package/logger.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from "fs/promises";
2
2
  import path from "path";
3
- import { useProject } from "./app.js";
3
+ import { useProject } from "./project.js";
4
4
  import { Context } from "./context/context.js";
5
5
  let previous = new Date();
6
6
  const useFile = Context.memo(async () => {
@@ -40,3 +40,5 @@ export declare function useHeader(key: string): string | undefined;
40
40
  export declare function useFormValue(name: string): string | null | undefined;
41
41
  export declare function useQueryParams(): import("aws-lambda").APIGatewayProxyEventQueryStringParameters;
42
42
  export declare function useQueryParam(name: string): string | undefined;
43
+ export declare function usePathParams(): import("aws-lambda").APIGatewayProxyEventPathParameters;
44
+ export declare function usePathParam(name: string): string | undefined;
package/node/api/index.js CHANGED
@@ -86,3 +86,11 @@ export function useQueryParams() {
86
86
  export function useQueryParam(name) {
87
87
  return useQueryParams()[name];
88
88
  }
89
+ export function usePathParams() {
90
+ const evt = useEvent("api");
91
+ const path = evt.pathParameters || {};
92
+ return path;
93
+ }
94
+ export function usePathParam(name) {
95
+ return usePathParams()[name];
96
+ }
@@ -1,3 +1,3 @@
1
1
  import { APIGatewayProxyStructuredResultV2 } from "aws-lambda";
2
2
  export declare function createAdapter<A extends (config: any) => Adapter>(adapter: A): A;
3
- export declare type Adapter = () => Promise<APIGatewayProxyStructuredResultV2>;
3
+ export type Adapter = () => Promise<APIGatewayProxyStructuredResultV2>;
@@ -5,17 +5,17 @@ import { OidcAdapter } from "./oidc.js";
5
5
  const issuer = new Issuer({
6
6
  issuer: "https://github.com",
7
7
  authorization_endpoint: "https://github.com/login/oauth/authorize",
8
- token_endpoint: "https://github.com/login/oauth/access_token"
8
+ token_endpoint: "https://github.com/login/oauth/access_token",
9
9
  });
10
10
  export const GithubAdapter = /* @__PURE__ */ createAdapter((config) => {
11
- if ("clientSecret" in config) {
11
+ if (config.clientSecret) {
12
12
  return OauthAdapter({
13
13
  issuer,
14
- ...config
14
+ ...config,
15
15
  });
16
16
  }
17
17
  return OidcAdapter({
18
18
  issuer,
19
- ...config
19
+ ...config,
20
20
  });
21
21
  });
@@ -1,6 +1,6 @@
1
1
  import { OauthBasicConfig } from "./oauth.js";
2
2
  import { OidcBasicConfig } from "./oidc.js";
3
- declare type GoogleConfig = (OauthBasicConfig & {
3
+ type GoogleConfig = (OauthBasicConfig & {
4
4
  mode: "oauth";
5
5
  }) | (OidcBasicConfig & {
6
6
  mode: "oidc";
@@ -3,7 +3,7 @@ import { APIGatewayProxyStructuredResultV2 } from "aws-lambda";
3
3
  export interface SessionTypes {
4
4
  public: {};
5
5
  }
6
- export declare type SessionValue = {
6
+ export type SessionValue = {
7
7
  [type in keyof SessionTypes]: {
8
8
  type: type;
9
9
  properties: SessionTypes[type];
@@ -4,10 +4,10 @@ export interface SecretResources {
4
4
  }
5
5
  export interface ConfigTypes {
6
6
  }
7
- export declare type ParameterTypes = {
7
+ export type ParameterTypes = {
8
8
  [T in keyof ParameterResources]: string;
9
9
  };
10
- export declare type SecretTypes = {
10
+ export type SecretTypes = {
11
11
  [T in keyof SecretResources]: string;
12
12
  };
13
13
  export declare const Config: ConfigTypes & ParameterTypes & SecretTypes;
@@ -2,10 +2,10 @@ export interface JobResources {
2
2
  }
3
3
  export interface JobTypes {
4
4
  }
5
- export declare type JobRunProps<T extends keyof JobResources> = {
5
+ export type JobRunProps<T extends keyof JobResources> = {
6
6
  payload?: JobTypes[T];
7
7
  };
8
- export declare type JobType = {
8
+ export type JobType = {
9
9
  [T in keyof JobResources]: ReturnType<typeof JobControl<T>>;
10
10
  };
11
11
  export declare const Job: JobType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.21",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -17,6 +17,7 @@
17
17
  "./constructs": "./constructs/index.js",
18
18
  "./context": "./context/index.js",
19
19
  "./node/*": "./node/*/index.js",
20
+ ".": "./index.js",
20
21
  "./*": "./*"
21
22
  },
22
23
  "homepage": "https://sst.dev",
@@ -45,6 +46,7 @@
45
46
  "@babel/core": "^7.0.0-0",
46
47
  "@babel/generator": "^7.20.5",
47
48
  "@trpc/server": "9.16.0",
49
+ "archiver": "^5.3.1",
48
50
  "aws-cdk": "2.55.0",
49
51
  "aws-cdk-lib": "2.55.0",
50
52
  "aws-iot-device-sdk": "^2.2.12",
@@ -59,16 +61,17 @@
59
61
  "cross-spawn": "^7.0.3",
60
62
  "dendriform-immer-patch-optimiser": "^2.1.0",
61
63
  "dotenv": "^16.0.3",
62
- "esbuild": "0.16.9",
64
+ "esbuild": "0.16.13",
63
65
  "express": "^4.18.2",
64
66
  "fast-jwt": "^1.6.1",
65
67
  "glob": "^8.0.3",
68
+ "graphql": "*",
66
69
  "graphql-helix": "^1.12.0",
67
70
  "immer": "9",
68
71
  "ink": "^3.2.0",
69
72
  "ink-spinner": "^4.0.3",
70
- "kysely": "^0.22.0",
71
- "kysely-codegen": "^0.8.0",
73
+ "kysely": "^0.23.3",
74
+ "kysely-codegen": "^0.9.0",
72
75
  "kysely-data-api": "^0.1.4",
73
76
  "openid-client": "^5.1.8",
74
77
  "ora": "^6.1.2",
@@ -77,8 +80,6 @@
77
80
  "remeda": "^1.3.0",
78
81
  "undici": "^5.12.0",
79
82
  "uuid": "^9.0.0",
80
- "vite": "^3.2.4",
81
- "vite-node": "^0.25.2",
82
83
  "ws": "^8.11.0",
83
84
  "yaml": "1.10.2",
84
85
  "yargs": "^17.6.2",
@@ -100,21 +101,15 @@
100
101
  "@types/uuid": "^8.3.4",
101
102
  "@types/ws": "^8.5.3",
102
103
  "@types/yargs": "^17.0.13",
103
- "archiver": "^5.3.1",
104
- "graphql": "^16.5.0",
105
104
  "tsx": "^3.12.1",
106
105
  "vitest": "^0.15.1"
107
106
  },
108
107
  "peerDependencies": {
109
- "@sls-next/lambda-at-edge": "^3.7.0",
110
- "graphql": "^16.5.0"
108
+ "@sls-next/lambda-at-edge": "^3.7.0"
111
109
  },
112
110
  "peerDependenciesMeta": {
113
111
  "@sls-next/lambda-at-edge": {
114
112
  "optional": true
115
- },
116
- "graphql": {
117
- "optional": true
118
113
  }
119
114
  },
120
115
  "bugs": {