@lobehub/market-sdk 0.28.1 → 0.28.2

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.mts CHANGED
@@ -4672,6 +4672,33 @@ declare class MarketSDK extends BaseSDK {
4672
4672
  registerClient(request: ClientRegistrationRequest): Promise<ClientRegistrationResponse>;
4673
4673
  }
4674
4674
 
4675
+ /**
4676
+ * Market API Error
4677
+ *
4678
+ * Custom error class for Market API errors that preserves the structured error response.
4679
+ */
4680
+ declare class MarketAPIError extends Error {
4681
+ /** HTTP status code */
4682
+ readonly status: number;
4683
+ /** Error code from API response */
4684
+ readonly code?: string;
4685
+ /** The full error response body */
4686
+ readonly errorBody?: any;
4687
+ constructor(status: number, statusText: string, errorBody?: any);
4688
+ /**
4689
+ * Check if this is a specific error code
4690
+ */
4691
+ isErrorCode(code: string): boolean;
4692
+ /**
4693
+ * Get the full error details from the API response
4694
+ */
4695
+ getErrorDetails(): any;
4696
+ /**
4697
+ * Convert to a plain object for logging or serialization
4698
+ */
4699
+ toJSON(): any;
4700
+ }
4701
+
4675
4702
  /**
4676
4703
  * Trusted Client Token Utilities
4677
4704
  *
@@ -4745,4 +4772,4 @@ declare function buildTrustedClientPayload(params: {
4745
4772
  userId: string;
4746
4773
  }): TrustedClientPayload;
4747
4774
 
4748
- export { type AccountMeta, type AdminListQueryParams, type AdminListResponse, type AdminPluginParams, type AgentCreateRequest, type AgentCreateResponse, type AgentDetailQuery, type AgentExtension, type AgentInstallCountRequest, type AgentInstallCountResponse, type AgentInterface, type AgentItemDetail, type AgentListQuery, type AgentListResponse, type AgentModifyRequest, type AgentModifyResponse, type AgentSecurityRequirement, type AgentSecurityScheme, type AgentSkill, type AgentStatus, type AgentStatusChangeResponse, type AgentUploadRequest, type AgentUploadResponse, type AgentUploadVersion, type AgentVersionCreateRequest, type AgentVersionCreateResponse, type AgentVersionLocalization, type AgentVersionModifyRequest, type AgentVersionModifyResponse, type AuthorizationCodeTokenRequest, type AuthorizeParams, type AuthorizeResponse, type CallSkillToolResponse, type CheckFavoriteQuery, type CheckFavoriteResponse, type CheckFollowQuery, type CheckFollowResponse, type CheckLikeQuery, type CheckLikeResponse, type ClientRegistrationError, type ClientRegistrationRequest, type ClientRegistrationResponse, type CodeInterpreterToolName, type CodeInterpreterToolParams, type ConnectProvider, type ConnectProviderDetail, type ConnectProviderScopes, type ConnectionHealth, type ConnectionStats, type DiscoveryDocument, type EditLocalFileParams, type ExecuteCodeParams, type ExportFileParams, type FavoriteListResponse, type FavoriteQuery, type FavoriteRequest, type FeedbackClientInfo, type FollowListItem, type FollowListResponse, type FollowRequest, type GetAllConnectionsHealthResponse, type GetAuthorizeUrlParams, type GetCommandOutputParams, type GetConnectProviderResponse, type GetConnectionHealthResponse, type GetConnectionStatsResponse, type GetConnectionStatusResponse, type GetSkillStatusResponse, type GetSkillToolResponse, type GlobLocalFilesParams, type GrepContentParams, type InteractionTargetType, type KillCommandParams, type LikeListResponse, type LikeQuery, type LikeRequest, type ListConnectProvidersResponse, type ListConnectionsResponse, type ListLocalFilesParams, type ListSkillProvidersResponse, type ListSkillToolsResponse, MarketAdmin, MarketSDK, type MarketSDKOptions, type MoveLocalFilesParams, type MoveOperation, type OAuthConnection, type OAuthTokenResponse, type OwnAgentListQuery, type PaginationQuery, type PluginI18nImportParams, type PluginI18nImportResponse, type PluginItem, type PluginListResponse, type PluginLocalization, type PluginQueryParams, type PluginUpdateParams, type PluginVersionCreateParams, type PluginVersionUpdateParams, type ProgrammingLanguage, type ReadLocalFileParams, type RefreshConnectionResponse, type RefreshTokenRequest, type RenameLocalFileParams, type ReviewStatus, ReviewStatusEnumSchema, type RevokeConnectionResponse, type RunBuildInToolsError, type RunBuildInToolsRequest, type RunBuildInToolsResponse, type RunBuildInToolsSuccessData, type RunCommandParams, type SearchLocalFilesParams, type SharedTokenState, type SkillCallParams, type SkillErrorResponse, type SkillProviderInfo, type SkillProviderStatus, type SkillTool, StatusEnumSchema, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SuccessResponse, type ToggleLikeResponse, type TrustedClientPayload, type UnclaimedPluginItem, type UpdateUserInfoRequest, type UpdateUserInfoResponse, type UserAgentItem, type UserInfoQuery, type UserInfoResponse, type UserProfile, VisibilityEnumSchema, type WriteLocalFileParams, buildTrustedClientPayload, createTrustedClientToken, generateNonce };
4775
+ export { type AccountMeta, type AdminListQueryParams, type AdminListResponse, type AdminPluginParams, type AgentCreateRequest, type AgentCreateResponse, type AgentDetailQuery, type AgentExtension, type AgentInstallCountRequest, type AgentInstallCountResponse, type AgentInterface, type AgentItemDetail, type AgentListQuery, type AgentListResponse, type AgentModifyRequest, type AgentModifyResponse, type AgentSecurityRequirement, type AgentSecurityScheme, type AgentSkill, type AgentStatus, type AgentStatusChangeResponse, type AgentUploadRequest, type AgentUploadResponse, type AgentUploadVersion, type AgentVersionCreateRequest, type AgentVersionCreateResponse, type AgentVersionLocalization, type AgentVersionModifyRequest, type AgentVersionModifyResponse, type AuthorizationCodeTokenRequest, type AuthorizeParams, type AuthorizeResponse, type CallSkillToolResponse, type CheckFavoriteQuery, type CheckFavoriteResponse, type CheckFollowQuery, type CheckFollowResponse, type CheckLikeQuery, type CheckLikeResponse, type ClientRegistrationError, type ClientRegistrationRequest, type ClientRegistrationResponse, type CodeInterpreterToolName, type CodeInterpreterToolParams, type ConnectProvider, type ConnectProviderDetail, type ConnectProviderScopes, type ConnectionHealth, type ConnectionStats, type DiscoveryDocument, type EditLocalFileParams, type ExecuteCodeParams, type ExportFileParams, type FavoriteListResponse, type FavoriteQuery, type FavoriteRequest, type FeedbackClientInfo, type FollowListItem, type FollowListResponse, type FollowRequest, type GetAllConnectionsHealthResponse, type GetAuthorizeUrlParams, type GetCommandOutputParams, type GetConnectProviderResponse, type GetConnectionHealthResponse, type GetConnectionStatsResponse, type GetConnectionStatusResponse, type GetSkillStatusResponse, type GetSkillToolResponse, type GlobLocalFilesParams, type GrepContentParams, type InteractionTargetType, type KillCommandParams, type LikeListResponse, type LikeQuery, type LikeRequest, type ListConnectProvidersResponse, type ListConnectionsResponse, type ListLocalFilesParams, type ListSkillProvidersResponse, type ListSkillToolsResponse, MarketAPIError, MarketAdmin, MarketSDK, type MarketSDKOptions, type MoveLocalFilesParams, type MoveOperation, type OAuthConnection, type OAuthTokenResponse, type OwnAgentListQuery, type PaginationQuery, type PluginI18nImportParams, type PluginI18nImportResponse, type PluginItem, type PluginListResponse, type PluginLocalization, type PluginQueryParams, type PluginUpdateParams, type PluginVersionCreateParams, type PluginVersionUpdateParams, type ProgrammingLanguage, type ReadLocalFileParams, type RefreshConnectionResponse, type RefreshTokenRequest, type RenameLocalFileParams, type ReviewStatus, ReviewStatusEnumSchema, type RevokeConnectionResponse, type RunBuildInToolsError, type RunBuildInToolsRequest, type RunBuildInToolsResponse, type RunBuildInToolsSuccessData, type RunCommandParams, type SearchLocalFilesParams, type SharedTokenState, type SkillCallParams, type SkillErrorResponse, type SkillProviderInfo, type SkillProviderStatus, type SkillTool, StatusEnumSchema, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SuccessResponse, type ToggleLikeResponse, type TrustedClientPayload, type UnclaimedPluginItem, type UpdateUserInfoRequest, type UpdateUserInfoResponse, type UserAgentItem, type UserInfoQuery, type UserInfoResponse, type UserProfile, VisibilityEnumSchema, type WriteLocalFileParams, buildTrustedClientPayload, createTrustedClientToken, generateNonce };
package/dist/index.mjs CHANGED
@@ -5,6 +5,51 @@ import debug9 from "debug";
5
5
  import debug from "debug";
6
6
  import { SignJWT } from "jose";
7
7
  import urlJoin from "url-join";
8
+
9
+ // src/core/MarketAPIError.ts
10
+ var MarketAPIError = class _MarketAPIError extends Error {
11
+ constructor(status, statusText, errorBody) {
12
+ var _a, _b;
13
+ const errorCode = (_a = errorBody == null ? void 0 : errorBody.error) == null ? void 0 : _a.code;
14
+ const errorMessage = (_b = errorBody == null ? void 0 : errorBody.error) == null ? void 0 : _b.message;
15
+ const message = errorMessage || statusText;
16
+ super(message);
17
+ this.name = "MarketAPIError";
18
+ this.status = status;
19
+ this.code = errorCode;
20
+ this.errorBody = errorBody;
21
+ if (Error.captureStackTrace) {
22
+ Error.captureStackTrace(this, _MarketAPIError);
23
+ }
24
+ }
25
+ /**
26
+ * Check if this is a specific error code
27
+ */
28
+ isErrorCode(code) {
29
+ return this.code === code;
30
+ }
31
+ /**
32
+ * Get the full error details from the API response
33
+ */
34
+ getErrorDetails() {
35
+ var _a;
36
+ return (_a = this.errorBody) == null ? void 0 : _a.error;
37
+ }
38
+ /**
39
+ * Convert to a plain object for logging or serialization
40
+ */
41
+ toJSON() {
42
+ return {
43
+ code: this.code,
44
+ errorBody: this.errorBody,
45
+ message: this.message,
46
+ name: this.name,
47
+ status: this.status
48
+ };
49
+ }
50
+ };
51
+
52
+ // src/core/BaseSDK.ts
8
53
  var log = debug("lobe-market-sdk:core");
9
54
  var BaseSDK = class {
10
55
  /**
@@ -78,14 +123,14 @@ var BaseSDK = class {
78
123
  headers: mergedHeaders
79
124
  });
80
125
  if (!response.ok) {
81
- const errorMsg = `Request failed: ${response.status} ${response.statusText}`;
126
+ let errorBody;
82
127
  try {
83
- const errorBody = await response.json();
128
+ errorBody = await response.json();
84
129
  console.error("Request error: %s", JSON.stringify(errorBody));
85
- throw new Error(`${errorMsg} - ${JSON.stringify(errorBody)}`);
86
130
  } catch (e) {
87
- throw new Error(errorMsg);
131
+ errorBody = void 0;
88
132
  }
133
+ throw new MarketAPIError(response.status, response.statusText, errorBody);
89
134
  }
90
135
  log("Request successful: %s", url);
91
136
  if (response.status === 204) {
@@ -3685,6 +3730,7 @@ function buildTrustedClientPayload(params) {
3685
3730
  // src/index.ts
3686
3731
  export * from "@lobehub/market-types";
3687
3732
  export {
3733
+ MarketAPIError,
3688
3734
  MarketAdmin,
3689
3735
  MarketSDK,
3690
3736
  ReviewStatusEnumSchema,