@ocxp/client 0.2.5 → 0.2.7

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.
package/dist/index.cjs CHANGED
@@ -1187,6 +1187,29 @@ var deleteRepo = (options) => (options.client ?? client).delete({
1187
1187
  url: "/ocxp/repo/{repo_id}",
1188
1188
  ...options
1189
1189
  });
1190
+ var syncAllRepos = (options) => (options?.client ?? client).post({
1191
+ security: [{ scheme: "bearer", type: "http" }],
1192
+ url: "/ocxp/repo/sync-all",
1193
+ ...options,
1194
+ headers: {
1195
+ "Content-Type": "application/json",
1196
+ ...options?.headers
1197
+ }
1198
+ });
1199
+ var getRepoCommits = (options) => (options.client ?? client).get({
1200
+ security: [{ scheme: "bearer", type: "http" }],
1201
+ url: "/ocxp/repo/{repo_id}/commits",
1202
+ ...options
1203
+ });
1204
+ var syncRepo = (options) => (options.client ?? client).post({
1205
+ security: [{ scheme: "bearer", type: "http" }],
1206
+ url: "/ocxp/repo/{repo_id}/sync",
1207
+ ...options,
1208
+ headers: {
1209
+ "Content-Type": "application/json",
1210
+ ...options.headers
1211
+ }
1212
+ });
1190
1213
  var githubCheckAccess = (options) => (options.client ?? client).post({
1191
1214
  security: [{ scheme: "bearer", type: "http" }],
1192
1215
  url: "/ocxp/github/check-access",
@@ -1999,6 +2022,48 @@ var OCXPClient = class {
1999
2022
  });
2000
2023
  return extractData(response);
2001
2024
  }
2025
+ /**
2026
+ * Sync a repository with its remote GitHub branch
2027
+ * @param repoId - Repository ID (owner/repo format)
2028
+ * @param force - Force sync even if no changes detected
2029
+ */
2030
+ async syncRepo(repoId, force = false) {
2031
+ const headers = await this.getHeaders();
2032
+ const response = await syncRepo({
2033
+ client: this.client,
2034
+ path: { repo_id: repoId },
2035
+ body: { force },
2036
+ headers
2037
+ });
2038
+ return extractData(response);
2039
+ }
2040
+ /**
2041
+ * Sync all repositories with their remote GitHub branches
2042
+ * @param force - Force sync all repos even if no changes
2043
+ */
2044
+ async syncAllRepos(force = false) {
2045
+ const headers = await this.getHeaders();
2046
+ const response = await syncAllRepos({
2047
+ client: this.client,
2048
+ body: { force },
2049
+ headers
2050
+ });
2051
+ return extractData(response);
2052
+ }
2053
+ /**
2054
+ * Get commit status for a repository
2055
+ * Shows how many commits behind and lists missing commits
2056
+ * @param repoId - Repository ID (owner/repo format)
2057
+ */
2058
+ async getRepoCommitStatus(repoId) {
2059
+ const headers = await this.getHeaders();
2060
+ const response = await getRepoCommits({
2061
+ client: this.client,
2062
+ path: { repo_id: repoId },
2063
+ headers
2064
+ });
2065
+ return extractData(response);
2066
+ }
2002
2067
  // ============== Database Operations ==============
2003
2068
  /**
2004
2069
  * List all database configurations in workspace
@@ -2508,7 +2573,7 @@ var OCXPClient = class {
2508
2573
  body: { github_token: token }
2509
2574
  });
2510
2575
  if (response.error) {
2511
- throw new Error(`Failed to set GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2576
+ throw new Error(`Failed to set GitHub token: ${JSON.stringify(response.error)}`);
2512
2577
  }
2513
2578
  if (response.data === true) {
2514
2579
  return { success: true };
@@ -2521,13 +2586,15 @@ var OCXPClient = class {
2521
2586
  */
2522
2587
  async getGitHubTokenStatus() {
2523
2588
  const headers = await this.getHeaders();
2524
- const response = await this.client.request({
2525
- method: "GET",
2526
- url: "/auth/github-token",
2527
- headers
2528
- });
2589
+ const response = await this.client.request(
2590
+ {
2591
+ method: "GET",
2592
+ url: "/auth/github-token",
2593
+ headers
2594
+ }
2595
+ );
2529
2596
  if (response.error) {
2530
- throw new Error(`Failed to get GitHub token status: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2597
+ throw new Error(`Failed to get GitHub token status: ${JSON.stringify(response.error)}`);
2531
2598
  }
2532
2599
  const data = response.data;
2533
2600
  if (data && typeof data === "object" && "configured" in data) {
@@ -2547,13 +2614,87 @@ var OCXPClient = class {
2547
2614
  headers
2548
2615
  });
2549
2616
  if (response.error) {
2550
- throw new Error(`Failed to delete GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2617
+ throw new Error(`Failed to delete GitHub token: ${JSON.stringify(response.error)}`);
2551
2618
  }
2552
2619
  if (response.data === true) {
2553
2620
  return { success: true };
2554
2621
  }
2555
2622
  return response.data || { success: true };
2556
2623
  }
2624
+ // ============== Project Credential Operations ==============
2625
+ /**
2626
+ * Get project credentials for frontend authentication
2627
+ * @param projectId - Project ID
2628
+ * @returns Project credentials
2629
+ */
2630
+ async getProjectCredentials(projectId) {
2631
+ const headers = await this.getHeaders();
2632
+ const response = await this.client.request({
2633
+ method: "GET",
2634
+ url: `/ocxp/project/${projectId}/credentials`,
2635
+ headers
2636
+ });
2637
+ if (response.error) {
2638
+ throw new Error(`Failed to get credentials: ${JSON.stringify(response.error)}`);
2639
+ }
2640
+ return response.data;
2641
+ }
2642
+ /**
2643
+ * Update project credentials for frontend authentication
2644
+ * @param projectId - Project ID
2645
+ * @param updates - Partial credential updates
2646
+ * @returns Updated project credentials
2647
+ */
2648
+ async updateProjectCredentials(projectId, updates) {
2649
+ const headers = await this.getHeaders();
2650
+ const response = await this.client.request({
2651
+ method: "PATCH",
2652
+ url: `/ocxp/project/${projectId}/credentials`,
2653
+ headers,
2654
+ body: updates
2655
+ });
2656
+ if (response.error) {
2657
+ throw new Error(`Failed to update credentials: ${JSON.stringify(response.error)}`);
2658
+ }
2659
+ return response.data;
2660
+ }
2661
+ /**
2662
+ * Test project credentials
2663
+ * @param projectId - Project ID
2664
+ * @returns Test result with success flag and optional message
2665
+ */
2666
+ async testProjectCredentials(projectId) {
2667
+ const headers = await this.getHeaders();
2668
+ const response = await this.client.request({
2669
+ method: "POST",
2670
+ url: `/ocxp/project/${projectId}/credentials/test`,
2671
+ headers
2672
+ });
2673
+ if (response.error) {
2674
+ throw new Error(`Failed to test credentials: ${JSON.stringify(response.error)}`);
2675
+ }
2676
+ const data = response.data;
2677
+ if (data && typeof data === "object" && "success" in data) {
2678
+ return data;
2679
+ }
2680
+ return { success: false };
2681
+ }
2682
+ /**
2683
+ * Delete project credentials
2684
+ * @param projectId - Project ID
2685
+ * @returns void
2686
+ */
2687
+ async deleteProjectCredentials(projectId) {
2688
+ const headers = await this.getHeaders();
2689
+ const response = await this.client.request({
2690
+ method: "DELETE",
2691
+ url: `/ocxp/project/${projectId}/credentials`,
2692
+ headers
2693
+ });
2694
+ if (response.error) {
2695
+ throw new Error(`Failed to delete credentials: ${JSON.stringify(response.error)}`);
2696
+ }
2697
+ }
2557
2698
  // ============== Namespaced Accessors ==============
2558
2699
  _mission;
2559
2700
  _project;
@@ -4351,6 +4492,7 @@ exports.getMissionContext = getMissionContext;
4351
4492
  exports.getProject = getProject;
4352
4493
  exports.getProjectDatabases = getProjectDatabases;
4353
4494
  exports.getPrototypeChat = getPrototypeChat;
4495
+ exports.getRepoCommits = getRepoCommits;
4354
4496
  exports.getRepoDownloadStatus = getRepoDownloadStatus;
4355
4497
  exports.getSample = getSample;
4356
4498
  exports.getSchema = getSchema;
@@ -4404,8 +4546,10 @@ exports.safeParseWSMessage = safeParseWSMessage;
4404
4546
  exports.searchContent = searchContent;
4405
4547
  exports.setDefaultDatabase = setDefaultDatabase;
4406
4548
  exports.setDefaultRepo = setDefaultRepo;
4549
+ exports.syncAllRepos = syncAllRepos;
4407
4550
  exports.syncPrototypeChat = syncPrototypeChat;
4408
4551
  exports.syncPrototypeChatAsync = syncPrototypeChatAsync;
4552
+ exports.syncRepo = syncRepo;
4409
4553
  exports.testDatabaseConnection = testDatabaseConnection;
4410
4554
  exports.toolCreateMission = toolCreateMission;
4411
4555
  exports.toolUpdateMission = toolUpdateMission;