sst 2.1.35 → 2.2.1

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 (41) hide show
  1. package/bootstrap.js +1 -1
  2. package/cdk/cloudformation-deployments-wrapper.d.ts +1 -1
  3. package/cdk/cloudformation-deployments-wrapper.js +6 -6
  4. package/cdk/cloudformation-deployments.d.ts +8 -8
  5. package/cdk/cloudformation-deployments.js +7 -7
  6. package/cdk/deploy-stack.d.ts +6 -6
  7. package/cdk/deploy-stack.js +9 -9
  8. package/cli/colors.d.ts +9 -20
  9. package/cli/commands/deploy.js +8 -6
  10. package/cli/commands/remove.js +1 -1
  11. package/cli/ui/deploy.d.ts +1 -0
  12. package/cli/ui/deploy.js +1 -1
  13. package/constructs/App.d.ts +4 -27
  14. package/constructs/App.js +5 -31
  15. package/constructs/Cron.d.ts +1 -1
  16. package/constructs/EventBus.d.ts +68 -35
  17. package/constructs/EventBus.js +13 -4
  18. package/constructs/Function.js +36 -33
  19. package/constructs/Job.js +6 -5
  20. package/constructs/RDS.js +4 -8
  21. package/constructs/Script.js +1 -1
  22. package/constructs/SsrSite.js +3 -1
  23. package/constructs/Stack.d.ts +8 -0
  24. package/constructs/Stack.js +17 -8
  25. package/constructs/StaticSite.js +3 -1
  26. package/constructs/deprecated/NextjsSite.js +2 -1
  27. package/credentials.d.ts +1 -1
  28. package/credentials.js +1 -1
  29. package/node/future/auth/index.d.ts +1 -0
  30. package/node/future/auth/session.js +1 -8
  31. package/package.json +8 -12
  32. package/runtime/handlers/node.js +0 -1
  33. package/runtime/server.js +4 -2
  34. package/sst.mjs +40 -37
  35. package/stacks/synth.d.ts +1 -1
  36. package/stacks/synth.js +3 -3
  37. package/support/bootstrap-metadata-function/index.mjs +1027 -274
  38. package/support/bridge/bridge.mjs +46 -35
  39. package/support/custom-resources/index.mjs +1663 -910
  40. package/support/nodejs-runtime/index.mjs +38 -2
  41. package/support/python-runtime/runtime.py +10 -4
@@ -75,7 +75,7 @@ while (true) {
75
75
  }, 1e3 * 60 * 15);
76
76
  let request;
77
77
  let response;
78
- let context = {};
78
+ let context;
79
79
  try {
80
80
  const result = await fetch({
81
81
  path: `/runtime/invocation/next`,
@@ -84,7 +84,43 @@ while (true) {
84
84
  });
85
85
  context = {
86
86
  awsRequestId: result.headers["lambda-runtime-aws-request-id"],
87
- invokedFunctionArn: result.headers["lambda-runtime-invoked-function-arn"]
87
+ invokedFunctionArn: result.headers["lambda-runtime-invoked-function-arn"],
88
+ getRemainingTimeInMillis: () => Math.max(
89
+ Number(result.headers["lambda-runtime-deadline-ms"]) - Date.now(),
90
+ 0
91
+ ),
92
+ identity: JSON.parse(result.headers["lambda-runtime-cognito-identity"]) ?? void 0,
93
+ clientContext: JSON.parse(result.headers["lambda-runtime-client-context"]) ?? void 0,
94
+ functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
95
+ functionVersion: process.env.AWS_LAMBDA_FUNCTION_VERSION,
96
+ memoryLimitInMB: process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE,
97
+ logGroupName: result.headers["lambda-runtime-log-group-name"],
98
+ logStreamName: result.headers["lambda-runtime-log-stream-name"],
99
+ callbackWaitsForEmptyEventLoop: {
100
+ set value(_value) {
101
+ throw new Error(
102
+ "`callbackWaitsForEmptyEventLoop` on lambda Context is not implemented by SST Live Lambda Development."
103
+ );
104
+ },
105
+ get value() {
106
+ return true;
107
+ }
108
+ }.value,
109
+ done() {
110
+ throw new Error(
111
+ "`done` on lambda Context is not implemented by SST Live Lambda Development."
112
+ );
113
+ },
114
+ fail() {
115
+ throw new Error(
116
+ "`fail` on lambda Context is not implemented by SST Live Lambda Development."
117
+ );
118
+ },
119
+ succeed() {
120
+ throw new Error(
121
+ "`succeed` on lambda Context is not implemented by SST Live Lambda Development."
122
+ );
123
+ }
88
124
  };
89
125
  request = JSON.parse(result.body);
90
126
  } catch {
@@ -21,14 +21,18 @@ class ClientContext(object):
21
21
  #__slots__ = ['custom', 'env', 'client']
22
22
 
23
23
  class Context(object):
24
- def __init__(self, invoked_function_arn, aws_request_id, deadline_ms, identity, client_context):
24
+ def __init__(self, invoked_function_arn, aws_request_id, deadline_ms, identity, client_context, log_group_name, log_stream_name):
25
25
  self.function_name = os.environ['AWS_LAMBDA_FUNCTION_NAME']
26
26
  self.invoked_function_arn = invoked_function_arn
27
27
  self.aws_request_id = aws_request_id
28
28
  self.memory_limit_in_mb = os.environ['AWS_LAMBDA_FUNCTION_MEMORY_SIZE']
29
29
  self.deadline_ms = deadline_ms
30
- self.identity = Identity(**json.loads(identity))
31
- self.client_context = ClientContext(**json.loads(client_context))
30
+ # If identity is null, we want to mimick AWS behavior and return an object with None values
31
+ self.identity = Identity(**json.loads(identity)) if identity != 'null' else Identity(cognito_identity_id = None, cognito_identity_pool_id = None)
32
+ # If client_context is null, we want to mimick AWS behavior and return None
33
+ self.client_context = ClientContext(**json.loads(client_context)) if client_context != 'null' else None
34
+ self.log_group_name = log_group_name
35
+ self.log_stream_name = log_stream_name
32
36
 
33
37
  def get_remaining_time_in_millis(self):
34
38
  return int(max(self.deadline_ms - int(round(time() * 1000)), 0))
@@ -75,7 +79,9 @@ if __name__ == '__main__':
75
79
  r.getheader('Lambda-Runtime-Aws-Request-Id'),
76
80
  r.getheader('Lambda-Runtime-Deadline-Ms'),
77
81
  r.getheader('Lambda-Runtime-Cognito-Identity'),
78
- r.getheader('Lambda-Runtime-Client-Context')
82
+ r.getheader('Lambda-Runtime-Client-Context'),
83
+ r.getheader('Lambda-Runtime-Log-Group-Name'),
84
+ r.getheader('Lambda-Runtime-Log-Stream-Name')
79
85
  )
80
86
 
81
87
  # invoke handler