sst 2.2.0 → 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.
@@ -6,5 +6,6 @@ export * from "./adapter/google.js";
6
6
  export * from "./adapter/link.js";
7
7
  export * from "./adapter/github.js";
8
8
  export * from "./adapter/oauth.js";
9
+ export type { Adapter } from "./adapter/adapter.js";
9
10
  export * from "./session.js";
10
11
  export * from "./handler.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -79,7 +79,7 @@
79
79
  "ora": "^6.1.2",
80
80
  "react": "17.0.2",
81
81
  "remeda": "^1.3.0",
82
- "sst-aws-cdk": "2.62.2-2",
82
+ "sst-aws-cdk": "2.62.2-3",
83
83
  "undici": "^5.12.0",
84
84
  "uuid": "^9.0.0",
85
85
  "ws": "^8.11.0",
@@ -33,7 +33,6 @@ export const useNodeHandler = Context.memo(async () => {
33
33
  new Promise(async () => {
34
34
  const worker = new Worker(url.fileURLToPath(new URL("../../support/nodejs-runtime/index.mjs", import.meta.url)), {
35
35
  env: {
36
- ...process.env,
37
36
  ...input.environment,
38
37
  IS_LOCAL: "true",
39
38
  },
package/runtime/server.js CHANGED
@@ -73,8 +73,10 @@ export const useRuntimeServer = Context.memo(async () => {
73
73
  "Lambda-Runtime-Aws-Request-Id": payload.context.awsRequestId,
74
74
  "Lambda-Runtime-Deadline-Ms": Date.now() + payload.deadline,
75
75
  "Lambda-Runtime-Invoked-Function-Arn": payload.context.invokedFunctionArn,
76
- "Lambda-Runtime-Client-Context": JSON.stringify(payload.context.clientContext || {}),
77
- "Lambda-Runtime-Cognito-Identity": JSON.stringify(payload.context.identity || {}),
76
+ "Lambda-Runtime-Client-Context": JSON.stringify(payload.context.clientContext || null),
77
+ "Lambda-Runtime-Cognito-Identity": JSON.stringify(payload.context.identity || null),
78
+ "Lambda-Runtime-Log-Group-Name": payload.context.logGroupName,
79
+ "Lambda-Runtime-Log-Stream-Name": payload.context.logStreamName,
78
80
  });
79
81
  res.json(payload.event);
80
82
  });
package/sst.mjs CHANGED
@@ -2415,11 +2415,13 @@ var init_server2 = __esm({
2415
2415
  "Lambda-Runtime-Deadline-Ms": Date.now() + payload.deadline,
2416
2416
  "Lambda-Runtime-Invoked-Function-Arn": payload.context.invokedFunctionArn,
2417
2417
  "Lambda-Runtime-Client-Context": JSON.stringify(
2418
- payload.context.clientContext || {}
2418
+ payload.context.clientContext || null
2419
2419
  ),
2420
2420
  "Lambda-Runtime-Cognito-Identity": JSON.stringify(
2421
- payload.context.identity || {}
2422
- )
2421
+ payload.context.identity || null
2422
+ ),
2423
+ "Lambda-Runtime-Log-Group-Name": payload.context.logGroupName,
2424
+ "Lambda-Runtime-Log-Stream-Name": payload.context.logStreamName
2423
2425
  });
2424
2426
  res.json(payload.event);
2425
2427
  }
@@ -4525,7 +4527,6 @@ var init_node = __esm({
4525
4527
  ),
4526
4528
  {
4527
4529
  env: {
4528
- ...process.env,
4529
4530
  ...input.environment,
4530
4531
  IS_LOCAL: "true"
4531
4532
  },
@@ -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