@nlxai/cli 1.2.2-alpha.2 → 1.2.2-alpha.4

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.
@@ -9,15 +9,33 @@ import boxen from "boxen";
9
9
  export const testCommand = new Command("test")
10
10
  .description("Run conversation tests for a given application ID")
11
11
  .argument("<applicationId>", "Application ID to fetch tests for")
12
+ .optionsGroup("Test selection:")
13
+ .option("--only-execute-at-build", "Only execute tests marked to run at build time")
14
+ .optionsGroup("Environment configuration:")
12
15
  .option("--env <environment>", "Specify the environment", "production")
13
16
  .option("--language <language>", "Specify the language code", "en-US")
14
17
  .option("--channel <channel>", "Specify the channel type", "API")
15
18
  .option("--applications-url-base-override <url>", "Override the base URL for applications")
16
- .option("--enterprise-region <region>", "Specify the enterprise region")
19
+ .option("--enterprise-region <region>", "Specify the enterprise region. Required for enterprise users.")
17
20
  .action(async (applicationId, opts) => {
18
21
  try {
19
- const { tests } = (await fetchManagementApi(`bots/${applicationId}/conversationTests`, "GET"));
20
- consola.log("Fetched %i tests. Running...", tests.length);
22
+ let { tests } = (await fetchManagementApi(`bots/${applicationId}/conversationTests`, "GET"));
23
+ if (opts.onlyExecuteAtBuild) {
24
+ let total = tests.length;
25
+ tests = tests.filter((test) => test.runAtBuild);
26
+ if (tests.length === 0) {
27
+ consola.error("No tests found.");
28
+ process.exit(1);
29
+ }
30
+ consola.log("Fetched %i tests, skipping %i not marked for build. Running %i tests...", total, total - tests.length, tests.length);
31
+ }
32
+ else {
33
+ if (tests.length === 0) {
34
+ consola.error("No tests found.");
35
+ process.exit(1);
36
+ }
37
+ consola.log("Fetched %i tests. Running...", tests.length);
38
+ }
21
39
  const baseUrl = getBaseUrl(opts.enterpriseRegion == null, opts.applicationsUrlBaseOverride ?? "", opts.enterpriseRegion ?? "US");
22
40
  const applicationUrl = `${baseUrl}/c/${applicationId}/sandbox`;
23
41
  consola.debug("Application URL:", applicationUrl);
package/lib/index.js CHANGED
@@ -4,7 +4,16 @@ import { modalitiesCommand } from "./commands/modalities/index.js";
4
4
  import { dataRequestsCommand } from "./commands/data-requests/index.js";
5
5
  import { httpCommand } from "./commands/http.js";
6
6
  import { testCommand } from "./commands/test.js";
7
+ import { consola } from "consola";
7
8
  program.description("Intereact with NLX from the command line");
9
+ program
10
+ .option("-v, --verbose", "Enable verbose logging")
11
+ .hook("preAction", (thisCommand) => {
12
+ if (thisCommand.opts().verbose) {
13
+ consola.level = 4; // Debug level
14
+ }
15
+ });
16
+ program.configureHelp({ showGlobalOptions: true });
8
17
  program.addCommand(authCommand);
9
18
  program.addCommand(modalitiesCommand);
10
19
  program.addCommand(dataRequestsCommand);
@@ -3,6 +3,7 @@ import { consola } from "consola";
3
3
  const API_BASE_URL = process.env.NLX_API_BASE_URL || "https://api.dev.studio.nlx.ai/v1";
4
4
  export const fetchManagementApi = async (path, method = "GET", body) => {
5
5
  const accessToken = await ensureToken();
6
+ consola.debug(`Fetch ${method} /${path} ${body ? JSON.stringify(body) : ""}`);
6
7
  const res = await fetch(`${API_BASE_URL}/${path}`, {
7
8
  headers: {
8
9
  Authorization: `Bearer ${accessToken}`,
@@ -15,5 +16,7 @@ export const fetchManagementApi = async (path, method = "GET", body) => {
15
16
  consola.error("Failed to fetch:", res.status, await res.text());
16
17
  process.exit(1);
17
18
  }
18
- return await res.json();
19
+ const result = (await res.json());
20
+ consola.debug("Response:", JSON.stringify(result));
21
+ return result;
19
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlxai/cli",
3
- "version": "1.2.2-alpha.2",
3
+ "version": "1.2.2-alpha.4",
4
4
  "description": "Tools for integrating with NLX apps",
5
5
  "keywords": [
6
6
  "NLX",
@@ -13,7 +13,7 @@
13
13
  "license": "MIT",
14
14
  "main": "lib/index.ts",
15
15
  "bin": {
16
- "npx": "bin/npx"
16
+ "nlx": "bin/nlx"
17
17
  },
18
18
  "directories": {
19
19
  "lib": "lib"
@@ -58,5 +58,5 @@
58
58
  "@vitest/ui": "^3.2.4",
59
59
  "vitest": "^3.2.4"
60
60
  },
61
- "gitHead": "326f4ca5d7362bf8f3c01acfd9f01844fdf53904"
61
+ "gitHead": "a9a40dd92574ce30e9860b02b61e5fd6328284dc"
62
62
  }