@devkong/cli-nx 0.0.8 → 0.0.11

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.8",
3
+ "version": "0.0.11",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "recommendations": [
3
+ "dbaeumer.vscode-eslint",
4
+ "esbenp.prettier-vscode",
3
5
  "ms-python.black-formatter",
4
6
  "ms-python.isort",
5
7
  "ms-python.pylint",
6
8
  "ms-python.python",
7
9
  "ms-python.vscode-pylance",
8
- "stylelint.vscode-stylelint",
9
- "dbaeumer.vscode-eslint",
10
10
  "nrwl.angular-console",
11
- "esbenp.prettier-vscode"
11
+ "streetsidesoftware.code-spell-checker",
12
+ "stylelint.vscode-stylelint"
12
13
  ]
13
14
  }
@@ -10,7 +10,7 @@
10
10
  "python": ".\\.venv\\Scripts\\python.exe"
11
11
  },
12
12
  "linux": {
13
- "python": ".venv/bin/python3"
13
+ "python": ".venv/bin/python"
14
14
  },
15
15
  "justMyCode": true
16
16
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "files.eol": "\n",
3
3
  "python.languageServer": "Pylance",
4
- "python.formatting.provider": "none",
5
4
  "[python]": {
6
5
  "editor.defaultFormatter": "ms-python.black-formatter",
7
6
  "editor.formatOnSave": true,
@@ -10,14 +9,10 @@
10
9
  }
11
10
  },
12
11
  "isort.args": ["--profile", "black"],
13
- "explorer.fileNesting.enabled": true,
14
- "explorer.fileNesting.patterns": {
15
- "config.json": "config.*.json"
16
- },
17
12
  "json.schemas": [
18
13
  {
19
14
  "fileMatch": ["**/kong.json"],
20
- "url": "./node_modules/@kong/cli/assets/kong-json-schema.json"
15
+ "url": "http://kong.dev.re.app-dfi.net/kong-cli-schema.json"
21
16
  }
22
17
  ],
23
18
  "cSpell.words": [
@@ -32,12 +27,14 @@
32
27
  "conint",
33
28
  "contextlib",
34
29
  "contextmanager",
30
+ "devkong",
35
31
  "docparams",
36
32
  "docstrings",
37
33
  "elif",
38
34
  "fstring",
39
35
  "inlinevar",
40
36
  "isort",
37
+ "libpeerconnection",
41
38
  "metaclass",
42
39
  "msvs",
43
40
  "mymodule",
@@ -48,6 +45,8 @@
48
45
  "optparse",
49
46
  "overgeneral",
50
47
  "parseable",
48
+ "protoeditor",
49
+ "pycache",
51
50
  "pyenchant",
52
51
  "pylint",
53
52
  "pytest",
@@ -55,6 +54,9 @@
55
54
  "rexec",
56
55
  "rgxs",
57
56
  "TERMIOS",
58
- "typevar"
57
+ "testem",
58
+ "typevar",
59
+ "unittests",
60
+ "venv"
59
61
  ]
60
62
  }
@@ -6,15 +6,15 @@ Welcome to the Kong extension development workspace!
6
6
 
7
7
  Before you start, make sure you have the following installed:
8
8
 
9
- - [Node.js](https://nodejs.org/en/download), version >= 20.0
9
+ - [Node.js](https://nodejs.org/en/download/prebuilt-installer), version >= 20.0
10
10
  - [Python](https://www.python.org/downloads/), version >= 3.9
11
- - [Docker](https://docs.docker.com/engine/install/)
11
+ - [Docker](https://docs.docker.com/desktop/)
12
12
 
13
13
  To verify the installation and check the versions, run the following commands:
14
14
 
15
15
  ```shell script
16
16
  node --version
17
- python --version
17
+ python --version # or python3 --version
18
18
  docker info
19
19
  ```
20
20
 
@@ -32,7 +32,7 @@ kong configure
32
32
  kong install --verbose
33
33
  ```
34
34
 
35
- That's it! Now, modify your code, tag it by publishing a new version, and assign aliases for use in the workflow.
35
+ That's it! Now, modify [main.py](./src/main.py), tag it by publishing a new version, and assign aliases for use in the workflow.
36
36
 
37
37
  ### Publish a New Version
38
38
 
@@ -3,21 +3,6 @@
3
3
  "$schema": "./node_modules/nx/schemas/project-schema.json",
4
4
  "projectType": "application",
5
5
  "sourceRoot": "./src",
6
- "targets": {
7
- "install": {
8
- "executor": "nx:run-commands",
9
- "options": {
10
- "cwd": "{workspaceRoot}",
11
- "commands": [
12
- "python -m venv .venv",
13
- <% if(os === "win32"){ %>
14
- ".\\.venv\\scripts\\activate.bat & pip install -r requirements-dev.txt -r requirements.txt"
15
- <% } else { %>
16
- ".venv/bin/activate && pip install -r requirements-dev.txt -r requirements.txt"
17
- <% } %>
18
- ]
19
- }
20
- }
21
- },
6
+ "targets": {},
22
7
  "tags": []
23
8
  }
@@ -1,10 +1,9 @@
1
1
  import sys
2
2
  from typing import Optional
3
- from uuid import UUID
4
3
 
5
4
  from kong.sdk.app import App
6
5
  from kong.sdk.kong_function import KongFunction
7
- from pydantic import BaseModel, EmailStr, Field
6
+ from pydantic import BaseModel, Field
8
7
 
9
8
  # This script is for developing an extension for Kong.
10
9
  # For more details, please refer to the README.md file.
@@ -16,49 +15,52 @@ class InputData(BaseModel):
16
15
  # sample objects in the UI, making it easier to work with the models.
17
16
  # For more standard types, refer to: https://docs.pydantic.dev/latest/concepts/types/
18
17
 
19
- string_field: str = Field(
20
- examples=["Hello"],
21
- description="A string",
22
- )
18
+ # REPLACE BELLOW WITH YOUR FIELDS
23
19
 
24
- integer_field: int = Field(
25
- examples=[42],
20
+ a: int = Field(
21
+ examples=[1],
26
22
  description="An integer number",
27
23
  )
28
24
 
29
- optional_field: Optional[UUID] = Field(
30
- None,
31
- examples=["123e4567-e89b-12d3-a456-426614174000"],
32
- description="An optional UUID field",
33
- )
34
-
35
- email_list: list[EmailStr] = Field(
36
- examples=["one@example.com", "two@example.com"],
37
- description="A list of emails",
25
+ b: int = Field(
26
+ examples=[2],
27
+ description="An integer number",
38
28
  )
39
29
 
40
30
 
41
31
  class OutputData(BaseModel):
42
32
  # Define the structure of the output data that your extension will return.
43
33
 
44
- value: str = Field(examples=["Hello"], description="Value from the string_field")
34
+ # REPLACE BELLOW WITH YOUR FIELDS
35
+
36
+ sum_of: int = Field(
37
+ examples=[3],
38
+ description="Result of a + b",
39
+ )
45
40
 
41
+ comment: Optional[str] = Field(
42
+ examples=["This example extension returns sum of a and b"],
43
+ description="A string field",
44
+ )
46
45
 
47
- class ExtensionTemplate(KongFunction):
48
- # This is where you implement the logic to handle the input data and produce the output.
49
- # Override the `handle` method to customize the processing of input data.
50
46
 
51
- async def handle(self, data: InputData) -> OutputData:
52
- # In this example, we are simply returning
53
- # the value of 'string_field' as the output.
47
+ class MyExtension(KongFunction):
48
+ # This is where you implement the logic to handle the input data
49
+ # and produce the output.
54
50
 
55
- return OutputData(value=data.string_field)
51
+ # OVERRIDE BELLOW TO CUSTOMIZE THE PROCESSING.
52
+
53
+ async def handle(self, data: InputData) -> OutputData:
54
+ return OutputData(
55
+ sum_of=data.a + data.b,
56
+ comment=f"sum of {data.a} and {data.b}",
57
+ )
56
58
 
57
59
 
58
60
  app = App(
59
61
  InputData,
60
62
  OutputData,
61
- ExtensionTemplate,
63
+ MyExtension,
62
64
  )
63
65
 
64
66
  if __name__ == "__main__":
@@ -1,21 +1,18 @@
1
1
  from kong.sdk.conftest import ExtensionFixture
2
-
3
- from src.main import ExtensionTemplate, InputData
2
+ from src.main import InputData, MyExtension
4
3
 
5
4
 
6
5
  # The test function to validate the behavior of the extension
7
6
  async def test_should_return_value_from_string_field_when_input_is_provided(
8
7
  create_extension: ExtensionFixture,
9
8
  ):
10
- extension = create_extension(ExtensionTemplate, InputData)
9
+ extension = create_extension(MyExtension, InputData)
11
10
 
12
11
  # Prepare the input data
13
12
  input_data = InputData(
14
- string_field="test",
15
- integer_field=42,
16
- optional_field=None,
17
- email_list=["one@example.com", "two@example.com"],
13
+ a=1,
14
+ b=2,
18
15
  )
19
16
 
20
17
  output = await extension.handle(input_data)
21
- assert output.value == "test"
18
+ assert output.sum_of == 3