Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This way even entityIds like environmentIds or testCaseIds will be autocompleted

# octomind

Octomind cli tool. Version: 4.5.0. Additional documentation see https://octomind.dev/docs/api-reference/
Octomind cli tool. Version: 4.5.1. Additional documentation see https://octomind.dev/docs/api-reference/

**Usage:** `octomind [options] [command]`

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@octomind/octomind",
"version": "4.5.0",
"version": "4.5.1",
"description": "a command line client for octomind apis",
"main": "./dist/index.js",
"packageManager": "pnpm@10.28.1+sha512.7d7dbbca9e99447b7c3bf7a73286afaaf6be99251eb9498baefa7d406892f67b879adb3a1d7e687fc4ccc1a388c7175fbaae567a26ab44d1067b54fcb0d6a316",
Expand All @@ -26,9 +26,9 @@
"lint": "pnpm apigen && npx genversion -des src/version.ts && biome check",
"tsc": "tsc --project tsconfig.build.json",
"typecheck": "tsc --project tsconfig.build.json --noEmit",
"dev:local": "pnpm apigen && OCTOMIND_CONFIG_FILE=octomind.dev.local.json OCTOMIND_API_URL=http://localhost:3000/api tsx src/index.ts",
"dev:staging": "pnpm apigen && OCTOMIND_CONFIG_FILE=octomind.dev.staging.json OCTOMIND_API_URL=https://preview.octomind.dev/api tsx src/index.ts",
"dev:prod": "pnpm apigen && OCTOMIND_CONFIG_FILE=octomind.dev.prod.json OCTOMIND_API_URL=https://app.octomind.dev/api tsx src/index.ts",
"dev:local": "pnpm apigen && OCTOMIND_CONFIG_FILE=octomind.dev.local.json OCTOMIND_API_URL=http://localhost:3000 tsx src/index.ts",
"dev:staging": "pnpm apigen && OCTOMIND_CONFIG_FILE=octomind.dev.staging.json OCTOMIND_API_URL=https://preview.octomind.dev tsx src/index.ts",
"dev:prod": "pnpm apigen && OCTOMIND_CONFIG_FILE=octomind.dev.prod.json OCTOMIND_API_URL=https://app.octomind.dev tsx src/index.ts",
"apigen": "openapi-typescript https://preview.octomind.dev/openapi.yaml --output src/api.ts && orval",
"build": "pnpm apigen && npx genversion -des src/version.ts && pnpm gendoc && tsc --project tsconfig.build.json",
"octomind": "pnpm apigen && tsx src/index.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/tools/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { logger } from "../logger";
import { version } from "../version";

export const BASE_URL =
process.env.OCTOMIND_API_URL || "https://app.octomind.dev/api";
process.env.OCTOMIND_API_URL || "https://app.octomind.dev";
type ErrorResponse =
| components["schemas"]["ZodResponse"]
| string
| { status: "error"; error: string }
| { status: "has dependencies"; dependencyIds: string[] }
| undefined;

const client: Client<paths> = createClient<paths>({ baseUrl: BASE_URL });
const client: Client<paths> = createClient<paths>({
baseUrl: `${BASE_URL}/api`,
});

export const createClientFromUrlAndApiKey = ({
baseUrl,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const getEnvironments = async (
if (options.bearerToken) {
logger.debug("Using bearer token for environments");
const res = await fetch(
`${BASE_URL}/bearer/v1/test-targets/${options.testTargetId}/environments`,
`${BASE_URL}/api/bearer/v1/test-targets/${options.testTargetId}/environments`,
{
headers: {
Authorization: `Bearer ${options.bearerToken}`,
Expand Down
4 changes: 2 additions & 2 deletions src/tools/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getPlaywrightConfig = async (options: {
const searchParams = new URLSearchParams(filteredParams);

const response = await fetch(
`${BASE_URL}/bearer/v1/test-targets/${options.testTargetId}/config?${searchParams.toString()}`,
`${BASE_URL}/api/bearer/v1/test-targets/${options.testTargetId}/config?${searchParams.toString()}`,
{
headers: {
Authorization: `Bearer ${options.bearerToken}`,
Expand Down Expand Up @@ -99,7 +99,7 @@ export const getPlaywrightCode = async (options: {
const searchParams = new URLSearchParams(filteredParams);

const response = await fetch(
`${BASE_URL}/bearer/v1/test-targets/${options.testTargetId}/test-cases/${options.testCaseId}/code?${searchParams.toString()}`,
`${BASE_URL}/api/bearer/v1/test-targets/${options.testTargetId}/test-cases/${options.testCaseId}/code?${searchParams.toString()}`,
{
headers: {
Authorization: `Bearer ${options.bearerToken}`,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const getTestCases = async (
): Promise<TestCasesResponse> => {
if (options.bearerToken) {
const url = new URL(
`${BASE_URL}/bearer/v1/test-targets/${options.testTargetId}/test-cases`,
`${BASE_URL}/api/bearer/v1/test-targets/${options.testTargetId}/test-cases`,
);
if (options.status || options.runStatus) {
url.searchParams.set(
Expand Down
3 changes: 1 addition & 2 deletions src/tools/yamlMutations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ const openBrowser = async ({
versionId: string;
testTargetId: string;
}): Promise<void> => {
const parsedBaseUrl = URL.parse(BASE_URL);
const localEditingUrl = new URL(
`${parsedBaseUrl?.protocol}//${parsedBaseUrl?.host}/testtargets/${testTargetId}/testcases/${versionId}/localEdit`,
`${BASE_URL}/testtargets/${testTargetId}/testcases/${versionId}/localEdit`,
);

await open(localEditingUrl.href);
Expand Down
3 changes: 1 addition & 2 deletions src/tools/yamlMutations/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ export const edit = async (options: EditOptions): Promise<void> => {
}
const { versionId, testResultId } = syncData;

const parsedBaseUrl = URL.parse(BASE_URL);
const localEditingUrl = new URL(
`${parsedBaseUrl?.protocol}//${parsedBaseUrl?.host}/testtargets/${options.testTargetId}/testcases/${versionId}/localEdit`,
`${BASE_URL}/testtargets/${options.testTargetId}/testcases/${versionId}/localEdit`,
);
if (testResultId) {
localEditingUrl.searchParams.set("testResultId", testResultId);
Expand Down
13 changes: 6 additions & 7 deletions src/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,23 @@ export const getUrl = async (
| { testCaseId: string; entityType: "discovery" }
| { batchGenerationId: string; entityType: "batch-generation" },
): Promise<string> => {
const relevantBaseUrl = new URL(BASE_URL).origin;
const config = await loadConfig();
const configuredTestTargetId = config.testTargetId;
if (!configuredTestTargetId && input.entityType !== "test-target") {
return "";
}
switch (input.entityType) {
case "test-case":
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testcases?testCaseId=${input.testCaseId}`;
return `${BASE_URL}/testtargets/${configuredTestTargetId}/testcases?testCaseId=${input.testCaseId}`;
case "test-target":
return `${relevantBaseUrl}/testtargets/${input.testTargetId}`;
return `${BASE_URL}/testtargets/${input.testTargetId}`;
case "test-report":
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testreports/${input.testReportId}`;
return `${BASE_URL}/testtargets/${configuredTestTargetId}/testreports/${input.testReportId}`;
case "test-result":
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testreports/${input.testReportId}/testresults/${input.testResultId}`;
return `${BASE_URL}/testtargets/${configuredTestTargetId}/testreports/${input.testReportId}/testresults/${input.testResultId}`;
case "discovery":
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testcases/${input.testCaseId}`;
return `${BASE_URL}/testtargets/${configuredTestTargetId}/testcases/${input.testCaseId}`;
case "batch-generation":
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/batch-generations/${input.batchGenerationId}`;
return `${BASE_URL}/testtargets/${configuredTestTargetId}/batch-generations/${input.batchGenerationId}`;
}
};
2 changes: 1 addition & 1 deletion tests/tools/environments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("environments", () => {
const result = await getEnvironments(options);

expect(fetch).toHaveBeenCalledWith(
`${BASE_URL}/bearer/v1/test-targets/${testTargetId}/environments`,
`${BASE_URL}/api/bearer/v1/test-targets/${testTargetId}/environments`,
{
headers: {
Authorization: `Bearer ${bearerToken}`,
Expand Down
4 changes: 2 additions & 2 deletions tests/tools/playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("playwright", () => {
});

expect(fetch).toHaveBeenCalledWith(
`${BASE_URL}/bearer/v1/test-targets/${testTargetId}/config?${expectedParams.toString()}`,
`${BASE_URL}/api/bearer/v1/test-targets/${testTargetId}/config?${expectedParams.toString()}`,
{
headers: {
Authorization: `Bearer ${bearerToken}`,
Expand Down Expand Up @@ -179,7 +179,7 @@ describe("playwright", () => {
});

expect(fetch).toHaveBeenCalledWith(
`${BASE_URL}/bearer/v1/test-targets/${testTargetId}/test-cases/${testCaseId}/code?${expectedParams.toString()}`,
`${BASE_URL}/api/bearer/v1/test-targets/${testTargetId}/test-cases/${testCaseId}/code?${expectedParams.toString()}`,
{
headers: {
Authorization: `Bearer ${bearerToken}`,
Expand Down