@devkong/cli-nx 0.0.45 → 0.0.48

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.45",
3
+ "version": "0.0.48",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -11,7 +11,7 @@ COPY --chown=quarkus:quarkus .editorconfig /code/
11
11
  USER quarkus
12
12
  WORKDIR /code
13
13
  COPY src /code/src
14
- RUN ./gradlew build -Dquarkus.package.main-class=io.kong.sdkkotlin.QuarkusApp -Dquarkus.native.enabled=true -Dquarkus.profile=prod -Dquarkus.package.jar.enabled=false
14
+ RUN ./gradlew build -Dquarkus.package.main-class=io.kong.sdk.function.template.QuarkusApp -Dquarkus.native.enabled=true -Dquarkus.profile=prod -Dquarkus.package.jar.enabled=false
15
15
 
16
16
  ## Stage 2 : create the docker final image
17
17
  FROM quay.io/quarkus/quarkus-micro-image:2.0
@@ -1,4 +1,7 @@
1
1
  val javaVersion: String by project
2
+ val kongSdkVersion: String by project
3
+ val kongVersion: String by project
4
+ val kotlinxCoroutinesTestVersion: String by project
2
5
  val quarkusVersion: String by project
3
6
 
4
7
  plugins {
@@ -12,16 +15,16 @@ repositories {
12
15
  mavenCentral()
13
16
  mavenLocal()
14
17
  maven {
15
- url = uri("https://nexus.shared.app-dts.net/repository/maven-releases/")
18
+ url = uri("https://nexus.shared.sg.app-dts.net/repository/maven-releases/")
16
19
  }
17
20
  maven {
18
- url = uri("https://nexus.shared.app-dts.net/repository/maven-snapshots/")
21
+ url = uri("https://nexus.shared.sg.app-dts.net/repository/maven-snapshots/")
19
22
  }
20
23
  }
21
24
 
22
25
  dependencies {
23
- implementation("io.kong:kong-common:0.0.7-SNAPSHOT")
24
- implementation("io.kong:kong-sdk-kotlin:0.0.31-SNAPSHOT")
26
+ implementation("io.kong:kong-common:$kongVersion")
27
+ implementation("io.kong:kong-sdk-function-template:$kongSdkVersion")
25
28
 
26
29
  implementation(enforcedPlatform("io.quarkus.platform:quarkus-bom:$quarkusVersion"))
27
30
  implementation("io.quarkus:quarkus-arc")
@@ -32,6 +35,7 @@ dependencies {
32
35
  implementation("io.quarkus:quarkus-smallrye-health")
33
36
 
34
37
  testImplementation("io.quarkus:quarkus-junit5")
38
+ testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesTestVersion")
35
39
  }
36
40
 
37
41
  group = "io.kong"
@@ -12,11 +12,17 @@ jsonSchemaValidatorVersion=1.5.8
12
12
  # https://mvnrepository.com/artifact/io.github.khalilou88.jnxplus/jnxplus-gradle-plugin
13
13
  jnxplusGradlePluginVersion=0.4.0
14
14
 
15
- #https://mvnrepository.com/artifact/com.networknt/json-schema-validator
16
- jsonSchemaValidatorVersion=1.5.8
15
+ # Version of Kong SDK artifacts
16
+ kongSdkVersion=0.0.8-SNAPSHOT
17
+
18
+ # Version of Kong non-SDK artifacts
19
+ kongVersion=0.0.1-SNAPSHOT
17
20
 
18
21
  # https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
19
22
  kotlinVersion=2.1.10
20
23
 
24
+ # https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-test
25
+ kotlinxCoroutinesTestVersion=1.10.2
26
+
21
27
  # https://mvnrepository.com/artifact/io.quarkus/quarkus-core
22
28
  quarkusVersion=3.18.4
@@ -3,6 +3,46 @@
3
3
  "$schema": "./node_modules/nx/schemas/project-schema.json",
4
4
  "projectType": "application",
5
5
  "sourceRoot": "./src",
6
- "targets": {},
6
+ "targets": {
7
+ "build": {
8
+ "executor": "@jnxplus/nx-gradle:run-task",
9
+ "outputs": [
10
+ "{projectRoot}/build"
11
+ ],
12
+ "options": {
13
+ "task": "quarkusBuild"
14
+ },
15
+ "configurations": {
16
+ "production": {
17
+ "task": "quarkusBuild -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true -Dquarkus.profile=prod"
18
+ }
19
+ }
20
+ },
21
+ "build-image": {
22
+ "dependsOn": [
23
+ "build"
24
+ ],
25
+ "executor": "@jnxplus/nx-gradle:quarkus-build-image"
26
+ },
27
+ "serve": {
28
+ "executor": "@jnxplus/nx-gradle:run-task",
29
+ "options": {
30
+ "task": "quarkusDev",
31
+ "keepItRunning": true
32
+ }
33
+ },
34
+ "lint": {
35
+ "executor": "@jnxplus/nx-gradle:run-task",
36
+ "options": {
37
+ "task": "ktlintCheck"
38
+ }
39
+ },
40
+ "test": {
41
+ "executor": "@jnxplus/nx-gradle:run-task",
42
+ "options": {
43
+ "task": "test"
44
+ }
45
+ }
46
+ },
7
47
  "tags": []
8
48
  }
@@ -1,10 +1,11 @@
1
- package io.kong.extensionapicall
1
+ package io.kong.extension
2
2
 
3
- import com.fasterxml.jackson.databind.JsonNode
4
3
  import com.fasterxml.jackson.databind.ObjectMapper
5
4
  import io.kong.common.AppLogger
6
- import io.kong.sdkkotlin.Field
7
- import io.kong.sdkkotlin.KongFunction
5
+ import io.kong.sdk.KongFunction
6
+ import io.kong.sdk.KongFunctionContext
7
+ import io.kong.sdk.function.template.Field
8
+ import io.quarkus.runtime.annotations.RegisterForReflection
8
9
  import jakarta.inject.Singleton
9
10
 
10
11
  // This is the main entry point for developing an extension for Kong.
@@ -13,12 +14,14 @@ import jakarta.inject.Singleton
13
14
  // Define the structure of the input data that your extension will accept.
14
15
  // Be sure to include example values for each field. These examples help generate
15
16
  // sample objects in the UI, making it easier to work with the models.
17
+ @RegisterForReflection
16
18
  data class InputData(
17
19
  // REPLACE BELLOW WITH YOUR FIELDS
18
20
  @Field(description = "An integer number", examples = ["1"]) val a: Int,
19
21
  @Field(description = "An integer number", examples = ["2"]) val b: Int,
20
22
  )
21
23
 
24
+ @RegisterForReflection
22
25
  data class OutputData(
23
26
  // Define the structure of the output data that your extension will return.
24
27
  // REPLACE BELLOW WITH YOUR FIELDS
@@ -37,6 +40,8 @@ val objectMapper = ObjectMapper()
37
40
  class Main : KongFunction<InputData>(InputData::class.java) {
38
41
  private val logger = AppLogger(Main::class.simpleName)
39
42
 
40
- override suspend fun handle(data: InputData): JsonNode? =
41
- objectMapper.valueToTree(OutputData(sum_of = data.a + data.b))
43
+ override suspend fun handle(
44
+ data: InputData,
45
+ context: KongFunctionContext,
46
+ ): ByteArray? = objectMapper.writeValueAsBytes(OutputData(sum_of = data.a + data.b))
42
47
  }
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <title>kong-extension-python-call - 0.0.1-SNAPSHOT</title>
5
+ <title>kong-extension-code-call - 0.0.1-SNAPSHOT</title>
6
6
  <style>
7
7
  body {
8
8
  margin: 0;
@@ -290,8 +290,8 @@
290
290
  <div class="app-details">
291
291
  <h5>Application</h5>
292
292
  <ul>
293
- <li>GroupId: <code>io.kong.data</code></li>
294
- <li>ArtifactId: <code>kong-extension-python-call</code></li>
293
+ <li>GroupId: <code>io.kong</code></li>
294
+ <li>ArtifactId: <code>kong-extension-code-call</code></li>
295
295
  <li>Version: <code>0.0.1-SNAPSHOT</code></li>
296
296
  <li>Quarkus Version: <code>2.16.11.Final</code></li>
297
297
  </ul>
@@ -3,6 +3,7 @@ quarkus.log.level=INFO
3
3
  quarkus.log.console.format=%d{yyyy-MM-dd'T'HH:mm:ss,SSS} | %-5p | %s thread=%t module=%c{2.} %e%n
4
4
  quarkus.otel.enabled=true
5
5
  quarkus.otel.exporter.otlp.enabled=false
6
+ quarkus.http.test-port=8083
6
7
 
7
8
 
8
9
  # non-prod profiles
@@ -0,0 +1,32 @@
1
+ package io.kong.extensionapicall
2
+
3
+ import com.fasterxml.jackson.databind.ObjectMapper
4
+ import io.kong.extension.InputData
5
+ import io.kong.extension.Main
6
+ import io.kong.extension.OutputData
7
+ import io.quarkus.test.junit.QuarkusTest
8
+ import jakarta.inject.Inject
9
+ import kotlinx.coroutines.test.runTest
10
+ import org.junit.jupiter.api.Assertions.assertEquals
11
+ import org.junit.jupiter.api.Test
12
+
13
+ @QuarkusTest
14
+ class Test {
15
+ @Inject
16
+ lateinit var extension: Main
17
+
18
+ @Inject
19
+ lateinit var objectMapper: ObjectMapper
20
+
21
+ @Test
22
+ fun `when provided valid input then returns expected result`() =
23
+ runTest {
24
+ val input = InputData(a = 1, b = 2)
25
+
26
+ val bytes = extension.handle(input)
27
+ val output = objectMapper.readValue(bytes, OutputData::class.java)
28
+ val sumOf = output.sum_of
29
+
30
+ assertEquals(3, sumOf)
31
+ }
32
+ }
@@ -1,6 +0,0 @@
1
- {
2
- "id": "<%=id%>",
3
- "name": "<%=name%>",
4
- "sdk": "<%=platform%>",
5
- "category": "unknown"
6
- }