@crosspost/types 0.1.4 → 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 +26 -9
- package/dist/index.d.cts +37 -23
- package/dist/index.d.ts +37 -23
- package/dist/index.js +25 -9
- package/package.json +1 -1
- package/src/activity.ts +9 -9
- 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/src/leaderboard.ts +0 -179
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({
|
@@ -759,15 +775,15 @@ var EndpointRateLimitResponseSchema = import_zod5.z.object({
|
|
759
775
|
// src/activity.ts
|
760
776
|
var import_zod6 = require("zod");
|
761
777
|
var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
|
762
|
-
TimePeriod2["
|
763
|
-
TimePeriod2["YEARLY"] = "
|
764
|
-
TimePeriod2["MONTHLY"] = "
|
765
|
-
TimePeriod2["WEEKLY"] = "
|
766
|
-
TimePeriod2["DAILY"] = "
|
778
|
+
TimePeriod2["ALL"] = "all";
|
779
|
+
TimePeriod2["YEARLY"] = "year";
|
780
|
+
TimePeriod2["MONTHLY"] = "month";
|
781
|
+
TimePeriod2["WEEKLY"] = "week";
|
782
|
+
TimePeriod2["DAILY"] = "day";
|
767
783
|
return TimePeriod2;
|
768
784
|
})(TimePeriod || {});
|
769
785
|
var ActivityLeaderboardQuerySchema = import_zod6.z.object({
|
770
|
-
timeframe: import_zod6.z.
|
786
|
+
timeframe: import_zod6.z.nativeEnum(TimePeriod).optional().describe(
|
771
787
|
"Timeframe for the leaderboard"
|
772
788
|
),
|
773
789
|
limit: import_zod6.z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(import_zod6.z.number().min(1).max(100).optional()).describe("Maximum number of results to return (1-100)"),
|
@@ -786,7 +802,7 @@ var AccountActivityEntrySchema = import_zod6.z.object({
|
|
786
802
|
}).describe("Account activity entry");
|
787
803
|
var ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
|
788
804
|
import_zod6.z.object({
|
789
|
-
timeframe: import_zod6.z.
|
805
|
+
timeframe: import_zod6.z.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
|
790
806
|
entries: import_zod6.z.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
|
791
807
|
total: import_zod6.z.number().describe("Total number of entries in the leaderboard"),
|
792
808
|
limit: import_zod6.z.number().describe("Maximum number of results returned"),
|
@@ -798,7 +814,7 @@ var AccountActivityParamsSchema = import_zod6.z.object({
|
|
798
814
|
signerId: import_zod6.z.string().describe("NEAR account ID")
|
799
815
|
}).describe("Account activity params");
|
800
816
|
var AccountActivityQuerySchema = import_zod6.z.object({
|
801
|
-
timeframe: import_zod6.z.
|
817
|
+
timeframe: import_zod6.z.nativeEnum(TimePeriod).optional().describe(
|
802
818
|
"Timeframe for the activity"
|
803
819
|
)
|
804
820
|
}).describe("Account activity query");
|
@@ -815,7 +831,7 @@ var PlatformActivitySchema = import_zod6.z.object({
|
|
815
831
|
var AccountActivityResponseSchema = EnhancedResponseSchema(
|
816
832
|
import_zod6.z.object({
|
817
833
|
signerId: import_zod6.z.string().describe("NEAR account ID"),
|
818
|
-
timeframe: import_zod6.z.
|
834
|
+
timeframe: import_zod6.z.nativeEnum(TimePeriod).describe("Timeframe for the activity"),
|
819
835
|
totalPosts: import_zod6.z.number().describe("Total number of posts across all platforms"),
|
820
836
|
totalLikes: import_zod6.z.number().describe("Total number of likes across all platforms"),
|
821
837
|
totalReposts: import_zod6.z.number().describe("Total number of reposts across all platforms"),
|
@@ -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, {
|
@@ -6188,26 +6202,26 @@ type EndpointRateLimitResponse = z.infer<typeof EndpointRateLimitResponseSchema>
|
|
6188
6202
|
* Time periods for activity filtering
|
6189
6203
|
*/
|
6190
6204
|
declare enum TimePeriod {
|
6191
|
-
|
6192
|
-
YEARLY = "
|
6193
|
-
MONTHLY = "
|
6194
|
-
WEEKLY = "
|
6195
|
-
DAILY = "
|
6205
|
+
ALL = "all",
|
6206
|
+
YEARLY = "year",
|
6207
|
+
MONTHLY = "month",
|
6208
|
+
WEEKLY = "week",
|
6209
|
+
DAILY = "day"
|
6196
6210
|
}
|
6197
6211
|
/**
|
6198
6212
|
* Activity leaderboard query schema
|
6199
6213
|
*/
|
6200
6214
|
declare const ActivityLeaderboardQuerySchema: z.ZodObject<{
|
6201
|
-
timeframe: z.ZodOptional<z.
|
6215
|
+
timeframe: z.ZodOptional<z.ZodNativeEnum<typeof TimePeriod>>;
|
6202
6216
|
limit: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number | undefined, string | undefined>, z.ZodOptional<z.ZodNumber>>;
|
6203
6217
|
offset: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number | undefined, string | undefined>, z.ZodOptional<z.ZodNumber>>;
|
6204
6218
|
}, "strip", z.ZodTypeAny, {
|
6205
6219
|
limit?: number | undefined;
|
6206
|
-
timeframe?:
|
6220
|
+
timeframe?: TimePeriod | undefined;
|
6207
6221
|
offset?: number | undefined;
|
6208
6222
|
}, {
|
6209
6223
|
limit?: string | undefined;
|
6210
|
-
timeframe?:
|
6224
|
+
timeframe?: TimePeriod | undefined;
|
6211
6225
|
offset?: string | undefined;
|
6212
6226
|
}>;
|
6213
6227
|
/**
|
@@ -6250,7 +6264,7 @@ declare const AccountActivityEntrySchema: z.ZodObject<{
|
|
6250
6264
|
declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
6251
6265
|
success: z.ZodBoolean;
|
6252
6266
|
data: z.ZodObject<{
|
6253
|
-
timeframe: z.
|
6267
|
+
timeframe: z.ZodNativeEnum<typeof TimePeriod>;
|
6254
6268
|
entries: z.ZodArray<z.ZodObject<{
|
6255
6269
|
signerId: z.ZodString;
|
6256
6270
|
totalPosts: z.ZodNumber;
|
@@ -6300,7 +6314,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6300
6314
|
lastActive: string;
|
6301
6315
|
}[];
|
6302
6316
|
total: number;
|
6303
|
-
timeframe:
|
6317
|
+
timeframe: TimePeriod;
|
6304
6318
|
offset: number;
|
6305
6319
|
generatedAt: string;
|
6306
6320
|
}, {
|
@@ -6317,7 +6331,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6317
6331
|
lastActive: string;
|
6318
6332
|
}[];
|
6319
6333
|
total: number;
|
6320
|
-
timeframe:
|
6334
|
+
timeframe: TimePeriod;
|
6321
6335
|
offset: number;
|
6322
6336
|
generatedAt: string;
|
6323
6337
|
}>;
|
@@ -6407,7 +6421,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6407
6421
|
lastActive: string;
|
6408
6422
|
}[];
|
6409
6423
|
total: number;
|
6410
|
-
timeframe:
|
6424
|
+
timeframe: TimePeriod;
|
6411
6425
|
offset: number;
|
6412
6426
|
generatedAt: string;
|
6413
6427
|
};
|
@@ -6444,7 +6458,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6444
6458
|
lastActive: string;
|
6445
6459
|
}[];
|
6446
6460
|
total: number;
|
6447
|
-
timeframe:
|
6461
|
+
timeframe: TimePeriod;
|
6448
6462
|
offset: number;
|
6449
6463
|
generatedAt: string;
|
6450
6464
|
};
|
@@ -6481,11 +6495,11 @@ declare const AccountActivityParamsSchema: z.ZodObject<{
|
|
6481
6495
|
* Account activity query schema
|
6482
6496
|
*/
|
6483
6497
|
declare const AccountActivityQuerySchema: z.ZodObject<{
|
6484
|
-
timeframe: z.ZodOptional<z.
|
6498
|
+
timeframe: z.ZodOptional<z.ZodNativeEnum<typeof TimePeriod>>;
|
6485
6499
|
}, "strip", z.ZodTypeAny, {
|
6486
|
-
timeframe?:
|
6500
|
+
timeframe?: TimePeriod | undefined;
|
6487
6501
|
}, {
|
6488
|
-
timeframe?:
|
6502
|
+
timeframe?: TimePeriod | undefined;
|
6489
6503
|
}>;
|
6490
6504
|
/**
|
6491
6505
|
* Platform activity schema
|
@@ -6525,7 +6539,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6525
6539
|
success: z.ZodBoolean;
|
6526
6540
|
data: z.ZodObject<{
|
6527
6541
|
signerId: z.ZodString;
|
6528
|
-
timeframe: z.
|
6542
|
+
timeframe: z.ZodNativeEnum<typeof TimePeriod>;
|
6529
6543
|
totalPosts: z.ZodNumber;
|
6530
6544
|
totalLikes: z.ZodNumber;
|
6531
6545
|
totalReposts: z.ZodNumber;
|
@@ -6574,7 +6588,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6574
6588
|
score: number;
|
6575
6589
|
}[];
|
6576
6590
|
signerId: string;
|
6577
|
-
timeframe:
|
6591
|
+
timeframe: TimePeriod;
|
6578
6592
|
totalPosts: number;
|
6579
6593
|
totalLikes: number;
|
6580
6594
|
totalReposts: number;
|
@@ -6595,7 +6609,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6595
6609
|
score: number;
|
6596
6610
|
}[];
|
6597
6611
|
signerId: string;
|
6598
|
-
timeframe:
|
6612
|
+
timeframe: TimePeriod;
|
6599
6613
|
totalPosts: number;
|
6600
6614
|
totalLikes: number;
|
6601
6615
|
totalReposts: number;
|
@@ -6689,7 +6703,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6689
6703
|
score: number;
|
6690
6704
|
}[];
|
6691
6705
|
signerId: string;
|
6692
|
-
timeframe:
|
6706
|
+
timeframe: TimePeriod;
|
6693
6707
|
totalPosts: number;
|
6694
6708
|
totalLikes: number;
|
6695
6709
|
totalReposts: number;
|
@@ -6730,7 +6744,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6730
6744
|
score: number;
|
6731
6745
|
}[];
|
6732
6746
|
signerId: string;
|
6733
|
-
timeframe:
|
6747
|
+
timeframe: TimePeriod;
|
6734
6748
|
totalPosts: number;
|
6735
6749
|
totalLikes: number;
|
6736
6750
|
totalReposts: number;
|
@@ -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, {
|
@@ -6188,26 +6202,26 @@ type EndpointRateLimitResponse = z.infer<typeof EndpointRateLimitResponseSchema>
|
|
6188
6202
|
* Time periods for activity filtering
|
6189
6203
|
*/
|
6190
6204
|
declare enum TimePeriod {
|
6191
|
-
|
6192
|
-
YEARLY = "
|
6193
|
-
MONTHLY = "
|
6194
|
-
WEEKLY = "
|
6195
|
-
DAILY = "
|
6205
|
+
ALL = "all",
|
6206
|
+
YEARLY = "year",
|
6207
|
+
MONTHLY = "month",
|
6208
|
+
WEEKLY = "week",
|
6209
|
+
DAILY = "day"
|
6196
6210
|
}
|
6197
6211
|
/**
|
6198
6212
|
* Activity leaderboard query schema
|
6199
6213
|
*/
|
6200
6214
|
declare const ActivityLeaderboardQuerySchema: z.ZodObject<{
|
6201
|
-
timeframe: z.ZodOptional<z.
|
6215
|
+
timeframe: z.ZodOptional<z.ZodNativeEnum<typeof TimePeriod>>;
|
6202
6216
|
limit: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number | undefined, string | undefined>, z.ZodOptional<z.ZodNumber>>;
|
6203
6217
|
offset: z.ZodPipeline<z.ZodEffects<z.ZodOptional<z.ZodString>, number | undefined, string | undefined>, z.ZodOptional<z.ZodNumber>>;
|
6204
6218
|
}, "strip", z.ZodTypeAny, {
|
6205
6219
|
limit?: number | undefined;
|
6206
|
-
timeframe?:
|
6220
|
+
timeframe?: TimePeriod | undefined;
|
6207
6221
|
offset?: number | undefined;
|
6208
6222
|
}, {
|
6209
6223
|
limit?: string | undefined;
|
6210
|
-
timeframe?:
|
6224
|
+
timeframe?: TimePeriod | undefined;
|
6211
6225
|
offset?: string | undefined;
|
6212
6226
|
}>;
|
6213
6227
|
/**
|
@@ -6250,7 +6264,7 @@ declare const AccountActivityEntrySchema: z.ZodObject<{
|
|
6250
6264
|
declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
6251
6265
|
success: z.ZodBoolean;
|
6252
6266
|
data: z.ZodObject<{
|
6253
|
-
timeframe: z.
|
6267
|
+
timeframe: z.ZodNativeEnum<typeof TimePeriod>;
|
6254
6268
|
entries: z.ZodArray<z.ZodObject<{
|
6255
6269
|
signerId: z.ZodString;
|
6256
6270
|
totalPosts: z.ZodNumber;
|
@@ -6300,7 +6314,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6300
6314
|
lastActive: string;
|
6301
6315
|
}[];
|
6302
6316
|
total: number;
|
6303
|
-
timeframe:
|
6317
|
+
timeframe: TimePeriod;
|
6304
6318
|
offset: number;
|
6305
6319
|
generatedAt: string;
|
6306
6320
|
}, {
|
@@ -6317,7 +6331,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6317
6331
|
lastActive: string;
|
6318
6332
|
}[];
|
6319
6333
|
total: number;
|
6320
|
-
timeframe:
|
6334
|
+
timeframe: TimePeriod;
|
6321
6335
|
offset: number;
|
6322
6336
|
generatedAt: string;
|
6323
6337
|
}>;
|
@@ -6407,7 +6421,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6407
6421
|
lastActive: string;
|
6408
6422
|
}[];
|
6409
6423
|
total: number;
|
6410
|
-
timeframe:
|
6424
|
+
timeframe: TimePeriod;
|
6411
6425
|
offset: number;
|
6412
6426
|
generatedAt: string;
|
6413
6427
|
};
|
@@ -6444,7 +6458,7 @@ declare const ActivityLeaderboardResponseSchema: z.ZodObject<{
|
|
6444
6458
|
lastActive: string;
|
6445
6459
|
}[];
|
6446
6460
|
total: number;
|
6447
|
-
timeframe:
|
6461
|
+
timeframe: TimePeriod;
|
6448
6462
|
offset: number;
|
6449
6463
|
generatedAt: string;
|
6450
6464
|
};
|
@@ -6481,11 +6495,11 @@ declare const AccountActivityParamsSchema: z.ZodObject<{
|
|
6481
6495
|
* Account activity query schema
|
6482
6496
|
*/
|
6483
6497
|
declare const AccountActivityQuerySchema: z.ZodObject<{
|
6484
|
-
timeframe: z.ZodOptional<z.
|
6498
|
+
timeframe: z.ZodOptional<z.ZodNativeEnum<typeof TimePeriod>>;
|
6485
6499
|
}, "strip", z.ZodTypeAny, {
|
6486
|
-
timeframe?:
|
6500
|
+
timeframe?: TimePeriod | undefined;
|
6487
6501
|
}, {
|
6488
|
-
timeframe?:
|
6502
|
+
timeframe?: TimePeriod | undefined;
|
6489
6503
|
}>;
|
6490
6504
|
/**
|
6491
6505
|
* Platform activity schema
|
@@ -6525,7 +6539,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6525
6539
|
success: z.ZodBoolean;
|
6526
6540
|
data: z.ZodObject<{
|
6527
6541
|
signerId: z.ZodString;
|
6528
|
-
timeframe: z.
|
6542
|
+
timeframe: z.ZodNativeEnum<typeof TimePeriod>;
|
6529
6543
|
totalPosts: z.ZodNumber;
|
6530
6544
|
totalLikes: z.ZodNumber;
|
6531
6545
|
totalReposts: z.ZodNumber;
|
@@ -6574,7 +6588,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6574
6588
|
score: number;
|
6575
6589
|
}[];
|
6576
6590
|
signerId: string;
|
6577
|
-
timeframe:
|
6591
|
+
timeframe: TimePeriod;
|
6578
6592
|
totalPosts: number;
|
6579
6593
|
totalLikes: number;
|
6580
6594
|
totalReposts: number;
|
@@ -6595,7 +6609,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6595
6609
|
score: number;
|
6596
6610
|
}[];
|
6597
6611
|
signerId: string;
|
6598
|
-
timeframe:
|
6612
|
+
timeframe: TimePeriod;
|
6599
6613
|
totalPosts: number;
|
6600
6614
|
totalLikes: number;
|
6601
6615
|
totalReposts: number;
|
@@ -6689,7 +6703,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6689
6703
|
score: number;
|
6690
6704
|
}[];
|
6691
6705
|
signerId: string;
|
6692
|
-
timeframe:
|
6706
|
+
timeframe: TimePeriod;
|
6693
6707
|
totalPosts: number;
|
6694
6708
|
totalLikes: number;
|
6695
6709
|
totalReposts: number;
|
@@ -6730,7 +6744,7 @@ declare const AccountActivityResponseSchema: z.ZodObject<{
|
|
6730
6744
|
score: number;
|
6731
6745
|
}[];
|
6732
6746
|
signerId: string;
|
6733
|
-
timeframe:
|
6747
|
+
timeframe: TimePeriod;
|
6734
6748
|
totalPosts: number;
|
6735
6749
|
totalLikes: number;
|
6736
6750
|
totalReposts: number;
|
@@ -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({
|
@@ -644,15 +659,15 @@ var EndpointRateLimitResponseSchema = z5.object({
|
|
644
659
|
// src/activity.ts
|
645
660
|
import { z as z6 } from "zod";
|
646
661
|
var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
|
647
|
-
TimePeriod2["
|
648
|
-
TimePeriod2["YEARLY"] = "
|
649
|
-
TimePeriod2["MONTHLY"] = "
|
650
|
-
TimePeriod2["WEEKLY"] = "
|
651
|
-
TimePeriod2["DAILY"] = "
|
662
|
+
TimePeriod2["ALL"] = "all";
|
663
|
+
TimePeriod2["YEARLY"] = "year";
|
664
|
+
TimePeriod2["MONTHLY"] = "month";
|
665
|
+
TimePeriod2["WEEKLY"] = "week";
|
666
|
+
TimePeriod2["DAILY"] = "day";
|
652
667
|
return TimePeriod2;
|
653
668
|
})(TimePeriod || {});
|
654
669
|
var ActivityLeaderboardQuerySchema = z6.object({
|
655
|
-
timeframe: z6.
|
670
|
+
timeframe: z6.nativeEnum(TimePeriod).optional().describe(
|
656
671
|
"Timeframe for the leaderboard"
|
657
672
|
),
|
658
673
|
limit: z6.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z6.number().min(1).max(100).optional()).describe("Maximum number of results to return (1-100)"),
|
@@ -671,7 +686,7 @@ var AccountActivityEntrySchema = z6.object({
|
|
671
686
|
}).describe("Account activity entry");
|
672
687
|
var ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
|
673
688
|
z6.object({
|
674
|
-
timeframe: z6.
|
689
|
+
timeframe: z6.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
|
675
690
|
entries: z6.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
|
676
691
|
total: z6.number().describe("Total number of entries in the leaderboard"),
|
677
692
|
limit: z6.number().describe("Maximum number of results returned"),
|
@@ -683,7 +698,7 @@ var AccountActivityParamsSchema = z6.object({
|
|
683
698
|
signerId: z6.string().describe("NEAR account ID")
|
684
699
|
}).describe("Account activity params");
|
685
700
|
var AccountActivityQuerySchema = z6.object({
|
686
|
-
timeframe: z6.
|
701
|
+
timeframe: z6.nativeEnum(TimePeriod).optional().describe(
|
687
702
|
"Timeframe for the activity"
|
688
703
|
)
|
689
704
|
}).describe("Account activity query");
|
@@ -700,7 +715,7 @@ var PlatformActivitySchema = z6.object({
|
|
700
715
|
var AccountActivityResponseSchema = EnhancedResponseSchema(
|
701
716
|
z6.object({
|
702
717
|
signerId: z6.string().describe("NEAR account ID"),
|
703
|
-
timeframe: z6.
|
718
|
+
timeframe: z6.nativeEnum(TimePeriod).describe("Timeframe for the activity"),
|
704
719
|
totalPosts: z6.number().describe("Total number of posts across all platforms"),
|
705
720
|
totalLikes: z6.number().describe("Total number of likes across all platforms"),
|
706
721
|
totalReposts: z6.number().describe("Total number of reposts across all platforms"),
|
@@ -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/activity.ts
CHANGED
@@ -12,18 +12,18 @@ import { PlatformSchema } from './common.ts';
|
|
12
12
|
* Time periods for activity filtering
|
13
13
|
*/
|
14
14
|
export enum TimePeriod {
|
15
|
-
|
16
|
-
YEARLY = '
|
17
|
-
MONTHLY = '
|
18
|
-
WEEKLY = '
|
19
|
-
DAILY = '
|
15
|
+
ALL = 'all',
|
16
|
+
YEARLY = 'year',
|
17
|
+
MONTHLY = 'month',
|
18
|
+
WEEKLY = 'week',
|
19
|
+
DAILY = 'day',
|
20
20
|
}
|
21
21
|
|
22
22
|
/**
|
23
23
|
* Activity leaderboard query schema
|
24
24
|
*/
|
25
25
|
export const ActivityLeaderboardQuerySchema = z.object({
|
26
|
-
timeframe: z.
|
26
|
+
timeframe: z.nativeEnum(TimePeriod).optional().describe(
|
27
27
|
'Timeframe for the leaderboard',
|
28
28
|
),
|
29
29
|
limit: z.string().optional()
|
@@ -56,7 +56,7 @@ export const AccountActivityEntrySchema = z.object({
|
|
56
56
|
*/
|
57
57
|
export const ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
|
58
58
|
z.object({
|
59
|
-
timeframe: z.
|
59
|
+
timeframe: z.nativeEnum(TimePeriod).describe('Timeframe for the leaderboard'),
|
60
60
|
entries: z.array(AccountActivityEntrySchema).describe('Leaderboard entries'),
|
61
61
|
total: z.number().describe('Total number of entries in the leaderboard'),
|
62
62
|
limit: z.number().describe('Maximum number of results returned'),
|
@@ -76,7 +76,7 @@ export const AccountActivityParamsSchema = z.object({
|
|
76
76
|
* Account activity query schema
|
77
77
|
*/
|
78
78
|
export const AccountActivityQuerySchema = z.object({
|
79
|
-
timeframe: z.
|
79
|
+
timeframe: z.nativeEnum(TimePeriod).optional().describe(
|
80
80
|
'Timeframe for the activity',
|
81
81
|
),
|
82
82
|
}).describe('Account activity query');
|
@@ -101,7 +101,7 @@ export const PlatformActivitySchema = z.object({
|
|
101
101
|
export const AccountActivityResponseSchema = EnhancedResponseSchema(
|
102
102
|
z.object({
|
103
103
|
signerId: z.string().describe('NEAR account ID'),
|
104
|
-
timeframe: z.
|
104
|
+
timeframe: z.nativeEnum(TimePeriod).describe('Timeframe for the activity'),
|
105
105
|
totalPosts: z.number().describe('Total number of posts across all platforms'),
|
106
106
|
totalLikes: z.number().describe('Total number of likes across all platforms'),
|
107
107
|
totalReposts: z.number().describe('Total number of reposts across all platforms'),
|
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
package/src/leaderboard.ts
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Leaderboard Schemas and Types
|
3
|
-
* Defines Zod schemas for leaderboard-related requests and responses
|
4
|
-
* TypeScript types are derived from Zod schemas for type safety
|
5
|
-
*/
|
6
|
-
|
7
|
-
import { z } from 'zod';
|
8
|
-
import { EnhancedResponseSchema } from './response.ts';
|
9
|
-
import { PlatformSchema } from './common.ts';
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Leaderboard query schema
|
13
|
-
*/
|
14
|
-
export const LeaderboardQuerySchema = z.object({
|
15
|
-
timeframe: z.enum(['day', 'week', 'month', 'all']).optional().describe(
|
16
|
-
'Timeframe for the leaderboard',
|
17
|
-
),
|
18
|
-
limit: z.string().optional()
|
19
|
-
.transform((val) => val ? parseInt(val, 10) : undefined)
|
20
|
-
.pipe(z.number().min(1).max(100).optional())
|
21
|
-
.describe('Maximum number of results to return (1-100)'),
|
22
|
-
offset: z.string().optional()
|
23
|
-
.transform((val) => val ? parseInt(val, 10) : undefined)
|
24
|
-
.pipe(z.number().min(0).optional())
|
25
|
-
.describe('Offset for pagination'),
|
26
|
-
}).describe('Leaderboard query');
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Account activity entry schema
|
30
|
-
*/
|
31
|
-
export const AccountActivityEntrySchema = z.object({
|
32
|
-
signerId: z.string().describe('NEAR account ID'),
|
33
|
-
totalPosts: z.number().describe('Total number of posts'),
|
34
|
-
totalLikes: z.number().describe('Total number of likes'),
|
35
|
-
totalReposts: z.number().describe('Total number of reposts'),
|
36
|
-
totalReplies: z.number().describe('Total number of replies'),
|
37
|
-
totalQuotes: z.number().describe('Total number of quote posts'),
|
38
|
-
totalScore: z.number().describe('Total activity score'),
|
39
|
-
rank: z.number().describe('Rank on the leaderboard'),
|
40
|
-
lastActive: z.string().datetime().describe('Timestamp of last activity'),
|
41
|
-
}).describe('Account activity entry');
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Leaderboard response schema
|
45
|
-
*/
|
46
|
-
export const LeaderboardResponseSchema = EnhancedResponseSchema(
|
47
|
-
z.object({
|
48
|
-
timeframe: z.enum(['day', 'week', 'month', 'all']).describe('Timeframe for the leaderboard'),
|
49
|
-
entries: z.array(AccountActivityEntrySchema).describe('Leaderboard entries'),
|
50
|
-
total: z.number().describe('Total number of entries in the leaderboard'),
|
51
|
-
limit: z.number().describe('Maximum number of results returned'),
|
52
|
-
offset: z.number().describe('Offset for pagination'),
|
53
|
-
generatedAt: z.string().datetime().describe('Timestamp when the leaderboard was generated'),
|
54
|
-
}),
|
55
|
-
).describe('Leaderboard response');
|
56
|
-
|
57
|
-
/**
|
58
|
-
* Account activity params schema
|
59
|
-
*/
|
60
|
-
export const AccountActivityParamsSchema = z.object({
|
61
|
-
signerId: z.string().describe('NEAR account ID'),
|
62
|
-
}).describe('Account activity params');
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Account activity query schema
|
66
|
-
*/
|
67
|
-
export const AccountActivityQuerySchema = z.object({
|
68
|
-
timeframe: z.enum(['day', 'week', 'month', 'all']).optional().describe(
|
69
|
-
'Timeframe for the activity',
|
70
|
-
),
|
71
|
-
}).describe('Account activity query');
|
72
|
-
|
73
|
-
/**
|
74
|
-
* Platform activity schema
|
75
|
-
*/
|
76
|
-
export const PlatformActivitySchema = z.object({
|
77
|
-
platform: PlatformSchema,
|
78
|
-
posts: z.number().describe('Number of posts on this platform'),
|
79
|
-
likes: z.number().describe('Number of likes on this platform'),
|
80
|
-
reposts: z.number().describe('Number of reposts on this platform'),
|
81
|
-
replies: z.number().describe('Number of replies on this platform'),
|
82
|
-
quotes: z.number().describe('Number of quote posts on this platform'),
|
83
|
-
score: z.number().describe('Activity score on this platform'),
|
84
|
-
lastActive: z.string().datetime().describe('Timestamp of last activity on this platform'),
|
85
|
-
}).describe('Platform activity');
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Account activity response schema
|
89
|
-
*/
|
90
|
-
export const AccountActivityResponseSchema = EnhancedResponseSchema(
|
91
|
-
z.object({
|
92
|
-
signerId: z.string().describe('NEAR account ID'),
|
93
|
-
timeframe: z.enum(['day', 'week', 'month', 'all']).describe('Timeframe for the activity'),
|
94
|
-
totalPosts: z.number().describe('Total number of posts across all platforms'),
|
95
|
-
totalLikes: z.number().describe('Total number of likes across all platforms'),
|
96
|
-
totalReposts: z.number().describe('Total number of reposts across all platforms'),
|
97
|
-
totalReplies: z.number().describe('Total number of replies across all platforms'),
|
98
|
-
totalQuotes: z.number().describe('Total number of quote posts across all platforms'),
|
99
|
-
totalScore: z.number().describe('Total activity score across all platforms'),
|
100
|
-
rank: z.number().describe('Rank on the leaderboard'),
|
101
|
-
lastActive: z.string().datetime().describe('Timestamp of last activity across all platforms'),
|
102
|
-
platforms: z.array(PlatformActivitySchema).describe('Activity breakdown by platform'),
|
103
|
-
}),
|
104
|
-
).describe('Account activity response');
|
105
|
-
|
106
|
-
/**
|
107
|
-
* Account posts params schema
|
108
|
-
*/
|
109
|
-
export const AccountPostsParamsSchema = z.object({
|
110
|
-
signerId: z.string().describe('NEAR account ID'),
|
111
|
-
}).describe('Account posts params');
|
112
|
-
|
113
|
-
/**
|
114
|
-
* Account posts query schema
|
115
|
-
*/
|
116
|
-
export const AccountPostsQuerySchema = z.object({
|
117
|
-
platform: z.string().optional().describe('Filter by platform (optional)'),
|
118
|
-
limit: z.string().optional()
|
119
|
-
.transform((val) => val ? parseInt(val, 10) : undefined)
|
120
|
-
.pipe(z.number().min(1).max(100).optional())
|
121
|
-
.describe('Maximum number of results to return (1-100)'),
|
122
|
-
offset: z.string().optional()
|
123
|
-
.transform((val) => val ? parseInt(val, 10) : undefined)
|
124
|
-
.pipe(z.number().min(0).optional())
|
125
|
-
.describe('Offset for pagination'),
|
126
|
-
type: z.enum(['post', 'repost', 'reply', 'quote', 'like', 'all']).optional().describe(
|
127
|
-
'Filter by post type (optional)',
|
128
|
-
),
|
129
|
-
}).describe('Account posts query');
|
130
|
-
|
131
|
-
/**
|
132
|
-
* Account post schema
|
133
|
-
*/
|
134
|
-
export const AccountPostSchema = z.object({
|
135
|
-
id: z.string().describe('Post ID'),
|
136
|
-
platform: PlatformSchema,
|
137
|
-
type: z.enum(['post', 'repost', 'reply', 'quote', 'like']).describe('Type of post'),
|
138
|
-
content: z.string().optional().describe('Post content (if available)'),
|
139
|
-
url: z.string().url().optional().describe('URL to the post on the platform (if available)'),
|
140
|
-
createdAt: z.string().datetime().describe('Timestamp when the post was created'),
|
141
|
-
metrics: z.object({
|
142
|
-
likes: z.number().optional().describe('Number of likes (if available)'),
|
143
|
-
reposts: z.number().optional().describe('Number of reposts (if available)'),
|
144
|
-
replies: z.number().optional().describe('Number of replies (if available)'),
|
145
|
-
quotes: z.number().optional().describe('Number of quotes (if available)'),
|
146
|
-
}).optional().describe('Post metrics (if available)'),
|
147
|
-
inReplyToId: z.string().optional().describe('ID of the post this is a reply to (if applicable)'),
|
148
|
-
quotedPostId: z.string().optional().describe('ID of the post this is quoting (if applicable)'),
|
149
|
-
}).describe('Account post');
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Account posts response schema
|
153
|
-
*/
|
154
|
-
export const AccountPostsResponseSchema = EnhancedResponseSchema(
|
155
|
-
z.object({
|
156
|
-
signerId: z.string().describe('NEAR account ID'),
|
157
|
-
posts: z.array(AccountPostSchema).describe('List of posts'),
|
158
|
-
total: z.number().describe('Total number of posts matching the query'),
|
159
|
-
limit: z.number().describe('Maximum number of results returned'),
|
160
|
-
offset: z.number().describe('Offset for pagination'),
|
161
|
-
platform: z.string().optional().describe('Platform filter (if applied)'),
|
162
|
-
type: z.enum(['post', 'repost', 'reply', 'quote', 'like', 'all']).optional().describe(
|
163
|
-
'Post type filter (if applied)',
|
164
|
-
),
|
165
|
-
}),
|
166
|
-
).describe('Account posts response');
|
167
|
-
|
168
|
-
// Derive TypeScript types from Zod schemas
|
169
|
-
export type LeaderboardQuery = z.infer<typeof LeaderboardQuerySchema>;
|
170
|
-
export type AccountActivityEntry = z.infer<typeof AccountActivityEntrySchema>;
|
171
|
-
export type LeaderboardResponse = z.infer<typeof LeaderboardResponseSchema>;
|
172
|
-
export type AccountActivityParams = z.infer<typeof AccountActivityParamsSchema>;
|
173
|
-
export type AccountActivityQuery = z.infer<typeof AccountActivityQuerySchema>;
|
174
|
-
export type PlatformActivity = z.infer<typeof PlatformActivitySchema>;
|
175
|
-
export type AccountActivityResponse = z.infer<typeof AccountActivityResponseSchema>;
|
176
|
-
export type AccountPostsParams = z.infer<typeof AccountPostsParamsSchema>;
|
177
|
-
export type AccountPostsQuery = z.infer<typeof AccountPostsQuerySchema>;
|
178
|
-
export type AccountPost = z.infer<typeof AccountPostSchema>;
|
179
|
-
export type AccountPostsResponse = z.infer<typeof AccountPostsResponseSchema>;
|