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 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

services:
mock-api:
image: ghcr.io/quantcdn/quant-mock-api:4.0.0
image: ghcr.io/quantcdn/quant-mock-api:4.3.0
ports:
- 4010:4010
options: >-
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

services:
quant-mock-api:
image: ghcr.io/quantcdn/quant-mock-api:4.0.0
image: ghcr.io/quantcdn/quant-mock-api:4.3.0
container_name: quant-mock-api-test
ports:
- "4010:4010"
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"url": "https://github.com/quantcdn/quant-cloud-cli/issues"
},
"dependencies": {
"@quantcdn/quant-client": "^4.0.0",
"@quantcdn/quant-client": "^4.3.0",
"axios": "^1.6.0",
"chalk": "^5.3.0",
"commander": "^11.1.0",
Expand Down
44 changes: 9 additions & 35 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,42 +275,16 @@ export class ApiClient {
}

try {
// NOTE: Using direct fetch() call as workaround
// The crawlersRun method is available in quant-ts-client commit fba13989a1f84e87fc16b431f77bb4d83b5970fa
// but that commit has build issues preventing npm install.
// Once the SDK is properly published with the crawlersRun method, replace this with:
// const response = await this.crawlersApi.crawlersRun(organizationId, projectName, crawlerId, payload);
const payload = urls ? { urls } : {};
const response = await fetch(
`${this.baseUrl}/api/v2/organizations/${organizationId}/projects/${projectName}/crawlers/${crawlerId}/run`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${this.token}`,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
}
);

if (!response.ok) {
if (response.status === 404) {
throw new Error(`Crawler '${crawlerId}' not found in project '${projectName}'.`);
} else if (response.status === 403) {
throw new Error(`Access denied to run crawler '${crawlerId}'.`);
} else if (response.status === 401) {
throw new Error('Authentication expired. Please run `qc login` to re-authenticate.');
} else {
const errorText = await response.text();
throw new Error(`Failed to run crawler: ${response.status} ${errorText}`);
}
}

return await response.json();
const payload = urls && urls.length > 0 ? { urls } : {};
const response = await this.crawlersApi.crawlersRun(organizationId, projectName, crawlerId, payload);
return response.data;
} catch (error: any) {
if (error.message?.includes('Crawler') || error.message?.includes('Authentication')) {
throw error; // Re-throw our friendly errors
if (error.statusCode === 404 || error.response?.status === 404) {
throw new Error(`Crawler '${crawlerId}' not found in project '${projectName}'.`);
} else if (error.statusCode === 403 || error.response?.status === 403) {
throw new Error(`Access denied to run crawler '${crawlerId}'.`);
} else if (error.statusCode === 401 || error.response?.status === 401) {
throw new Error('Authentication expired. Please run `qc login` to re-authenticate.');
} else {
throw new Error(`Failed to run crawler: ${error.message || 'Network error'}`);
}
Expand Down
Loading