@devkong/cli 0.0.16 → 0.0.17-0

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.
@@ -23,5 +23,4 @@ cd %EXTENSION_DIR%
23
23
 
24
24
  call .venv\Scripts\activate.bat
25
25
 
26
- %PIP_CMD% install -r requirements.txt
27
- %PIP_CMD% install -r requirements-dev.txt
26
+ %PIP_CMD% install -r requirements.txt -r requirements-dev.txt
package/index.js CHANGED
@@ -66902,9 +66902,12 @@ function getProfile(profileName = "default") {
66902
66902
  const profile = availableProfiles[profileName] || {
66903
66903
  kongBaseUrl: urlText("")
66904
66904
  };
66905
- profile.kongBaseUrl = urlText(optionalEnv("KONG_BASE_URL")) || profile.kongBaseUrl;
66905
+ profile.kongBaseUrl = profile.kongBaseUrl || urlText(optionalEnv("KONG_BASE_URL"));
66906
66906
  return profile;
66907
66907
  }
66908
+ function printProfile(profile) {
66909
+ console.info(`Current profile=${profile}, baseUrl=${getProfile(profile).kongBaseUrl}`);
66910
+ }
66908
66911
 
66909
66912
  // packages/kong-cli/src/commands/configureCommand.ts
66910
66913
  var ConfigureCommand = class {
@@ -69696,7 +69699,6 @@ var InstallCommand = class {
69696
69699
  title: "Installing dependencies with pip",
69697
69700
  task: async (_2, task) => {
69698
69701
  const scriptPath = this.scriptPath();
69699
- task.output = `${scriptPath} ${workspaceDirectory}`;
69700
69702
  await spawnCommand(
69701
69703
  `${scriptPath} ${workspaceDirectory}`,
69702
69704
  new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */),
@@ -69755,10 +69757,58 @@ var ManagementClient = class {
69755
69757
  const url2 = joinUrlAndPath(this.baseUrl, "v1/extensions", extensionId, "/snapshots/versions");
69756
69758
  return (await axios_default.get(url2, API_HEADERS)).data;
69757
69759
  }
69760
+ async getExtensionSnapshotAliases(extensionId) {
69761
+ const url2 = joinUrlAndPath(this.baseUrl, "v1/extensions", extensionId, "/aliases");
69762
+ return (await axios_default.get(url2, API_HEADERS)).data;
69763
+ }
69758
69764
  };
69759
69765
 
69760
- // packages/kong-cli/src/commands/listExtensionSnapshotCommand.ts
69761
- var ListExtensionSnapshotCommand = class {
69766
+ // packages/kong-cli/src/commands/listAliasesCommand.ts
69767
+ var ListAliasesCommand = class {
69768
+ constructor(profile, verbose) {
69769
+ this.profile = profile;
69770
+ this.verbose = verbose;
69771
+ this.managementClient = new ManagementClient(this.profile.kongBaseUrl);
69772
+ }
69773
+ async execute() {
69774
+ await new Listr(
69775
+ [
69776
+ {
69777
+ title: "List extension aliases",
69778
+ task: async (ctx, task) => {
69779
+ const kongJson = getKongJson();
69780
+ const aliases = await this.managementClient.getExtensionSnapshotAliases(kongJson.id);
69781
+ if (aliases.length === 0) {
69782
+ task.output = "No aliases available";
69783
+ } else {
69784
+ const result = [];
69785
+ for (const alias of aliases) {
69786
+ for (const item of alias.use) {
69787
+ result.push(`${alias.name}, ${item.snapshot.version}, ${item.balance}%`);
69788
+ }
69789
+ }
69790
+ task.output = result.join("\n");
69791
+ }
69792
+ },
69793
+ rendererOptions: {
69794
+ persistentOutput: true
69795
+ }
69796
+ }
69797
+ ],
69798
+ {
69799
+ renderer: "default",
69800
+ rendererOptions: {
69801
+ logger: new ListrLogger({
69802
+ processOutput: new ProcessOutput(process.stderr, process.stderr)
69803
+ })
69804
+ }
69805
+ }
69806
+ ).run();
69807
+ }
69808
+ };
69809
+
69810
+ // packages/kong-cli/src/commands/listVersionsCommand.ts
69811
+ var ListVersionsCommand = class {
69762
69812
  constructor(profile, verbose) {
69763
69813
  this.verbose = verbose;
69764
69814
  this.managementClient = new ManagementClient(profile.kongBaseUrl);
@@ -69952,7 +70002,7 @@ var PublicClient = class {
69952
70002
  }
69953
70003
  };
69954
70004
 
69955
- // packages/kong-cli/src/commands/setExtensionAliasCommand.ts
70005
+ // packages/kong-cli/src/commands/setAliasCommand.ts
69956
70006
  function validateName(value) {
69957
70007
  if (isEmpty(value)) {
69958
70008
  throw new AppError("The alias name should not be empty.");
@@ -69963,7 +70013,7 @@ function validateName(value) {
69963
70013
  );
69964
70014
  }
69965
70015
  }
69966
- var SetExtensionAliasCommand = class {
70016
+ var SetAliasCommand = class {
69967
70017
  constructor(profile) {
69968
70018
  this.publicClient = new PublicClient(profile.kongBaseUrl);
69969
70019
  this.managementClient = new ManagementClient(profile.kongBaseUrl);
@@ -70068,6 +70118,7 @@ async function main() {
70068
70118
  "Build and automatically tag the current code with an incremented version, ready for selection in extension aliases"
70069
70119
  ).addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).addOption(new Option("--verbose", "Show full logs during command execution")).addOption(new Option("--notes [text]", "Optional version notes").default("")).action(async (options) => {
70070
70120
  try {
70121
+ printProfile(options.profile);
70071
70122
  const kongJson = getKongJson();
70072
70123
  await new PublishVersionCommand(getProfile(options.profile), options.verbose).execute(
70073
70124
  kongJson.name,
@@ -70079,24 +70130,28 @@ async function main() {
70079
70130
  });
70080
70131
  const listVersionsCommand = new Command("list-versions").description("List available versions").addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).addOption(new Option("--verbose", "Show full logs during command execution")).action(async (options) => {
70081
70132
  try {
70082
- await new ListExtensionSnapshotCommand(
70083
- getProfile(options.profile),
70084
- options.verbose
70085
- ).execute();
70133
+ printProfile(options.profile);
70134
+ await new ListVersionsCommand(getProfile(options.profile), options.verbose).execute();
70086
70135
  } catch (ex) {
70087
70136
  printError("list-versions command failed", ex);
70088
70137
  }
70089
70138
  });
70090
70139
  const setAliasCommand = new Command("set-alias").description("Assign alias to an extension").argument("alias-name", "Alias name to assign").argument("extension-version", "Extension version to use. Should be one of existing versions").addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).action(async (aliasName, extensionVersion, options) => {
70091
70140
  try {
70092
- await new SetExtensionAliasCommand(getProfile(options.profile)).execute(
70093
- aliasName,
70094
- extensionVersion
70095
- );
70141
+ printProfile(options.profile);
70142
+ await new SetAliasCommand(getProfile(options.profile)).execute(aliasName, extensionVersion);
70096
70143
  } catch (ex) {
70097
70144
  printError("set-alias command failed", ex);
70098
70145
  }
70099
70146
  });
70147
+ const listAliasesCommand = new Command("list-aliases").description("List available extension aliases").addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).action(async (options) => {
70148
+ try {
70149
+ printProfile(options.profile);
70150
+ await new ListAliasesCommand(getProfile(options.profile), options.verbose).execute();
70151
+ } catch (ex) {
70152
+ printError("list-aliases command failed", ex);
70153
+ }
70154
+ });
70100
70155
  const cli = new Command().version(getPresetVersion()).description("CLI to support creating and publishing Kong extensions");
70101
70156
  cli.addCommand(generateCommand);
70102
70157
  cli.addCommand(configureCommand);
@@ -70104,6 +70159,7 @@ async function main() {
70104
70159
  cli.addCommand(publishVersionCommand);
70105
70160
  cli.addCommand(listVersionsCommand);
70106
70161
  cli.addCommand(setAliasCommand);
70162
+ cli.addCommand(listAliasesCommand);
70107
70163
  cli.parse(process.argv);
70108
70164
  }
70109
70165
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.17-0",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -0,0 +1,8 @@
1
+ import { Profile } from "../common/profile";
2
+ export declare class ListAliasesCommand {
3
+ private profile;
4
+ private verbose;
5
+ private readonly managementClient;
6
+ constructor(profile: Profile, verbose: boolean);
7
+ execute(): Promise<void>;
8
+ }
@@ -1,5 +1,5 @@
1
1
  import { Profile } from "../common/profile";
2
- export declare class ListExtensionSnapshotCommand {
2
+ export declare class ListVersionsCommand {
3
3
  private verbose;
4
4
  private readonly managementClient;
5
5
  constructor(profile: Profile, verbose: boolean);
@@ -1,5 +1,5 @@
1
1
  import { Profile } from "../common/profile";
2
- export declare class SetExtensionAliasCommand {
2
+ export declare class SetAliasCommand {
3
3
  private publicClient;
4
4
  private managementClient;
5
5
  constructor(profile: Profile);
@@ -7,3 +7,4 @@ export type ConfigProfiles = Record<ProfileName, Profile>;
7
7
  export declare function loadProfiles(): ConfigProfiles;
8
8
  export declare function saveProfiles(profiles: ConfigProfiles): void;
9
9
  export declare function getProfile(profileName?: string): Profile;
10
+ export declare function printProfile(profile: string): void;
@@ -1,4 +1,4 @@
1
- import { AppExtension, AppExtensionSnapshot, AppExtensionSnapshotDetails } from "@kong/contract";
1
+ import { AppExtension, AppExtensionAlias, AppExtensionSnapshot, AppExtensionSnapshotDetails } from "@kong/contract";
2
2
  import { Optional, UrlText } from "@kong/ts";
3
3
  export declare class ManagementClient {
4
4
  private readonly baseUrl;
@@ -6,4 +6,5 @@ export declare class ManagementClient {
6
6
  createExtensionSnapshot(extensionId: AppExtension["id"], extensionName: AppExtension["name"], snapshot: Omit<AppExtensionSnapshotDetails, "id">): Promise<void>;
7
7
  getExtensionSnapshot(extensionName: AppExtension["name"], extensionSnapshotVersion: AppExtensionSnapshot["version"]): Promise<Optional<AppExtensionSnapshotDetails>>;
8
8
  getExtensionSnapshotVersions(extensionId: AppExtension["id"]): Promise<AppExtensionSnapshot[]>;
9
+ getExtensionSnapshotAliases(extensionId: AppExtension["id"]): Promise<AppExtensionAlias[]>;
9
10
  }
@@ -111,6 +111,7 @@ export interface KongSpecStateCompensate extends KongSpecStateBase, KongSpecSupp
111
111
  }
112
112
  export interface KongSpecCondition extends KongSpecSupportsTransition, KongSpecSupportsTransition {
113
113
  id: Distinct<string, "KongSpecConditionId">;
114
+ description: string;
114
115
  match: JqFilter;
115
116
  }
116
117
  export interface KongSpecStateSwitch extends KongSpecStateBase, KongSpecCanBeUsedForCompensation, KongSpecSupportsTransition {
@@ -18,5 +18,6 @@ export type { AppProject } from "./lib/appProject";
18
18
  export type { AppTestCase } from "./lib/appTestCase";
19
19
  export type { AppTestCaseDetails } from "./lib/appTestCaseDetails";
20
20
  export type { AppTestCaseMatchFeature } from "./lib/appTestCaseMatchFeature";
21
+ export type { AppTestResult } from "./lib/appTestResult";
21
22
  export type { AppWorkspace } from "./lib/appWorkspace";
22
23
  export type { SdkExtensionAlias } from "./lib/sdkExtensionAlias";
@@ -1,8 +1,10 @@
1
- import { Entity, User, UtcDateTime } from "@kong/ts";
1
+ import { Entity, JsonObject, User, UtcDateTime } from "@kong/ts";
2
2
  export interface AppTestCase extends Entity {
3
3
  id: number;
4
4
  title: string;
5
5
  tags: string[];
6
+ inputPayload: JsonObject;
7
+ expectedResult: JsonObject;
6
8
  created: UtcDateTime;
7
9
  updated: UtcDateTime;
8
10
  createdBy: User["name"];
@@ -0,0 +1,12 @@
1
+ import { JsonObject, User, UtcDateTime } from "@kong/ts";
2
+ import { AppTestCase } from "./appTestCase";
3
+ export interface AppTestResult {
4
+ id?: number;
5
+ testCaseId: AppTestCase["id"];
6
+ testRunId: number;
7
+ actualResult: JsonObject;
8
+ created: UtcDateTime;
9
+ updated: UtcDateTime;
10
+ createdBy: User["name"];
11
+ updatedBy: User["name"];
12
+ }