@devkong/cli-nx 0.0.67-alpha.25 → 0.0.67-alpha.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli-nx",
3
- "version": "0.0.67-alpha.25",
3
+ "version": "0.0.67-alpha.26",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -1,24 +1,22 @@
1
1
  import sys
2
2
  from datetime import timedelta
3
3
 
4
- from frontend import frontend
5
- from input_data import InputData
6
4
  from kong.sdk.app import App
7
- from kong.sdk.app_logger import app_logger
8
5
  from kong.sdk.kong_function import KongFunction
9
6
  from kong.sdk.kong_function_context import KongFunctionContext
10
7
  from kong.sdk.s3 import S3Secret
8
+
9
+ from frontend import frontend
10
+ from input_data import InputData
11
11
  from output_data import OutputData
12
12
  from s3 import create_s3_client
13
13
 
14
14
 
15
15
  class Main(KongFunction):
16
- __logger = app_logger(__name__)
17
-
18
16
  async def handle(self, data: InputData, context: KongFunctionContext) -> OutputData:
19
17
  secret: S3Secret = context.secret.get("s3").data
20
18
  client = await context.state.use(
21
- key=f"{secret.endpoint}:{secret.port}:{secret.bucket}:{secret.access_key}",
19
+ key=f"{secret.endpoint}:{secret.port}:{secret.bucket}:{secret.accessKey}",
22
20
  create=lambda: create_s3_client(secret),
23
21
  unused=(timedelta(minutes=5), lambda c: c.close()),
24
22
  )
@@ -29,14 +27,7 @@ class Main(KongFunction):
29
27
  )
30
28
 
31
29
  body = await response["Body"].read()
32
- self.__logger.info(
33
- "have response from S3",
34
- lambda: {
35
- "bucket": secret.bucket,
36
- "key": data.execute.key,
37
- "size": len(body),
38
- },
39
- )
30
+ print("body size:", len(body))
40
31
 
41
32
  return OutputData(
42
33
  key=data.execute.key,
@@ -1,23 +1,19 @@
1
- from datetime import timedelta
2
- from types import SimpleNamespace
3
-
4
1
  from frontend import frontend
5
2
  from input_data import ExecuteData, InputData
6
3
  from kong.sdk.conftest import ExtensionFixture, extension_test_context
7
4
  from kong.sdk.kong_function_request import KongFunctionRequest
8
- from kong.sdk.kong_state_context import KongStateContext
9
5
  from kong.sdk.s3 import S3Secret
10
- from main import Main, client_cache_key
6
+ from main import Main
11
7
 
12
8
  S3_SECRET = S3Secret(
13
- access_key="access",
14
- secret_key="secret",
9
+ accessKey="access",
10
+ secretKey="secret",
15
11
  bucket="my-bucket",
16
12
  region="us-east-1",
17
13
  endpoint=None,
18
14
  port=None,
19
- use_ssl=True,
20
- path_style=False,
15
+ useSSL=True,
16
+ pathStyle=False,
21
17
  )
22
18
 
23
19
 
@@ -1,5 +1,3 @@
1
- from typing import Optional
2
-
3
1
  from pydantic import BaseModel, Field
4
2
 
5
3
 
@@ -8,14 +6,3 @@ class OutputData(BaseModel):
8
6
  examples=["test/example.json"],
9
7
  description="Key of the object that was downloaded",
10
8
  )
11
-
12
- size: int = Field(
13
- examples=[42],
14
- description="Size of the downloaded object, in bytes",
15
- )
16
-
17
- content: Optional[str] = Field(
18
- default=None,
19
- examples=['{"hello": "world"}'],
20
- description="UTF-8 decoded content of the downloaded object",
21
- )
@@ -8,7 +8,7 @@ async def create_s3_client(secret: S3Secret):
8
8
  # stores (MinIO, Ceph, ...) need an explicit endpoint override.
9
9
  endpoint_url = None
10
10
  if secret.endpoint and "amazonaws.com" not in secret.endpoint:
11
- scheme = "https" if secret.use_ssl else "http"
11
+ scheme = "https" if secret.useSSL else "http"
12
12
  endpoint_url = (
13
13
  f"{scheme}://{secret.endpoint}:{secret.port}"
14
14
  if secret.port
@@ -19,9 +19,9 @@ async def create_s3_client(secret: S3Secret):
19
19
  "s3",
20
20
  region_name=secret.region,
21
21
  endpoint_url=endpoint_url,
22
- use_ssl=secret.use_ssl,
23
- aws_access_key_id=secret.access_key,
24
- aws_secret_access_key=secret.secret_key,
25
- config=(Config(s3={"addressing_style": "path"}) if secret.path_style else None),
22
+ use_ssl=secret.useSSL,
23
+ aws_access_key_id=secret.accessKey,
24
+ aws_secret_access_key=secret.secretKey,
25
+ config=(Config(s3={"addressing_style": "path"}) if secret.pathStyle else None),
26
26
  )
27
27
  return await client_context.__aenter__()