@codeguide/core 0.0.22 → 0.0.24

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.
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.demonstrateProjectFiltering = demonstrateProjectFiltering;
4
+ const index_1 = require("../index");
5
+ // Example usage of the new has_repository filtering functionality
6
+ async function demonstrateProjectFiltering() {
7
+ const codeGuide = new index_1.CodeGuide({
8
+ baseUrl: 'https://api.example.com',
9
+ apiKey: 'your-api-key'
10
+ });
11
+ console.log('=== Project Filtering Examples ===\n');
12
+ // Example 1: Get all projects with repositories
13
+ console.log('1. Getting all projects with repositories:');
14
+ try {
15
+ const projectsWithRepos = await codeGuide.projects.getAllProjects({
16
+ has_repository: true
17
+ });
18
+ console.log(`Found ${projectsWithRepos.length} projects with repositories`);
19
+ projectsWithRepos.forEach((project) => {
20
+ console.log(`- ${project.title} (${project.project_repositories.length} repositories)`);
21
+ });
22
+ }
23
+ catch (error) {
24
+ console.log('Error:', error.message);
25
+ }
26
+ console.log('\n');
27
+ // Example 2: Get all projects without repositories
28
+ console.log('2. Getting all projects without repositories:');
29
+ try {
30
+ const projectsWithoutRepos = await codeGuide.projects.getAllProjects({
31
+ has_repository: false
32
+ });
33
+ console.log(`Found ${projectsWithoutRepos.length} projects without repositories`);
34
+ projectsWithoutRepos.forEach((project) => {
35
+ console.log(`- ${project.title}`);
36
+ });
37
+ }
38
+ catch (error) {
39
+ console.log('Error:', error.message);
40
+ }
41
+ console.log('\n');
42
+ // Example 3: Paginated projects with repository filter
43
+ console.log('3. Getting paginated projects with repositories:');
44
+ try {
45
+ const paginatedRequest = {
46
+ page: 1,
47
+ page_size: 10,
48
+ has_repository: true,
49
+ status: 'active'
50
+ };
51
+ const paginatedResponse = await codeGuide.projects.getPaginatedProjects(paginatedRequest);
52
+ console.log(`Page ${paginatedResponse.pagination.page} of ${paginatedResponse.pagination.total_pages}`);
53
+ console.log(`Total projects with repositories: ${paginatedResponse.pagination.total}`);
54
+ console.log(`Showing ${paginatedResponse.data.length} projects:`);
55
+ paginatedResponse.data.forEach((project) => {
56
+ console.log(`- ${project.title}`);
57
+ project.project_repositories.forEach((repo) => {
58
+ console.log(` Repository: ${repo.repo_url} (${repo.branch})`);
59
+ });
60
+ });
61
+ }
62
+ catch (error) {
63
+ console.log('Error:', error.message);
64
+ }
65
+ console.log('\n');
66
+ // Example 4: Combining filters
67
+ console.log('4. Combining multiple filters:');
68
+ try {
69
+ const combinedFilters = {
70
+ page: 1,
71
+ page_size: 5,
72
+ has_repository: false,
73
+ search_query: 'web',
74
+ sort_by_date: 'desc'
75
+ };
76
+ const filteredProjects = await codeGuide.projects.getPaginatedProjects(combinedFilters);
77
+ console.log(`Found ${filteredProjects.pagination.total} projects matching filters:`);
78
+ filteredProjects.data.forEach((project) => {
79
+ console.log(`- ${project.title} (Updated: ${project.updated_at})`);
80
+ });
81
+ }
82
+ catch (error) {
83
+ console.log('Error:', error.message);
84
+ }
85
+ }
86
+ // Run example if this file is executed directly
87
+ if (require.main === module) {
88
+ demonstrateProjectFiltering().catch(console.error);
89
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { CodeGuide } from './codeguide';
2
2
  export * from './services';
3
3
  export * from './types';
4
- export type { ConnectRepositoryRequest, ConnectRepositoryResponse } from './services/projects/project-types';
5
- export type { CreateCodespaceTaskRequestV2 as CreateCodespaceTaskRequest, CreateCodespaceTaskResponseV2 as CreateCodespaceTaskResponse, CreateBackgroundCodespaceTaskRequest, CreateBackgroundCodespaceTaskResponse, ModelApiKey, GetCodespaceTaskResponse, CodespaceTaskData, TechnicalDocument, GetProjectTasksByCodespaceResponse } from './services/codespace/codespace-types';
4
+ export type { ConnectRepositoryRequest, ConnectRepositoryResponse, ProjectRepository, GetProjectsRequest, PaginatedProjectsRequest, PaginatedProjectsResponse } from './services/projects/project-types';
5
+ export type { CreateCodespaceTaskRequestV2 as CreateCodespaceTaskRequest, CreateCodespaceTaskResponseV2 as CreateCodespaceTaskResponse, CreateBackgroundCodespaceTaskRequest, CreateBackgroundCodespaceTaskResponse, ModelApiKey, Attachment, GetCodespaceTaskResponse, CodespaceTaskData, TechnicalDocument, GetProjectTasksByCodespaceResponse } from './services/codespace/codespace-types';
6
6
  export type { StoreExternalTokenRequest, StoreExternalTokenResponse, ListTokensQuery, ListTokensResponse, ValidateTokenRequest, ValidateTokenResponse, FindBestMatchRequest, FindBestMatchResponse, Platform, TokenType } from './services/external-tokens/external-tokens-types';
@@ -1,11 +1,15 @@
1
1
  import { BaseService } from '../base/base-service';
2
- import { GenerateTaskTitleRequest, GenerateTaskTitleResponse, CreateCodespaceTaskRequest, CreateCodespaceTaskResponse, CreateCodespaceTaskRequestV2, CreateCodespaceTaskResponseV2, CreateBackgroundCodespaceTaskRequest, CreateBackgroundCodespaceTaskResponse, GetCodespaceTaskResponse, GetProjectTasksByCodespaceResponse } from './codespace-types';
2
+ import { GenerateTaskTitleRequest, GenerateTaskTitleResponse, CreateCodespaceTaskRequest, CreateCodespaceTaskResponse, CreateCodespaceTaskRequestV2, CreateCodespaceTaskResponseV2, CreateBackgroundCodespaceTaskRequest, CreateBackgroundCodespaceTaskResponse, GetCodespaceTaskResponse, GetProjectTasksByCodespaceResponse, GetCodespaceTasksByProjectRequest, GetCodespaceTasksByProjectResponse, CodespaceTaskDetailedResponse, CodespaceQuestionnaireRequest, CodespaceQuestionnaireResponse } from './codespace-types';
3
3
  export declare class CodespaceService extends BaseService {
4
4
  generateTaskTitle(request: GenerateTaskTitleRequest): Promise<GenerateTaskTitleResponse>;
5
+ generateQuestionnaire(request: CodespaceQuestionnaireRequest): Promise<CodespaceQuestionnaireResponse>;
5
6
  createCodespaceTask(request: CreateCodespaceTaskRequest): Promise<CreateCodespaceTaskResponse>;
6
7
  createCodespaceTaskV2(request: CreateCodespaceTaskRequestV2): Promise<CreateCodespaceTaskResponseV2>;
7
8
  createBackgroundCodespaceTask(request: CreateBackgroundCodespaceTaskRequest): Promise<CreateBackgroundCodespaceTaskResponse>;
8
9
  getCodespaceTask(codespaceTaskId: string): Promise<GetCodespaceTaskResponse>;
9
10
  getProjectTasksByCodespace(codespaceTaskId: string): Promise<GetProjectTasksByCodespaceResponse>;
11
+ getCodespaceTasksByProject(params: GetCodespaceTasksByProjectRequest): Promise<GetCodespaceTasksByProjectResponse>;
12
+ getCodespaceTaskDetailed(codespaceTaskId: string): Promise<CodespaceTaskDetailedResponse>;
10
13
  private validateCodespaceTaskRequest;
14
+ private validateQuestionnaireRequest;
11
15
  }
@@ -6,6 +6,10 @@ class CodespaceService extends base_service_1.BaseService {
6
6
  async generateTaskTitle(request) {
7
7
  return this.post('/codespace/generate-task-title', request);
8
8
  }
9
+ async generateQuestionnaire(request) {
10
+ this.validateQuestionnaireRequest(request);
11
+ return this.post('/codespace/generate-questionnaire', request);
12
+ }
9
13
  async createCodespaceTask(request) {
10
14
  return this.post('/codespace/create-task', request);
11
15
  }
@@ -29,6 +33,30 @@ class CodespaceService extends base_service_1.BaseService {
29
33
  }
30
34
  return this.get(`/project-tasks/by-codespace/${codespaceTaskId}`);
31
35
  }
36
+ async getCodespaceTasksByProject(params) {
37
+ if (!params.project_id) {
38
+ throw new Error('project_id is required');
39
+ }
40
+ const queryParams = new URLSearchParams();
41
+ if (params.status)
42
+ queryParams.append('status', params.status);
43
+ if (params.limit !== undefined)
44
+ queryParams.append('limit', params.limit.toString());
45
+ if (params.offset !== undefined)
46
+ queryParams.append('offset', params.offset.toString());
47
+ if (params.sort_by)
48
+ queryParams.append('sort_by', params.sort_by);
49
+ if (params.sort_order)
50
+ queryParams.append('sort_order', params.sort_order);
51
+ const url = `/codespace/tasks/project/${params.project_id}${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
52
+ return this.get(url);
53
+ }
54
+ async getCodespaceTaskDetailed(codespaceTaskId) {
55
+ if (!codespaceTaskId) {
56
+ throw new Error('codespace_task_id is required');
57
+ }
58
+ return this.get(`/codespace/task/${codespaceTaskId}/detailed`);
59
+ }
32
60
  validateCodespaceTaskRequest(request) {
33
61
  if (!request.project_id) {
34
62
  throw new Error('project_id is required');
@@ -36,7 +64,8 @@ class CodespaceService extends base_service_1.BaseService {
36
64
  if (!request.task_description) {
37
65
  throw new Error('task_description is required');
38
66
  }
39
- if (request.execution_mode && !['implementation', 'docs-only'].includes(request.execution_mode)) {
67
+ if (request.execution_mode &&
68
+ !['implementation', 'docs-only'].includes(request.execution_mode)) {
40
69
  throw new Error('execution_mode must be either "implementation" or "docs-only"');
41
70
  }
42
71
  // Validate model_api_keys if provided
@@ -57,6 +86,51 @@ class CodespaceService extends base_service_1.BaseService {
57
86
  if (request.base_branch === undefined) {
58
87
  request.base_branch = 'main';
59
88
  }
89
+ // Validate ai_questionnaire if provided
90
+ if (request.ai_questionnaire) {
91
+ if (typeof request.ai_questionnaire !== 'object' || request.ai_questionnaire === null) {
92
+ throw new Error('ai_questionnaire must be an object');
93
+ }
94
+ // Check if it's a plain object with string keys and string values
95
+ for (const [key, value] of Object.entries(request.ai_questionnaire)) {
96
+ if (typeof key !== 'string') {
97
+ throw new Error('All ai_questionnaire keys must be strings');
98
+ }
99
+ if (typeof value !== 'string') {
100
+ throw new Error('All ai_questionnaire values must be strings');
101
+ }
102
+ }
103
+ }
104
+ }
105
+ validateQuestionnaireRequest(request) {
106
+ if (!request.task_description) {
107
+ throw new Error('task_description is required');
108
+ }
109
+ // Validate attachments if provided
110
+ if (request.attachments) {
111
+ if (!Array.isArray(request.attachments)) {
112
+ throw new Error('attachments must be an array');
113
+ }
114
+ for (const attachment of request.attachments) {
115
+ // Check required fields
116
+ if (!attachment.filename || typeof attachment.filename !== 'string') {
117
+ throw new Error('Each attachment must have a valid filename string');
118
+ }
119
+ if (!attachment.file_data || typeof attachment.file_data !== 'string') {
120
+ throw new Error('Each attachment must have valid file_data string');
121
+ }
122
+ if (!attachment.mime_type || typeof attachment.mime_type !== 'string') {
123
+ throw new Error('Each attachment must have a valid mime_type string');
124
+ }
125
+ if (typeof attachment.file_size !== 'number' || attachment.file_size < 0) {
126
+ throw new Error('Each attachment must have a valid file_size number (>= 0)');
127
+ }
128
+ // Validate optional description field
129
+ if (attachment.description && typeof attachment.description !== 'string') {
130
+ throw new Error('Attachment description must be a string if provided');
131
+ }
132
+ }
133
+ }
60
134
  }
61
135
  }
62
136
  exports.CodespaceService = CodespaceService;
@@ -20,6 +20,13 @@ export interface ModelApiKey {
20
20
  model_name: string;
21
21
  api_key: string;
22
22
  }
23
+ export interface Attachment {
24
+ filename: string;
25
+ file_data: string;
26
+ mime_type: string;
27
+ file_size: number;
28
+ description?: string;
29
+ }
23
30
  export interface CreateCodespaceTaskRequestV2 {
24
31
  project_id: string;
25
32
  project_repository_id?: string;
@@ -35,6 +42,9 @@ export interface CreateCodespaceTaskRequestV2 {
35
42
  execution_mode?: 'implementation' | 'docs-only';
36
43
  model_name?: string;
37
44
  starter_kit_repo?: string;
45
+ use_enhanced_summary?: boolean;
46
+ attachments?: Attachment[];
47
+ ai_questionnaire?: Record<string, string>;
38
48
  }
39
49
  export interface CreateCodespaceTaskResponseV2 {
40
50
  success: boolean;
@@ -115,3 +125,41 @@ export interface CreateBackgroundCodespaceTaskRequest extends CreateCodespaceTas
115
125
  }
116
126
  export interface CreateBackgroundCodespaceTaskResponse extends CreateCodespaceTaskResponseV2 {
117
127
  }
128
+ export interface GetCodespaceTasksByProjectRequest {
129
+ project_id: string;
130
+ status?: 'completed' | 'failed' | 'in_progress' | 'created' | 'cancelled';
131
+ limit?: number;
132
+ offset?: number;
133
+ sort_by?: string;
134
+ sort_order?: 'asc' | 'desc';
135
+ }
136
+ export interface GetCodespaceTasksByProjectResponse {
137
+ status: string;
138
+ data: CodespaceTaskData[];
139
+ total_count: number;
140
+ message: string;
141
+ }
142
+ export interface CodespaceTaskDetailedResponse {
143
+ status: string;
144
+ data: {
145
+ task: CodespaceTaskData;
146
+ project: any;
147
+ repository: any;
148
+ usage_summary: any;
149
+ };
150
+ message: string;
151
+ }
152
+ export interface CodespaceQuestionnaireRequest {
153
+ task_description: string;
154
+ project_context?: string;
155
+ repository_info?: {
156
+ name?: string;
157
+ description?: string;
158
+ };
159
+ attachments?: Attachment[];
160
+ }
161
+ export interface CodespaceQuestionnaireResponse {
162
+ success: boolean;
163
+ questions: string[];
164
+ message: string;
165
+ }
@@ -1,3 +1,3 @@
1
1
  export { CodespaceService } from './codespace-service';
2
2
  export * from './codespace-types';
3
- export type { CreateCodespaceTaskRequestV2 as CreateCodespaceTaskRequest, CreateCodespaceTaskResponseV2 as CreateCodespaceTaskResponse, CreateBackgroundCodespaceTaskRequest, CreateBackgroundCodespaceTaskResponse, ModelApiKey, GetCodespaceTaskResponse, CodespaceTaskData, TechnicalDocument, GetProjectTasksByCodespaceResponse } from './codespace-types';
3
+ export type { CreateCodespaceTaskRequestV2 as CreateCodespaceTaskRequest, CreateCodespaceTaskResponseV2 as CreateCodespaceTaskResponse, CreateBackgroundCodespaceTaskRequest, CreateBackgroundCodespaceTaskResponse, ModelApiKey, Attachment, GetCodespaceTaskResponse, CodespaceTaskData, TechnicalDocument, GetProjectTasksByCodespaceResponse, CodespaceQuestionnaireRequest, CodespaceQuestionnaireResponse } from './codespace-types';
@@ -1,7 +1,7 @@
1
1
  import { BaseService } from '../base/base-service';
2
- import { Project, CreateProjectRequest, UpdateProjectRequest, PaginatedProjectsRequest, PaginatedProjectsResponse, GetProjectDocumentsRequest, GetProjectDocumentsResponse, ConnectRepositoryRequest, ConnectRepositoryResponse } from './project-types';
2
+ import { Project, CreateProjectRequest, UpdateProjectRequest, PaginatedProjectsRequest, PaginatedProjectsResponse, GetProjectsRequest, GetProjectDocumentsRequest, GetProjectDocumentsResponse, ConnectRepositoryRequest, ConnectRepositoryResponse } from './project-types';
3
3
  export declare class ProjectService extends BaseService {
4
- getAllProjects(): Promise<Project[]>;
4
+ getAllProjects(params?: GetProjectsRequest): Promise<Project[]>;
5
5
  getPaginatedProjects(params: PaginatedProjectsRequest): Promise<PaginatedProjectsResponse>;
6
6
  getProjectById(projectId: string): Promise<Project>;
7
7
  createProject(request: CreateProjectRequest): Promise<Project>;
@@ -3,8 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectService = void 0;
4
4
  const base_service_1 = require("../base/base-service");
5
5
  class ProjectService extends base_service_1.BaseService {
6
- async getAllProjects() {
7
- const response = await this.get('/projects');
6
+ async getAllProjects(params) {
7
+ const queryParams = new URLSearchParams();
8
+ if (params?.has_repository !== undefined) {
9
+ queryParams.append('has_repository', params.has_repository.toString());
10
+ }
11
+ const url = `/projects${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
12
+ const response = await this.get(url);
8
13
  return response.data;
9
14
  }
10
15
  async getPaginatedProjects(params) {
@@ -23,6 +28,8 @@ class ProjectService extends base_service_1.BaseService {
23
28
  queryParams.append('end_date', params.end_date);
24
29
  if (params.sort_by_date)
25
30
  queryParams.append('sort_by_date', params.sort_by_date);
31
+ if (params.has_repository !== undefined)
32
+ queryParams.append('has_repository', params.has_repository.toString());
26
33
  const url = `/projects/paginated${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
27
34
  return this.get(url);
28
35
  }
@@ -1,3 +1,14 @@
1
+ export interface ProjectRepository {
2
+ id: string;
3
+ project_id: string;
4
+ repo_url: string;
5
+ branch: string;
6
+ author: string;
7
+ name: string;
8
+ connection_status: 'pending' | 'connected' | 'failed';
9
+ created_at: string;
10
+ updated_at: string;
11
+ }
1
12
  export interface Project {
2
13
  id: string;
3
14
  title: string;
@@ -6,6 +17,7 @@ export interface Project {
6
17
  created_at: string;
7
18
  updated_at: string;
8
19
  project_documents: ProjectDocument[];
20
+ project_repositories: ProjectRepository[];
9
21
  category?: Category;
10
22
  codie_tool?: CodieTool;
11
23
  github_url?: string;
@@ -76,6 +88,9 @@ export interface ProjectResponse {
76
88
  status: string;
77
89
  data: Project;
78
90
  }
91
+ export interface GetProjectsRequest {
92
+ has_repository?: boolean;
93
+ }
79
94
  export interface PaginatedProjectsRequest {
80
95
  page?: number;
81
96
  page_size?: number;
@@ -84,6 +99,7 @@ export interface PaginatedProjectsRequest {
84
99
  start_date?: string;
85
100
  end_date?: string;
86
101
  sort_by_date?: 'asc' | 'desc';
102
+ has_repository?: boolean;
87
103
  }
88
104
  export interface PaginatedProjectsResponse {
89
105
  status: string;
@@ -1,8 +1,21 @@
1
+ import { Attachment } from '../codespace/codespace-types';
1
2
  export interface AnalyzeRepositoryRequest {
2
- repository_url: string;
3
+ github_url: string;
4
+ github_token?: string;
3
5
  generate_documents?: boolean;
4
6
  create_codespace_task?: boolean;
5
7
  project_id?: string;
8
+ codespace_task_description?: string;
9
+ codespace_branch?: string;
10
+ codespace_base_branch?: string;
11
+ model_api_keys?: {
12
+ model_name: string;
13
+ api_key: string;
14
+ }[];
15
+ model_name?: string;
16
+ starter_kit_repo?: string;
17
+ use_enhanced_summary?: boolean;
18
+ attachments?: Attachment[];
6
19
  }
7
20
  export interface AnalyzeRepositoryResponse {
8
21
  task_id: string;