@ocxp/client 0.2.6 → 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.d.ts CHANGED
@@ -2899,7 +2899,7 @@ type RepoDeleteResponse = {
2899
2899
  *
2900
2900
  * Deleted repository UUID
2901
2901
  */
2902
- id: string;
2902
+ id?: string | null;
2903
2903
  /**
2904
2904
  * Repo Id
2905
2905
  *
@@ -7185,7 +7185,7 @@ declare const listDownloadedRepos: <ThrowOnError extends boolean = false>(option
7185
7185
  /**
7186
7186
  * Delete repository
7187
7187
  *
7188
- * Permanently deletes a downloaded repository. Uses repo_id (owner/repo format).
7188
+ * Permanently deletes a downloaded repository. Accepts UUID or owner/repo format.
7189
7189
  */
7190
7190
  declare const deleteRepo: <ThrowOnError extends boolean = false>(options: Options<DeleteRepoData, ThrowOnError>) => RequestResult<DeleteRepoResponses, DeleteRepoErrors, ThrowOnError, "fields">;
7191
7191
  /**
@@ -7431,6 +7431,182 @@ declare const getCurrentUser: <ThrowOnError extends boolean = false>(options?: O
7431
7431
  */
7432
7432
  declare const listWorkspaces: <ThrowOnError extends boolean = false>(options?: Options<ListWorkspacesData, ThrowOnError>) => RequestResult<ListWorkspacesResponses, ListWorkspacesErrors, ThrowOnError, "fields">;
7433
7433
 
7434
+ /**
7435
+ * OCXP Error Types
7436
+ *
7437
+ * Typed error classes for the OCXP SDK providing structured error handling
7438
+ * with error codes, HTTP status codes, and detailed context.
7439
+ */
7440
+ /**
7441
+ * Error codes for OCXP operations
7442
+ */
7443
+ declare enum OCXPErrorCode {
7444
+ /** Network-level error (connection failed, timeout, etc.) */
7445
+ NETWORK_ERROR = "NETWORK_ERROR",
7446
+ /** Request or response validation failed */
7447
+ VALIDATION_ERROR = "VALIDATION_ERROR",
7448
+ /** Authentication or authorization failed */
7449
+ AUTH_ERROR = "AUTH_ERROR",
7450
+ /** Resource not found */
7451
+ NOT_FOUND = "NOT_FOUND",
7452
+ /** Rate limit exceeded */
7453
+ RATE_LIMITED = "RATE_LIMITED",
7454
+ /** Conflict (e.g., etag mismatch) */
7455
+ CONFLICT = "CONFLICT",
7456
+ /** Operation timed out */
7457
+ TIMEOUT = "TIMEOUT",
7458
+ /** Server-side error */
7459
+ SERVER_ERROR = "SERVER_ERROR",
7460
+ /** Unknown error */
7461
+ UNKNOWN = "UNKNOWN"
7462
+ }
7463
+ /**
7464
+ * Base error class for all OCXP errors
7465
+ */
7466
+ declare class OCXPError extends Error {
7467
+ /** Error code for programmatic handling */
7468
+ readonly code: OCXPErrorCode;
7469
+ /** HTTP status code if applicable */
7470
+ readonly statusCode: number;
7471
+ /** Additional error details */
7472
+ readonly details?: Record<string, unknown>;
7473
+ /** Request ID for debugging */
7474
+ readonly requestId?: string;
7475
+ /** Original cause of the error */
7476
+ readonly cause?: Error;
7477
+ constructor(message: string, code?: OCXPErrorCode, statusCode?: number, options?: {
7478
+ details?: Record<string, unknown>;
7479
+ requestId?: string;
7480
+ cause?: Error;
7481
+ });
7482
+ /**
7483
+ * Convert error to JSON for logging/serialization
7484
+ */
7485
+ toJSON(): Record<string, unknown>;
7486
+ }
7487
+ /**
7488
+ * Network-level error (connection failed, DNS resolution, etc.)
7489
+ */
7490
+ declare class OCXPNetworkError extends OCXPError {
7491
+ constructor(message: string, options?: {
7492
+ details?: Record<string, unknown>;
7493
+ requestId?: string;
7494
+ cause?: Error;
7495
+ });
7496
+ }
7497
+ /**
7498
+ * Validation error (request or response validation failed)
7499
+ */
7500
+ declare class OCXPValidationError extends OCXPError {
7501
+ /** Field-level validation errors */
7502
+ readonly validationErrors?: Record<string, string[]>;
7503
+ constructor(message: string, validationErrors?: Record<string, string[]>, options?: {
7504
+ details?: Record<string, unknown>;
7505
+ requestId?: string;
7506
+ cause?: Error;
7507
+ });
7508
+ }
7509
+ /**
7510
+ * Authentication or authorization error
7511
+ */
7512
+ declare class OCXPAuthError extends OCXPError {
7513
+ constructor(message: string, options?: {
7514
+ details?: Record<string, unknown>;
7515
+ requestId?: string;
7516
+ cause?: Error;
7517
+ });
7518
+ }
7519
+ /**
7520
+ * Resource not found error
7521
+ */
7522
+ declare class OCXPNotFoundError extends OCXPError {
7523
+ /** The resource path that was not found */
7524
+ readonly path?: string;
7525
+ constructor(message: string, path?: string, options?: {
7526
+ details?: Record<string, unknown>;
7527
+ requestId?: string;
7528
+ cause?: Error;
7529
+ });
7530
+ }
7531
+ /**
7532
+ * Rate limit exceeded error
7533
+ */
7534
+ declare class OCXPRateLimitError extends OCXPError {
7535
+ /** Seconds until rate limit resets */
7536
+ readonly retryAfter?: number;
7537
+ constructor(message?: string, retryAfter?: number, options?: {
7538
+ details?: Record<string, unknown>;
7539
+ requestId?: string;
7540
+ cause?: Error;
7541
+ });
7542
+ }
7543
+ /**
7544
+ * Conflict error (e.g., etag mismatch, concurrent modification)
7545
+ */
7546
+ declare class OCXPConflictError extends OCXPError {
7547
+ /** Expected etag value */
7548
+ readonly expectedEtag?: string;
7549
+ /** Actual etag value */
7550
+ readonly actualEtag?: string;
7551
+ constructor(message: string, options?: {
7552
+ expectedEtag?: string;
7553
+ actualEtag?: string;
7554
+ details?: Record<string, unknown>;
7555
+ requestId?: string;
7556
+ cause?: Error;
7557
+ });
7558
+ }
7559
+ /**
7560
+ * Operation timeout error
7561
+ */
7562
+ declare class OCXPTimeoutError extends OCXPError {
7563
+ /** Timeout duration in milliseconds */
7564
+ readonly timeoutMs?: number;
7565
+ constructor(message?: string, timeoutMs?: number, options?: {
7566
+ details?: Record<string, unknown>;
7567
+ requestId?: string;
7568
+ cause?: Error;
7569
+ });
7570
+ }
7571
+ /**
7572
+ * Type guard to check if an error is an OCXPError
7573
+ */
7574
+ declare function isOCXPError(error: unknown): error is OCXPError;
7575
+ /**
7576
+ * Type guard for specific error types
7577
+ */
7578
+ declare function isOCXPNetworkError(error: unknown): error is OCXPNetworkError;
7579
+ declare function isOCXPValidationError(error: unknown): error is OCXPValidationError;
7580
+ declare function isOCXPAuthError(error: unknown): error is OCXPAuthError;
7581
+ declare function isOCXPNotFoundError(error: unknown): error is OCXPNotFoundError;
7582
+ declare function isOCXPRateLimitError(error: unknown): error is OCXPRateLimitError;
7583
+ declare function isOCXPConflictError(error: unknown): error is OCXPConflictError;
7584
+ declare function isOCXPTimeoutError(error: unknown): error is OCXPTimeoutError;
7585
+ /**
7586
+ * Map HTTP status code to appropriate OCXP error
7587
+ */
7588
+ declare function mapHttpError(statusCode: number, message: string, options?: {
7589
+ details?: Record<string, unknown>;
7590
+ requestId?: string;
7591
+ path?: string;
7592
+ retryAfter?: number;
7593
+ }): OCXPError;
7594
+
7595
+ /**
7596
+ * OCXP Type Exports
7597
+ */
7598
+
7599
+ /**
7600
+ * Project Credentials for frontend authentication
7601
+ */
7602
+ interface ProjectCredentials {
7603
+ url?: string;
7604
+ username?: string;
7605
+ password?: string;
7606
+ createdAt?: string;
7607
+ updatedAt?: string;
7608
+ }
7609
+
7434
7610
  interface ListEntry$1 {
7435
7611
  name: string;
7436
7612
  type: string;
@@ -8009,6 +8185,34 @@ declare class OCXPClient {
8009
8185
  deleteGitHubToken(): Promise<{
8010
8186
  success: boolean;
8011
8187
  }>;
8188
+ /**
8189
+ * Get project credentials for frontend authentication
8190
+ * @param projectId - Project ID
8191
+ * @returns Project credentials
8192
+ */
8193
+ getProjectCredentials(projectId: string): Promise<ProjectCredentials>;
8194
+ /**
8195
+ * Update project credentials for frontend authentication
8196
+ * @param projectId - Project ID
8197
+ * @param updates - Partial credential updates
8198
+ * @returns Updated project credentials
8199
+ */
8200
+ updateProjectCredentials(projectId: string, updates: Partial<ProjectCredentials>): Promise<ProjectCredentials>;
8201
+ /**
8202
+ * Test project credentials
8203
+ * @param projectId - Project ID
8204
+ * @returns Test result with success flag and optional message
8205
+ */
8206
+ testProjectCredentials(projectId: string): Promise<{
8207
+ success: boolean;
8208
+ message?: string;
8209
+ }>;
8210
+ /**
8211
+ * Delete project credentials
8212
+ * @param projectId - Project ID
8213
+ * @returns void
8214
+ */
8215
+ deleteProjectCredentials(projectId: string): Promise<void>;
8012
8216
  private _mission?;
8013
8217
  private _project?;
8014
8218
  private _session?;
@@ -8810,167 +9014,6 @@ declare class WebSocketService {
8810
9014
  */
8811
9015
  declare function createWebSocketService(options: WebSocketServiceOptions): WebSocketService;
8812
9016
 
8813
- /**
8814
- * OCXP Error Types
8815
- *
8816
- * Typed error classes for the OCXP SDK providing structured error handling
8817
- * with error codes, HTTP status codes, and detailed context.
8818
- */
8819
- /**
8820
- * Error codes for OCXP operations
8821
- */
8822
- declare enum OCXPErrorCode {
8823
- /** Network-level error (connection failed, timeout, etc.) */
8824
- NETWORK_ERROR = "NETWORK_ERROR",
8825
- /** Request or response validation failed */
8826
- VALIDATION_ERROR = "VALIDATION_ERROR",
8827
- /** Authentication or authorization failed */
8828
- AUTH_ERROR = "AUTH_ERROR",
8829
- /** Resource not found */
8830
- NOT_FOUND = "NOT_FOUND",
8831
- /** Rate limit exceeded */
8832
- RATE_LIMITED = "RATE_LIMITED",
8833
- /** Conflict (e.g., etag mismatch) */
8834
- CONFLICT = "CONFLICT",
8835
- /** Operation timed out */
8836
- TIMEOUT = "TIMEOUT",
8837
- /** Server-side error */
8838
- SERVER_ERROR = "SERVER_ERROR",
8839
- /** Unknown error */
8840
- UNKNOWN = "UNKNOWN"
8841
- }
8842
- /**
8843
- * Base error class for all OCXP errors
8844
- */
8845
- declare class OCXPError extends Error {
8846
- /** Error code for programmatic handling */
8847
- readonly code: OCXPErrorCode;
8848
- /** HTTP status code if applicable */
8849
- readonly statusCode: number;
8850
- /** Additional error details */
8851
- readonly details?: Record<string, unknown>;
8852
- /** Request ID for debugging */
8853
- readonly requestId?: string;
8854
- /** Original cause of the error */
8855
- readonly cause?: Error;
8856
- constructor(message: string, code?: OCXPErrorCode, statusCode?: number, options?: {
8857
- details?: Record<string, unknown>;
8858
- requestId?: string;
8859
- cause?: Error;
8860
- });
8861
- /**
8862
- * Convert error to JSON for logging/serialization
8863
- */
8864
- toJSON(): Record<string, unknown>;
8865
- }
8866
- /**
8867
- * Network-level error (connection failed, DNS resolution, etc.)
8868
- */
8869
- declare class OCXPNetworkError extends OCXPError {
8870
- constructor(message: string, options?: {
8871
- details?: Record<string, unknown>;
8872
- requestId?: string;
8873
- cause?: Error;
8874
- });
8875
- }
8876
- /**
8877
- * Validation error (request or response validation failed)
8878
- */
8879
- declare class OCXPValidationError extends OCXPError {
8880
- /** Field-level validation errors */
8881
- readonly validationErrors?: Record<string, string[]>;
8882
- constructor(message: string, validationErrors?: Record<string, string[]>, options?: {
8883
- details?: Record<string, unknown>;
8884
- requestId?: string;
8885
- cause?: Error;
8886
- });
8887
- }
8888
- /**
8889
- * Authentication or authorization error
8890
- */
8891
- declare class OCXPAuthError extends OCXPError {
8892
- constructor(message: string, options?: {
8893
- details?: Record<string, unknown>;
8894
- requestId?: string;
8895
- cause?: Error;
8896
- });
8897
- }
8898
- /**
8899
- * Resource not found error
8900
- */
8901
- declare class OCXPNotFoundError extends OCXPError {
8902
- /** The resource path that was not found */
8903
- readonly path?: string;
8904
- constructor(message: string, path?: string, options?: {
8905
- details?: Record<string, unknown>;
8906
- requestId?: string;
8907
- cause?: Error;
8908
- });
8909
- }
8910
- /**
8911
- * Rate limit exceeded error
8912
- */
8913
- declare class OCXPRateLimitError extends OCXPError {
8914
- /** Seconds until rate limit resets */
8915
- readonly retryAfter?: number;
8916
- constructor(message?: string, retryAfter?: number, options?: {
8917
- details?: Record<string, unknown>;
8918
- requestId?: string;
8919
- cause?: Error;
8920
- });
8921
- }
8922
- /**
8923
- * Conflict error (e.g., etag mismatch, concurrent modification)
8924
- */
8925
- declare class OCXPConflictError extends OCXPError {
8926
- /** Expected etag value */
8927
- readonly expectedEtag?: string;
8928
- /** Actual etag value */
8929
- readonly actualEtag?: string;
8930
- constructor(message: string, options?: {
8931
- expectedEtag?: string;
8932
- actualEtag?: string;
8933
- details?: Record<string, unknown>;
8934
- requestId?: string;
8935
- cause?: Error;
8936
- });
8937
- }
8938
- /**
8939
- * Operation timeout error
8940
- */
8941
- declare class OCXPTimeoutError extends OCXPError {
8942
- /** Timeout duration in milliseconds */
8943
- readonly timeoutMs?: number;
8944
- constructor(message?: string, timeoutMs?: number, options?: {
8945
- details?: Record<string, unknown>;
8946
- requestId?: string;
8947
- cause?: Error;
8948
- });
8949
- }
8950
- /**
8951
- * Type guard to check if an error is an OCXPError
8952
- */
8953
- declare function isOCXPError(error: unknown): error is OCXPError;
8954
- /**
8955
- * Type guard for specific error types
8956
- */
8957
- declare function isOCXPNetworkError(error: unknown): error is OCXPNetworkError;
8958
- declare function isOCXPValidationError(error: unknown): error is OCXPValidationError;
8959
- declare function isOCXPAuthError(error: unknown): error is OCXPAuthError;
8960
- declare function isOCXPNotFoundError(error: unknown): error is OCXPNotFoundError;
8961
- declare function isOCXPRateLimitError(error: unknown): error is OCXPRateLimitError;
8962
- declare function isOCXPConflictError(error: unknown): error is OCXPConflictError;
8963
- declare function isOCXPTimeoutError(error: unknown): error is OCXPTimeoutError;
8964
- /**
8965
- * Map HTTP status code to appropriate OCXP error
8966
- */
8967
- declare function mapHttpError(statusCode: number, message: string, options?: {
8968
- details?: Record<string, unknown>;
8969
- requestId?: string;
8970
- path?: string;
8971
- retryAfter?: number;
8972
- }): OCXPError;
8973
-
8974
9017
  /**
8975
9018
  * Common Zod Schemas for OCXP API
8976
9019
  *
package/dist/index.js CHANGED
@@ -2571,7 +2571,7 @@ var OCXPClient = class {
2571
2571
  body: { github_token: token }
2572
2572
  });
2573
2573
  if (response.error) {
2574
- throw new Error(`Failed to set GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2574
+ throw new Error(`Failed to set GitHub token: ${JSON.stringify(response.error)}`);
2575
2575
  }
2576
2576
  if (response.data === true) {
2577
2577
  return { success: true };
@@ -2584,13 +2584,15 @@ var OCXPClient = class {
2584
2584
  */
2585
2585
  async getGitHubTokenStatus() {
2586
2586
  const headers = await this.getHeaders();
2587
- const response = await this.client.request({
2588
- method: "GET",
2589
- url: "/auth/github-token",
2590
- headers
2591
- });
2587
+ const response = await this.client.request(
2588
+ {
2589
+ method: "GET",
2590
+ url: "/auth/github-token",
2591
+ headers
2592
+ }
2593
+ );
2592
2594
  if (response.error) {
2593
- throw new Error(`Failed to get GitHub token status: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2595
+ throw new Error(`Failed to get GitHub token status: ${JSON.stringify(response.error)}`);
2594
2596
  }
2595
2597
  const data = response.data;
2596
2598
  if (data && typeof data === "object" && "configured" in data) {
@@ -2610,13 +2612,87 @@ var OCXPClient = class {
2610
2612
  headers
2611
2613
  });
2612
2614
  if (response.error) {
2613
- throw new Error(`Failed to delete GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2615
+ throw new Error(`Failed to delete GitHub token: ${JSON.stringify(response.error)}`);
2614
2616
  }
2615
2617
  if (response.data === true) {
2616
2618
  return { success: true };
2617
2619
  }
2618
2620
  return response.data || { success: true };
2619
2621
  }
2622
+ // ============== Project Credential Operations ==============
2623
+ /**
2624
+ * Get project credentials for frontend authentication
2625
+ * @param projectId - Project ID
2626
+ * @returns Project credentials
2627
+ */
2628
+ async getProjectCredentials(projectId) {
2629
+ const headers = await this.getHeaders();
2630
+ const response = await this.client.request({
2631
+ method: "GET",
2632
+ url: `/ocxp/project/${projectId}/credentials`,
2633
+ headers
2634
+ });
2635
+ if (response.error) {
2636
+ throw new Error(`Failed to get credentials: ${JSON.stringify(response.error)}`);
2637
+ }
2638
+ return response.data;
2639
+ }
2640
+ /**
2641
+ * Update project credentials for frontend authentication
2642
+ * @param projectId - Project ID
2643
+ * @param updates - Partial credential updates
2644
+ * @returns Updated project credentials
2645
+ */
2646
+ async updateProjectCredentials(projectId, updates) {
2647
+ const headers = await this.getHeaders();
2648
+ const response = await this.client.request({
2649
+ method: "PATCH",
2650
+ url: `/ocxp/project/${projectId}/credentials`,
2651
+ headers,
2652
+ body: updates
2653
+ });
2654
+ if (response.error) {
2655
+ throw new Error(`Failed to update credentials: ${JSON.stringify(response.error)}`);
2656
+ }
2657
+ return response.data;
2658
+ }
2659
+ /**
2660
+ * Test project credentials
2661
+ * @param projectId - Project ID
2662
+ * @returns Test result with success flag and optional message
2663
+ */
2664
+ async testProjectCredentials(projectId) {
2665
+ const headers = await this.getHeaders();
2666
+ const response = await this.client.request({
2667
+ method: "POST",
2668
+ url: `/ocxp/project/${projectId}/credentials/test`,
2669
+ headers
2670
+ });
2671
+ if (response.error) {
2672
+ throw new Error(`Failed to test credentials: ${JSON.stringify(response.error)}`);
2673
+ }
2674
+ const data = response.data;
2675
+ if (data && typeof data === "object" && "success" in data) {
2676
+ return data;
2677
+ }
2678
+ return { success: false };
2679
+ }
2680
+ /**
2681
+ * Delete project credentials
2682
+ * @param projectId - Project ID
2683
+ * @returns void
2684
+ */
2685
+ async deleteProjectCredentials(projectId) {
2686
+ const headers = await this.getHeaders();
2687
+ const response = await this.client.request({
2688
+ method: "DELETE",
2689
+ url: `/ocxp/project/${projectId}/credentials`,
2690
+ headers
2691
+ });
2692
+ if (response.error) {
2693
+ throw new Error(`Failed to delete credentials: ${JSON.stringify(response.error)}`);
2694
+ }
2695
+ }
2620
2696
  // ============== Namespaced Accessors ==============
2621
2697
  _mission;
2622
2698
  _project;