@crosspost/types 0.1.5 → 0.1.6
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 +17 -0
- package/dist/index.d.cts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +16 -0
- package/package.json +1 -1
- package/src/errors/api-error.ts +2 -0
- package/src/errors/composite-api-error.ts +33 -0
- package/src/errors/index.ts +1 -0
package/dist/index.cjs
CHANGED
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
41
41
|
AuthStatusResponseSchema: () => AuthStatusResponseSchema,
|
42
42
|
AuthUrlResponseSchema: () => AuthUrlResponseSchema,
|
43
43
|
BaseError: () => BaseError,
|
44
|
+
CompositeApiError: () => CompositeApiError,
|
44
45
|
ConnectedAccountSchema: () => ConnectedAccountSchema,
|
45
46
|
ConnectedAccountsResponseSchema: () => ConnectedAccountsResponseSchema,
|
46
47
|
CreatePostRequestSchema: () => CreatePostRequestSchema,
|
@@ -312,6 +313,7 @@ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
|
|
312
313
|
ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
|
313
314
|
ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
|
314
315
|
ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
316
|
+
ApiErrorCode2["MULTI_STATUS"] = "MULTI_STATUS";
|
315
317
|
return ApiErrorCode2;
|
316
318
|
})(ApiErrorCode || {});
|
317
319
|
var ApiError = class _ApiError extends BaseError {
|
@@ -411,6 +413,20 @@ var PlatformError = class extends Error {
|
|
411
413
|
}
|
412
414
|
};
|
413
415
|
|
416
|
+
// src/errors/composite-api-error.ts
|
417
|
+
var CompositeApiError = class extends ApiError {
|
418
|
+
constructor(message, errors, status = 207, details, recoverable = false) {
|
419
|
+
super(
|
420
|
+
message,
|
421
|
+
"MULTI_STATUS" /* MULTI_STATUS */,
|
422
|
+
status,
|
423
|
+
{ ...details, errors },
|
424
|
+
recoverable
|
425
|
+
);
|
426
|
+
this.errors = errors;
|
427
|
+
}
|
428
|
+
};
|
429
|
+
|
414
430
|
// src/auth.ts
|
415
431
|
var import_zod3 = require("zod");
|
416
432
|
var PlatformParamSchema = import_zod3.z.object({
|
@@ -910,6 +926,7 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
|
|
910
926
|
AuthStatusResponseSchema,
|
911
927
|
AuthUrlResponseSchema,
|
912
928
|
BaseError,
|
929
|
+
CompositeApiError,
|
913
930
|
ConnectedAccountSchema,
|
914
931
|
ConnectedAccountsResponseSchema,
|
915
932
|
CreatePostRequestSchema,
|
package/dist/index.d.cts
CHANGED
@@ -1003,7 +1003,8 @@ declare enum ApiErrorCode {
|
|
1003
1003
|
THREAD_CREATION_FAILED = "THREAD_CREATION_FAILED",
|
1004
1004
|
POST_DELETION_FAILED = "POST_DELETION_FAILED",
|
1005
1005
|
POST_INTERACTION_FAILED = "POST_INTERACTION_FAILED",
|
1006
|
-
NETWORK_ERROR = "NETWORK_ERROR"
|
1006
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
1007
|
+
MULTI_STATUS = "MULTI_STATUS"
|
1007
1008
|
}
|
1008
1009
|
/**
|
1009
1010
|
* API Error class for application-level errors
|
@@ -1055,6 +1056,19 @@ declare class PlatformError extends Error {
|
|
1055
1056
|
constructor(message: string, platform: PlatformName, code?: ApiErrorCode, recoverable?: boolean, originalError?: unknown | undefined, status?: StatusCode | undefined, userId?: string, details?: Record<string, any>);
|
1056
1057
|
}
|
1057
1058
|
|
1059
|
+
/**
|
1060
|
+
* CompositeApiError represents a collection of multiple errors that occurred during an API operation.
|
1061
|
+
* This is particularly useful for handling multi-status responses (HTTP 207) where multiple operations
|
1062
|
+
* may have different outcomes.
|
1063
|
+
*/
|
1064
|
+
declare class CompositeApiError extends ApiError {
|
1065
|
+
/**
|
1066
|
+
* Array of individual error details
|
1067
|
+
*/
|
1068
|
+
readonly errors: ErrorDetail[];
|
1069
|
+
constructor(message: string, errors: ErrorDetail[], status?: StatusCode, details?: Record<string, any>, recoverable?: boolean);
|
1070
|
+
}
|
1071
|
+
|
1058
1072
|
declare const PlatformParamSchema: z.ZodObject<{
|
1059
1073
|
platform: z.ZodString;
|
1060
1074
|
}, "strip", z.ZodTypeAny, {
|
@@ -7463,4 +7477,4 @@ type UserProfile = z.infer<typeof UserProfileSchema>;
|
|
7463
7477
|
type ProfileRefreshResult = z.infer<typeof ProfileRefreshResultSchema>;
|
7464
7478
|
type ProfileRefreshResponse = z.infer<typeof ProfileRefreshResponseSchema>;
|
7465
7479
|
|
7466
|
-
export { type AccountActivity, type AccountActivityEntry, AccountActivityEntrySchema, type AccountActivityParams, AccountActivityParamsSchema, type AccountActivityQuery, AccountActivityQuerySchema, type AccountActivityResponse, AccountActivityResponseSchema, type AccountPost, AccountPostSchema, type AccountPostsParams, AccountPostsParamsSchema, type AccountPostsQuery, AccountPostsQuerySchema, type AccountPostsResponse, AccountPostsResponseSchema, type ActivityLeaderboardQuery, ActivityLeaderboardQuerySchema, type ActivityLeaderboardResponse, ActivityLeaderboardResponseSchema, type AllRateLimitsResponse, AllRateLimitsResponseSchema, ApiError, ApiErrorCode, type ApiResponse, ApiResponseSchema, type AuthCallbackQuery, AuthCallbackQuerySchema, type AuthCallbackResponse, AuthCallbackResponseSchema, type AuthInitRequest, AuthInitRequestSchema, type AuthRevokeResponse, AuthRevokeResponseSchema, type AuthStatusResponse, AuthStatusResponseSchema, type AuthUrlResponse, AuthUrlResponseSchema, BaseError, type ConnectedAccount, ConnectedAccountSchema, type ConnectedAccountsResponse, ConnectedAccountsResponseSchema, type CreatePostRequest, CreatePostRequestSchema, type CreatePostResponse, CreatePostResponseLegacySchema, CreatePostResponseSchema, type CreatePostTargetError, CreatePostTargetErrorSchema, type CreatePostTargetResult, CreatePostTargetResultSchema, type DeletePostRequest, DeletePostRequestSchema, type DeletePostResponse, DeletePostResponseSchema, type DeleteResult, DeleteResultSchema, type EndpointRateLimitResponse, EndpointRateLimitResponseSchema, type EnhancedApiResponse, type EnhancedErrorResponse, EnhancedErrorResponseSchema, type EnhancedResponseMeta, EnhancedResponseMetaSchema, EnhancedResponseSchema, type ErrorDetail, ErrorDetailSchema, type ErrorResponse, ErrorResponseSchema, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardResponse, type LikePostRequest, LikePostRequestSchema, type LikePostResponse, LikePostResponseSchema, type LikeResult, LikeResultSchema, type Media, type MediaContent, MediaContentSchema, MediaSchema, type MultiStatusResponse, MultiStatusResponseSchema, type NearAuthorizationRequest, NearAuthorizationRequestSchema, type NearAuthorizationResponse, NearAuthorizationResponseSchema, type NearAuthorizationStatusResponse, NearAuthorizationStatusResponseSchema, Platform, type PlatformAccountActivity, type PlatformActivity, PlatformActivitySchema, PlatformError, type PlatformLeaderboardEntry, type PlatformName, type PlatformParam, PlatformParamSchema, type PlatformRateLimit, PlatformRateLimitSchema, PlatformSchema, type Post, type PostContent, PostContentSchema, type PostMetrics, PostMetricsSchema, type PostMultiStatusResponse, PostMultiStatusResponseSchema, type PostRecord, type PostRecordResponse, type PostResponse, PostResponseSchema, type PostResult, PostResultSchema, PostSchema, type PostSuccessDetail, PostSuccessDetailSchema, type PostToDelete, PostToDeleteSchema, type ProfileRefreshResponse, ProfileRefreshResponseSchema, type ProfileRefreshResult, ProfileRefreshResultSchema, type QuotePostRequest, QuotePostRequestSchema, type QuotePostResponse, QuotePostResponseSchema, type RateLimitEndpoint, type RateLimitEndpointParam, RateLimitEndpointParamSchema, RateLimitEndpointSchema, type RateLimitResponse, RateLimitResponseSchema, type RateLimitStatus, type RateLimitStatusResponse, RateLimitStatusResponseSchema, RateLimitStatusSchema, type ReplyToPostRequest, ReplyToPostRequestSchema, type ReplyToPostResponse, ReplyToPostResponseSchema, type RepostRequest, RepostRequestSchema, type RepostResponse, RepostResponseSchema, SUPPORTED_PLATFORMS, type SuccessDetail, SuccessDetailSchema, type SupportedPlatformName, SupportedPlatformSchema, type Target, TargetSchema, TimePeriod, type UnlikePostRequest, UnlikePostRequestSchema, type UnlikePostResponse, UnlikePostResponseSchema, type UsageRateLimit, UsageRateLimitSchema, type UserProfile, UserProfileSchema, createApiResponse, createEnhancedApiResponse, createEnhancedErrorResponse, createErrorDetail, createErrorResponse, createMultiStatusResponse, createSuccessDetail, isPlatformSupported };
|
7480
|
+
export { type AccountActivity, type AccountActivityEntry, AccountActivityEntrySchema, type AccountActivityParams, AccountActivityParamsSchema, type AccountActivityQuery, AccountActivityQuerySchema, type AccountActivityResponse, AccountActivityResponseSchema, type AccountPost, AccountPostSchema, type AccountPostsParams, AccountPostsParamsSchema, type AccountPostsQuery, AccountPostsQuerySchema, type AccountPostsResponse, AccountPostsResponseSchema, type ActivityLeaderboardQuery, ActivityLeaderboardQuerySchema, type ActivityLeaderboardResponse, ActivityLeaderboardResponseSchema, type AllRateLimitsResponse, AllRateLimitsResponseSchema, ApiError, ApiErrorCode, type ApiResponse, ApiResponseSchema, type AuthCallbackQuery, AuthCallbackQuerySchema, type AuthCallbackResponse, AuthCallbackResponseSchema, type AuthInitRequest, AuthInitRequestSchema, type AuthRevokeResponse, AuthRevokeResponseSchema, type AuthStatusResponse, AuthStatusResponseSchema, type AuthUrlResponse, AuthUrlResponseSchema, BaseError, CompositeApiError, type ConnectedAccount, ConnectedAccountSchema, type ConnectedAccountsResponse, ConnectedAccountsResponseSchema, type CreatePostRequest, CreatePostRequestSchema, type CreatePostResponse, CreatePostResponseLegacySchema, CreatePostResponseSchema, type CreatePostTargetError, CreatePostTargetErrorSchema, type CreatePostTargetResult, CreatePostTargetResultSchema, type DeletePostRequest, DeletePostRequestSchema, type DeletePostResponse, DeletePostResponseSchema, type DeleteResult, DeleteResultSchema, type EndpointRateLimitResponse, EndpointRateLimitResponseSchema, type EnhancedApiResponse, type EnhancedErrorResponse, EnhancedErrorResponseSchema, type EnhancedResponseMeta, EnhancedResponseMetaSchema, EnhancedResponseSchema, type ErrorDetail, ErrorDetailSchema, type ErrorResponse, ErrorResponseSchema, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardResponse, type LikePostRequest, LikePostRequestSchema, type LikePostResponse, LikePostResponseSchema, type LikeResult, LikeResultSchema, type Media, type MediaContent, MediaContentSchema, MediaSchema, type MultiStatusResponse, MultiStatusResponseSchema, type NearAuthorizationRequest, NearAuthorizationRequestSchema, type NearAuthorizationResponse, NearAuthorizationResponseSchema, type NearAuthorizationStatusResponse, NearAuthorizationStatusResponseSchema, Platform, type PlatformAccountActivity, type PlatformActivity, PlatformActivitySchema, PlatformError, type PlatformLeaderboardEntry, type PlatformName, type PlatformParam, PlatformParamSchema, type PlatformRateLimit, PlatformRateLimitSchema, PlatformSchema, type Post, type PostContent, PostContentSchema, type PostMetrics, PostMetricsSchema, type PostMultiStatusResponse, PostMultiStatusResponseSchema, type PostRecord, type PostRecordResponse, type PostResponse, PostResponseSchema, type PostResult, PostResultSchema, PostSchema, type PostSuccessDetail, PostSuccessDetailSchema, type PostToDelete, PostToDeleteSchema, type ProfileRefreshResponse, ProfileRefreshResponseSchema, type ProfileRefreshResult, ProfileRefreshResultSchema, type QuotePostRequest, QuotePostRequestSchema, type QuotePostResponse, QuotePostResponseSchema, type RateLimitEndpoint, type RateLimitEndpointParam, RateLimitEndpointParamSchema, RateLimitEndpointSchema, type RateLimitResponse, RateLimitResponseSchema, type RateLimitStatus, type RateLimitStatusResponse, RateLimitStatusResponseSchema, RateLimitStatusSchema, type ReplyToPostRequest, ReplyToPostRequestSchema, type ReplyToPostResponse, ReplyToPostResponseSchema, type RepostRequest, RepostRequestSchema, type RepostResponse, RepostResponseSchema, SUPPORTED_PLATFORMS, type SuccessDetail, SuccessDetailSchema, type SupportedPlatformName, SupportedPlatformSchema, type Target, TargetSchema, TimePeriod, type UnlikePostRequest, UnlikePostRequestSchema, type UnlikePostResponse, UnlikePostResponseSchema, type UsageRateLimit, UsageRateLimitSchema, type UserProfile, UserProfileSchema, createApiResponse, createEnhancedApiResponse, createEnhancedErrorResponse, createErrorDetail, createErrorResponse, createMultiStatusResponse, createSuccessDetail, isPlatformSupported };
|
package/dist/index.d.ts
CHANGED
@@ -1003,7 +1003,8 @@ declare enum ApiErrorCode {
|
|
1003
1003
|
THREAD_CREATION_FAILED = "THREAD_CREATION_FAILED",
|
1004
1004
|
POST_DELETION_FAILED = "POST_DELETION_FAILED",
|
1005
1005
|
POST_INTERACTION_FAILED = "POST_INTERACTION_FAILED",
|
1006
|
-
NETWORK_ERROR = "NETWORK_ERROR"
|
1006
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
1007
|
+
MULTI_STATUS = "MULTI_STATUS"
|
1007
1008
|
}
|
1008
1009
|
/**
|
1009
1010
|
* API Error class for application-level errors
|
@@ -1055,6 +1056,19 @@ declare class PlatformError extends Error {
|
|
1055
1056
|
constructor(message: string, platform: PlatformName, code?: ApiErrorCode, recoverable?: boolean, originalError?: unknown | undefined, status?: StatusCode | undefined, userId?: string, details?: Record<string, any>);
|
1056
1057
|
}
|
1057
1058
|
|
1059
|
+
/**
|
1060
|
+
* CompositeApiError represents a collection of multiple errors that occurred during an API operation.
|
1061
|
+
* This is particularly useful for handling multi-status responses (HTTP 207) where multiple operations
|
1062
|
+
* may have different outcomes.
|
1063
|
+
*/
|
1064
|
+
declare class CompositeApiError extends ApiError {
|
1065
|
+
/**
|
1066
|
+
* Array of individual error details
|
1067
|
+
*/
|
1068
|
+
readonly errors: ErrorDetail[];
|
1069
|
+
constructor(message: string, errors: ErrorDetail[], status?: StatusCode, details?: Record<string, any>, recoverable?: boolean);
|
1070
|
+
}
|
1071
|
+
|
1058
1072
|
declare const PlatformParamSchema: z.ZodObject<{
|
1059
1073
|
platform: z.ZodString;
|
1060
1074
|
}, "strip", z.ZodTypeAny, {
|
@@ -7463,4 +7477,4 @@ type UserProfile = z.infer<typeof UserProfileSchema>;
|
|
7463
7477
|
type ProfileRefreshResult = z.infer<typeof ProfileRefreshResultSchema>;
|
7464
7478
|
type ProfileRefreshResponse = z.infer<typeof ProfileRefreshResponseSchema>;
|
7465
7479
|
|
7466
|
-
export { type AccountActivity, type AccountActivityEntry, AccountActivityEntrySchema, type AccountActivityParams, AccountActivityParamsSchema, type AccountActivityQuery, AccountActivityQuerySchema, type AccountActivityResponse, AccountActivityResponseSchema, type AccountPost, AccountPostSchema, type AccountPostsParams, AccountPostsParamsSchema, type AccountPostsQuery, AccountPostsQuerySchema, type AccountPostsResponse, AccountPostsResponseSchema, type ActivityLeaderboardQuery, ActivityLeaderboardQuerySchema, type ActivityLeaderboardResponse, ActivityLeaderboardResponseSchema, type AllRateLimitsResponse, AllRateLimitsResponseSchema, ApiError, ApiErrorCode, type ApiResponse, ApiResponseSchema, type AuthCallbackQuery, AuthCallbackQuerySchema, type AuthCallbackResponse, AuthCallbackResponseSchema, type AuthInitRequest, AuthInitRequestSchema, type AuthRevokeResponse, AuthRevokeResponseSchema, type AuthStatusResponse, AuthStatusResponseSchema, type AuthUrlResponse, AuthUrlResponseSchema, BaseError, type ConnectedAccount, ConnectedAccountSchema, type ConnectedAccountsResponse, ConnectedAccountsResponseSchema, type CreatePostRequest, CreatePostRequestSchema, type CreatePostResponse, CreatePostResponseLegacySchema, CreatePostResponseSchema, type CreatePostTargetError, CreatePostTargetErrorSchema, type CreatePostTargetResult, CreatePostTargetResultSchema, type DeletePostRequest, DeletePostRequestSchema, type DeletePostResponse, DeletePostResponseSchema, type DeleteResult, DeleteResultSchema, type EndpointRateLimitResponse, EndpointRateLimitResponseSchema, type EnhancedApiResponse, type EnhancedErrorResponse, EnhancedErrorResponseSchema, type EnhancedResponseMeta, EnhancedResponseMetaSchema, EnhancedResponseSchema, type ErrorDetail, ErrorDetailSchema, type ErrorResponse, ErrorResponseSchema, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardResponse, type LikePostRequest, LikePostRequestSchema, type LikePostResponse, LikePostResponseSchema, type LikeResult, LikeResultSchema, type Media, type MediaContent, MediaContentSchema, MediaSchema, type MultiStatusResponse, MultiStatusResponseSchema, type NearAuthorizationRequest, NearAuthorizationRequestSchema, type NearAuthorizationResponse, NearAuthorizationResponseSchema, type NearAuthorizationStatusResponse, NearAuthorizationStatusResponseSchema, Platform, type PlatformAccountActivity, type PlatformActivity, PlatformActivitySchema, PlatformError, type PlatformLeaderboardEntry, type PlatformName, type PlatformParam, PlatformParamSchema, type PlatformRateLimit, PlatformRateLimitSchema, PlatformSchema, type Post, type PostContent, PostContentSchema, type PostMetrics, PostMetricsSchema, type PostMultiStatusResponse, PostMultiStatusResponseSchema, type PostRecord, type PostRecordResponse, type PostResponse, PostResponseSchema, type PostResult, PostResultSchema, PostSchema, type PostSuccessDetail, PostSuccessDetailSchema, type PostToDelete, PostToDeleteSchema, type ProfileRefreshResponse, ProfileRefreshResponseSchema, type ProfileRefreshResult, ProfileRefreshResultSchema, type QuotePostRequest, QuotePostRequestSchema, type QuotePostResponse, QuotePostResponseSchema, type RateLimitEndpoint, type RateLimitEndpointParam, RateLimitEndpointParamSchema, RateLimitEndpointSchema, type RateLimitResponse, RateLimitResponseSchema, type RateLimitStatus, type RateLimitStatusResponse, RateLimitStatusResponseSchema, RateLimitStatusSchema, type ReplyToPostRequest, ReplyToPostRequestSchema, type ReplyToPostResponse, ReplyToPostResponseSchema, type RepostRequest, RepostRequestSchema, type RepostResponse, RepostResponseSchema, SUPPORTED_PLATFORMS, type SuccessDetail, SuccessDetailSchema, type SupportedPlatformName, SupportedPlatformSchema, type Target, TargetSchema, TimePeriod, type UnlikePostRequest, UnlikePostRequestSchema, type UnlikePostResponse, UnlikePostResponseSchema, type UsageRateLimit, UsageRateLimitSchema, type UserProfile, UserProfileSchema, createApiResponse, createEnhancedApiResponse, createEnhancedErrorResponse, createErrorDetail, createErrorResponse, createMultiStatusResponse, createSuccessDetail, isPlatformSupported };
|
7480
|
+
export { type AccountActivity, type AccountActivityEntry, AccountActivityEntrySchema, type AccountActivityParams, AccountActivityParamsSchema, type AccountActivityQuery, AccountActivityQuerySchema, type AccountActivityResponse, AccountActivityResponseSchema, type AccountPost, AccountPostSchema, type AccountPostsParams, AccountPostsParamsSchema, type AccountPostsQuery, AccountPostsQuerySchema, type AccountPostsResponse, AccountPostsResponseSchema, type ActivityLeaderboardQuery, ActivityLeaderboardQuerySchema, type ActivityLeaderboardResponse, ActivityLeaderboardResponseSchema, type AllRateLimitsResponse, AllRateLimitsResponseSchema, ApiError, ApiErrorCode, type ApiResponse, ApiResponseSchema, type AuthCallbackQuery, AuthCallbackQuerySchema, type AuthCallbackResponse, AuthCallbackResponseSchema, type AuthInitRequest, AuthInitRequestSchema, type AuthRevokeResponse, AuthRevokeResponseSchema, type AuthStatusResponse, AuthStatusResponseSchema, type AuthUrlResponse, AuthUrlResponseSchema, BaseError, CompositeApiError, type ConnectedAccount, ConnectedAccountSchema, type ConnectedAccountsResponse, ConnectedAccountsResponseSchema, type CreatePostRequest, CreatePostRequestSchema, type CreatePostResponse, CreatePostResponseLegacySchema, CreatePostResponseSchema, type CreatePostTargetError, CreatePostTargetErrorSchema, type CreatePostTargetResult, CreatePostTargetResultSchema, type DeletePostRequest, DeletePostRequestSchema, type DeletePostResponse, DeletePostResponseSchema, type DeleteResult, DeleteResultSchema, type EndpointRateLimitResponse, EndpointRateLimitResponseSchema, type EnhancedApiResponse, type EnhancedErrorResponse, EnhancedErrorResponseSchema, type EnhancedResponseMeta, EnhancedResponseMetaSchema, EnhancedResponseSchema, type ErrorDetail, ErrorDetailSchema, type ErrorResponse, ErrorResponseSchema, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardResponse, type LikePostRequest, LikePostRequestSchema, type LikePostResponse, LikePostResponseSchema, type LikeResult, LikeResultSchema, type Media, type MediaContent, MediaContentSchema, MediaSchema, type MultiStatusResponse, MultiStatusResponseSchema, type NearAuthorizationRequest, NearAuthorizationRequestSchema, type NearAuthorizationResponse, NearAuthorizationResponseSchema, type NearAuthorizationStatusResponse, NearAuthorizationStatusResponseSchema, Platform, type PlatformAccountActivity, type PlatformActivity, PlatformActivitySchema, PlatformError, type PlatformLeaderboardEntry, type PlatformName, type PlatformParam, PlatformParamSchema, type PlatformRateLimit, PlatformRateLimitSchema, PlatformSchema, type Post, type PostContent, PostContentSchema, type PostMetrics, PostMetricsSchema, type PostMultiStatusResponse, PostMultiStatusResponseSchema, type PostRecord, type PostRecordResponse, type PostResponse, PostResponseSchema, type PostResult, PostResultSchema, PostSchema, type PostSuccessDetail, PostSuccessDetailSchema, type PostToDelete, PostToDeleteSchema, type ProfileRefreshResponse, ProfileRefreshResponseSchema, type ProfileRefreshResult, ProfileRefreshResultSchema, type QuotePostRequest, QuotePostRequestSchema, type QuotePostResponse, QuotePostResponseSchema, type RateLimitEndpoint, type RateLimitEndpointParam, RateLimitEndpointParamSchema, RateLimitEndpointSchema, type RateLimitResponse, RateLimitResponseSchema, type RateLimitStatus, type RateLimitStatusResponse, RateLimitStatusResponseSchema, RateLimitStatusSchema, type ReplyToPostRequest, ReplyToPostRequestSchema, type ReplyToPostResponse, ReplyToPostResponseSchema, type RepostRequest, RepostRequestSchema, type RepostResponse, RepostResponseSchema, SUPPORTED_PLATFORMS, type SuccessDetail, SuccessDetailSchema, type SupportedPlatformName, SupportedPlatformSchema, type Target, TargetSchema, TimePeriod, type UnlikePostRequest, UnlikePostRequestSchema, type UnlikePostResponse, UnlikePostResponseSchema, type UsageRateLimit, UsageRateLimitSchema, type UserProfile, UserProfileSchema, createApiResponse, createEnhancedApiResponse, createEnhancedErrorResponse, createErrorDetail, createErrorResponse, createMultiStatusResponse, createSuccessDetail, isPlatformSupported };
|
package/dist/index.js
CHANGED
@@ -197,6 +197,7 @@ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
|
|
197
197
|
ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
|
198
198
|
ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
|
199
199
|
ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
200
|
+
ApiErrorCode2["MULTI_STATUS"] = "MULTI_STATUS";
|
200
201
|
return ApiErrorCode2;
|
201
202
|
})(ApiErrorCode || {});
|
202
203
|
var ApiError = class _ApiError extends BaseError {
|
@@ -296,6 +297,20 @@ var PlatformError = class extends Error {
|
|
296
297
|
}
|
297
298
|
};
|
298
299
|
|
300
|
+
// src/errors/composite-api-error.ts
|
301
|
+
var CompositeApiError = class extends ApiError {
|
302
|
+
constructor(message, errors, status = 207, details, recoverable = false) {
|
303
|
+
super(
|
304
|
+
message,
|
305
|
+
"MULTI_STATUS" /* MULTI_STATUS */,
|
306
|
+
status,
|
307
|
+
{ ...details, errors },
|
308
|
+
recoverable
|
309
|
+
);
|
310
|
+
this.errors = errors;
|
311
|
+
}
|
312
|
+
};
|
313
|
+
|
299
314
|
// src/auth.ts
|
300
315
|
import { z as z3 } from "zod";
|
301
316
|
var PlatformParamSchema = z3.object({
|
@@ -794,6 +809,7 @@ export {
|
|
794
809
|
AuthStatusResponseSchema,
|
795
810
|
AuthUrlResponseSchema,
|
796
811
|
BaseError,
|
812
|
+
CompositeApiError,
|
797
813
|
ConnectedAccountSchema,
|
798
814
|
ConnectedAccountsResponseSchema,
|
799
815
|
CreatePostRequestSchema,
|
package/package.json
CHANGED
package/src/errors/api-error.ts
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
import { ApiError, ApiErrorCode } from './api-error.ts';
|
2
|
+
import type { ErrorDetail } from '../response.ts';
|
3
|
+
import type { StatusCode } from 'hono/utils/http-status';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* CompositeApiError represents a collection of multiple errors that occurred during an API operation.
|
7
|
+
* This is particularly useful for handling multi-status responses (HTTP 207) where multiple operations
|
8
|
+
* may have different outcomes.
|
9
|
+
*/
|
10
|
+
export class CompositeApiError extends ApiError {
|
11
|
+
/**
|
12
|
+
* Array of individual error details
|
13
|
+
*/
|
14
|
+
readonly errors: ErrorDetail[];
|
15
|
+
|
16
|
+
constructor(
|
17
|
+
message: string,
|
18
|
+
errors: ErrorDetail[],
|
19
|
+
status: StatusCode = 207,
|
20
|
+
details?: Record<string, any>,
|
21
|
+
recoverable: boolean = false,
|
22
|
+
) {
|
23
|
+
super(
|
24
|
+
message,
|
25
|
+
ApiErrorCode.MULTI_STATUS,
|
26
|
+
status,
|
27
|
+
{ ...details, errors },
|
28
|
+
recoverable,
|
29
|
+
);
|
30
|
+
|
31
|
+
this.errors = errors;
|
32
|
+
}
|
33
|
+
}
|
package/src/errors/index.ts
CHANGED