@crosspost/types
Version:
Shared type definitions for Crosspost API
763 lines (751 loc) • 39.4 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
AccountActivityEntrySchema: () => AccountActivityEntrySchema,
AccountActivityParamsSchema: () => AccountActivityParamsSchema,
AccountActivityQuerySchema: () => AccountActivityQuerySchema,
AccountPostSchema: () => AccountPostSchema,
AccountPostsParamsSchema: () => AccountPostsParamsSchema,
AccountPostsQuerySchema: () => AccountPostsQuerySchema,
ActivityLeaderboardQuerySchema: () => ActivityLeaderboardQuerySchema,
ActivityType: () => ActivityType,
AllRateLimitsResponseSchema: () => AllRateLimitsResponseSchema,
ApiErrorCode: () => ApiErrorCode,
ApiErrorCodeSchema: () => ApiErrorCodeSchema,
AuthCallbackQuerySchema: () => AuthCallbackQuerySchema,
AuthCallbackResponseSchema: () => AuthCallbackResponseSchema,
AuthInitRequestSchema: () => AuthInitRequestSchema,
AuthRevokeResponseSchema: () => AuthRevokeResponseSchema,
AuthStatusParamsSchema: () => AuthStatusParamsSchema,
AuthStatusResponseSchema: () => AuthStatusResponseSchema,
AuthStatusSchema: () => AuthStatusSchema,
AuthTokenRequestSchema: () => AuthTokenRequestSchema,
AuthUrlResponseSchema: () => AuthUrlResponseSchema,
ConnectedAccountSchema: () => ConnectedAccountSchema,
ConnectedAccountsResponseSchema: () => ConnectedAccountsResponseSchema,
CreatePostRequestSchema: () => CreatePostRequestSchema,
CreatePostResponseSchema: () => CreatePostResponseSchema,
DeletePostRequestSchema: () => DeletePostRequestSchema,
DeletePostResponseSchema: () => DeletePostResponseSchema,
DeleteResultSchema: () => DeleteResultSchema,
EndpointRateLimitResponseSchema: () => EndpointRateLimitResponseSchema,
ErrorDetailSchema: () => ErrorDetailSchema,
FilterSchema: () => FilterSchema,
HealthStatusSchema: () => HealthStatusSchema,
LikePostRequestSchema: () => LikePostRequestSchema,
LikePostResponseSchema: () => LikePostResponseSchema,
LikeResultSchema: () => LikeResultSchema,
MediaContentSchema: () => MediaContentSchema,
MediaSchema: () => MediaSchema,
MultiStatusDataSchema: () => MultiStatusDataSchema,
MultiStatusSummarySchema: () => MultiStatusSummarySchema,
NearAuthorizationRequestSchema: () => NearAuthorizationRequestSchema,
NearAuthorizationResponseSchema: () => NearAuthorizationResponseSchema,
NearAuthorizationStatusResponseSchema: () => NearAuthorizationStatusResponseSchema,
NearUnauthorizationResponseSchema: () => NearUnauthorizationResponseSchema,
PaginationSchema: () => PaginationSchema,
Platform: () => Platform,
PlatformActivitySchema: () => PlatformActivitySchema,
PlatformParamSchema: () => PlatformParamSchema,
PlatformRateLimitSchema: () => PlatformRateLimitSchema,
PlatformSchema: () => PlatformSchema,
PostContentSchema: () => PostContentSchema,
PostMetricsSchema: () => PostMetricsSchema,
PostResponseSchema: () => PostResponseSchema,
PostResultSchema: () => PostResultSchema,
PostSchema: () => PostSchema,
PostToDeleteSchema: () => PostToDeleteSchema,
ProfileRefreshResponseSchema: () => ProfileRefreshResponseSchema,
QuotePostRequestSchema: () => QuotePostRequestSchema,
QuotePostResponseSchema: () => QuotePostResponseSchema,
RateLimitEndpointParamSchema: () => RateLimitEndpointParamSchema,
RateLimitEndpointSchema: () => RateLimitEndpointSchema,
RateLimitResponseSchema: () => RateLimitResponseSchema,
RateLimitStatusResponseSchema: () => RateLimitStatusResponseSchema,
RateLimitStatusSchema: () => RateLimitStatusSchema,
ReplyToPostRequestSchema: () => ReplyToPostRequestSchema,
ReplyToPostResponseSchema: () => ReplyToPostResponseSchema,
RepostRequestSchema: () => RepostRequestSchema,
RepostResponseSchema: () => RepostResponseSchema,
ResponseMetaSchema: () => ResponseMetaSchema,
SUPPORTED_PLATFORMS: () => SUPPORTED_PLATFORMS,
SuccessDetailSchema: () => SuccessDetailSchema,
SupportedPlatformSchema: () => SupportedPlatformSchema,
TargetSchema: () => TargetSchema,
TimePeriod: () => TimePeriod,
UnlikePostRequestSchema: () => UnlikePostRequestSchema,
UnlikePostResponseSchema: () => UnlikePostResponseSchema,
UsageRateLimitSchema: () => UsageRateLimitSchema,
UserProfileSchema: () => UserProfileSchema,
createMultiStatusDataSchema: () => createMultiStatusDataSchema,
createSuccessDetailSchema: () => createSuccessDetailSchema,
errorCodeToStatusCode: () => errorCodeToStatusCode,
isPlatformSupported: () => isPlatformSupported
});
module.exports = __toCommonJS(index_exports);
// src/common.ts
var import_zod = require("zod");
var Platform = /* @__PURE__ */ ((Platform2) => {
Platform2["UNKNOWN"] = "unknown";
Platform2["TWITTER"] = "twitter";
return Platform2;
})(Platform || {});
var PlatformSchema = import_zod.z.nativeEnum(Platform).describe("Social media platform");
var SUPPORTED_PLATFORMS = [
"twitter" /* TWITTER */
// Add more platforms here as they're implemented
];
var SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0 ? import_zod.z.enum(SUPPORTED_PLATFORMS) : import_zod.z.never();
SupportedPlatformSchema.describe("Currently supported social media platforms");
function isPlatformSupported(platform) {
return SUPPORTED_PLATFORMS.includes(platform);
}
// src/response.ts
var import_zod3 = require("zod");
// src/errors.ts
var import_zod2 = require("zod");
var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
ApiErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
ApiErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
ApiErrorCode2["UNAUTHORIZED"] = "UNAUTHORIZED";
ApiErrorCode2["FORBIDDEN"] = "FORBIDDEN";
ApiErrorCode2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
ApiErrorCode2["INVALID_REQUEST"] = "INVALID_REQUEST";
ApiErrorCode2["RATE_LIMITED"] = "RATE_LIMITED";
ApiErrorCode2["NOT_FOUND"] = "NOT_FOUND";
ApiErrorCode2["PLATFORM_ERROR"] = "PLATFORM_ERROR";
ApiErrorCode2["PLATFORM_UNAVAILABLE"] = "PLATFORM_UNAVAILABLE";
ApiErrorCode2["CONTENT_POLICY_VIOLATION"] = "CONTENT_POLICY_VIOLATION";
ApiErrorCode2["DUPLICATE_CONTENT"] = "DUPLICATE_CONTENT";
ApiErrorCode2["MEDIA_UPLOAD_FAILED"] = "MEDIA_UPLOAD_FAILED";
ApiErrorCode2["MULTI_STATUS"] = "MULTI_STATUS";
ApiErrorCode2["POST_CREATION_FAILED"] = "POST_CREATION_FAILED";
ApiErrorCode2["THREAD_CREATION_FAILED"] = "THREAD_CREATION_FAILED";
ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
ApiErrorCode2["INVALID_RESPONSE"] = "INVALID_RESPONSE";
ApiErrorCode2["TOKEN_REFRESH_FAILED"] = "TOKEN_REFRESH_FAILED";
ApiErrorCode2["PROFILE_REFRESH_FAILED"] = "PROFILE_REFRESH_FAILED";
return ApiErrorCode2;
})(ApiErrorCode || {});
var ApiErrorCodeSchema = import_zod2.z.enum(Object.values(ApiErrorCode));
var errorCodeToStatusCode = {
["MULTI_STATUS" /* MULTI_STATUS */]: 207,
["UNKNOWN_ERROR" /* UNKNOWN_ERROR */]: 500,
["INTERNAL_ERROR" /* INTERNAL_ERROR */]: 500,
["VALIDATION_ERROR" /* VALIDATION_ERROR */]: 400,
["INVALID_REQUEST" /* INVALID_REQUEST */]: 400,
["NOT_FOUND" /* NOT_FOUND */]: 404,
["UNAUTHORIZED" /* UNAUTHORIZED */]: 401,
["FORBIDDEN" /* FORBIDDEN */]: 403,
["RATE_LIMITED" /* RATE_LIMITED */]: 429,
["PLATFORM_ERROR" /* PLATFORM_ERROR */]: 502,
["PLATFORM_UNAVAILABLE" /* PLATFORM_UNAVAILABLE */]: 503,
["CONTENT_POLICY_VIOLATION" /* CONTENT_POLICY_VIOLATION */]: 400,
["DUPLICATE_CONTENT" /* DUPLICATE_CONTENT */]: 400,
["MEDIA_UPLOAD_FAILED" /* MEDIA_UPLOAD_FAILED */]: 400,
["POST_CREATION_FAILED" /* POST_CREATION_FAILED */]: 500,
["THREAD_CREATION_FAILED" /* THREAD_CREATION_FAILED */]: 500,
["POST_DELETION_FAILED" /* POST_DELETION_FAILED */]: 500,
["POST_INTERACTION_FAILED" /* POST_INTERACTION_FAILED */]: 500,
["NETWORK_ERROR" /* NETWORK_ERROR */]: 503,
["INVALID_RESPONSE" /* INVALID_RESPONSE */]: 500,
["TOKEN_REFRESH_FAILED" /* TOKEN_REFRESH_FAILED */]: 500,
["PROFILE_REFRESH_FAILED" /* PROFILE_REFRESH_FAILED */]: 500
};
var ErrorDetailSchema = import_zod2.z.object({
message: import_zod2.z.string().describe("Human-readable error message"),
code: ApiErrorCodeSchema.describe("Machine-readable error code"),
recoverable: import_zod2.z.boolean().describe("Whether the error can be recovered from"),
details: import_zod2.z.record(import_zod2.z.unknown()).optional().describe("Additional error details")
});
// src/response.ts
var ResponseMetaSchema = import_zod3.z.object({
requestId: import_zod3.z.string().uuid().describe("Unique identifier for the request"),
timestamp: import_zod3.z.string().datetime().describe("ISO timestamp of response generation"),
rateLimit: import_zod3.z.object({
remaining: import_zod3.z.number().int().nonnegative(),
limit: import_zod3.z.number().int().positive(),
reset: import_zod3.z.number().int().positive().describe("Unix timestamp (seconds)")
}).optional().describe("Rate limit information if applicable"),
pagination: import_zod3.z.object({
limit: import_zod3.z.number().int().nonnegative().optional(),
offset: import_zod3.z.number().int().nonnegative().optional(),
total: import_zod3.z.number().int().nonnegative().optional()
}).optional().describe("Pagination information if applicable")
});
var createSuccessDetailSchema = (detailsSchema = import_zod3.z.any().optional()) => import_zod3.z.object({
platform: import_zod3.z.string(),
userId: import_zod3.z.string(),
details: detailsSchema,
status: import_zod3.z.literal("success")
}).catchall(import_zod3.z.any());
var SuccessDetailSchema = createSuccessDetailSchema();
var HealthStatusSchema = import_zod3.z.object({
status: import_zod3.z.string().describe("Health status of the API"),
version: import_zod3.z.string().optional().describe("API version"),
timestamp: import_zod3.z.string().datetime().describe("Current server time")
}).describe("Health status response");
var MultiStatusSummarySchema = import_zod3.z.object({
total: import_zod3.z.number().int().nonnegative(),
succeeded: import_zod3.z.number().int().nonnegative(),
failed: import_zod3.z.number().int().nonnegative()
});
var createMultiStatusDataSchema = (detailsSchema) => import_zod3.z.object({
summary: MultiStatusSummarySchema,
results: import_zod3.z.array(
detailsSchema ? createSuccessDetailSchema(detailsSchema) : SuccessDetailSchema
// Uses default createSuccessDetailSchema() if no specific schema passed
),
errors: import_zod3.z.array(ErrorDetailSchema)
});
var MultiStatusDataSchema = createMultiStatusDataSchema();
// src/auth.ts
var import_zod5 = require("zod");
// src/user-profile.ts
var import_zod4 = require("zod");
var UserProfileSchema = import_zod4.z.object({
userId: import_zod4.z.string().describe("User ID on the platform"),
username: import_zod4.z.string().describe("Username on the platform"),
url: import_zod4.z.string().url().optional().describe("URL to the user profile"),
profileImageUrl: import_zod4.z.string().describe("URL to the user profile image"),
isPremium: import_zod4.z.boolean().optional().describe("Whether the user has a premium account"),
platform: PlatformSchema.describe("The platform the user profile is from"),
lastUpdated: import_zod4.z.number().describe("Timestamp when the profile was last updated")
}).describe("User profile");
var ProfileRefreshResponseSchema = import_zod4.z.object({
profile: UserProfileSchema.optional().describe("The refreshed user profile (if successful)")
}).describe("Profile refresh response");
// src/auth.ts
var PlatformParamSchema = import_zod5.z.object({
platform: import_zod5.z.string().describe("Social media platform")
}).describe("Platform parameter");
var AuthStatusSchema = import_zod5.z.object({
message: import_zod5.z.string().describe("User-friendly status message"),
code: import_zod5.z.string().describe("Status code for programmatic handling"),
details: import_zod5.z.string().optional().describe("Additional status details")
}).describe("Authentication status information");
var AuthInitRequestSchema = import_zod5.z.object({
successUrl: import_zod5.z.string().url().optional().describe(
"URL to redirect to on successful authentication"
),
errorUrl: import_zod5.z.string().url().optional().describe("URL to redirect to on authentication error"),
redirect: import_zod5.z.boolean().optional().default(false).describe(
"Whether to redirect to successUrl/errorUrl (true) or return data directly (false)"
)
}).describe("Auth initialization request");
var AuthUrlResponseSchema = import_zod5.z.object({
url: import_zod5.z.string().describe("Authentication URL to redirect the user to")
}).describe("Auth URL response");
var AuthCallbackQuerySchema = import_zod5.z.object({
code: import_zod5.z.string().describe("Authorization code from OAuth provider"),
state: import_zod5.z.string().describe("State parameter for CSRF protection")
}).describe("Auth callback query");
var AuthCallbackResponseSchema = import_zod5.z.object({
platform: PlatformSchema,
userId: import_zod5.z.string().describe("User ID"),
redirectUrl: import_zod5.z.string().optional().describe("URL to redirect the user to after authentication"),
status: AuthStatusSchema.describe("Authentication status information")
}).describe("Auth callback response");
var AuthStatusParamsSchema = import_zod5.z.object({
platform: import_zod5.z.string().describe("Social media platform"),
userId: import_zod5.z.string().describe("User ID on the platform")
}).describe("Token status parameters");
var NearUnauthorizationResponseSchema = import_zod5.z.object({
success: import_zod5.z.boolean().describe("Whether the unauthorized operation was successful"),
nearAccount: import_zod5.z.string().describe("NEAR account ID that was unauthorized")
}).describe("NEAR unauthorized response");
var AuthStatusResponseSchema = import_zod5.z.object({
platform: PlatformSchema,
userId: import_zod5.z.string().describe("User ID"),
authenticated: import_zod5.z.boolean().describe("Whether the user is authenticated"),
tokenStatus: import_zod5.z.object({
valid: import_zod5.z.boolean().describe("Whether the token is valid"),
expired: import_zod5.z.boolean().describe("Whether the token is expired"),
expiresAt: import_zod5.z.string().optional().describe("When the token expires")
})
}).describe("Auth status response");
var AuthTokenRequestSchema = import_zod5.z.object({
userId: import_zod5.z.string().describe("User ID on the platform")
}).describe("Auth token request");
var AuthRevokeResponseSchema = import_zod5.z.object({
platform: PlatformSchema,
userId: import_zod5.z.string().describe("User ID")
}).describe("Auth revoke response");
var ConnectedAccountSchema = import_zod5.z.object({
platform: PlatformSchema,
userId: import_zod5.z.string().describe("User ID on the platform"),
connectedAt: import_zod5.z.string().describe("When the account was connected"),
profile: UserProfileSchema.nullable().describe("Full user profile data"),
error: import_zod5.z.string().optional().describe("Error message if fetching profile failed")
}).describe("Connected account");
var ConnectedAccountsResponseSchema = import_zod5.z.object({
accounts: import_zod5.z.array(ConnectedAccountSchema)
}).describe("Response containing an array of connected accounts");
var NearAuthorizationRequestSchema = import_zod5.z.object({
// No additional parameters needed, as the NEAR account ID is extracted from the signature
}).describe("NEAR authorization request");
var NearAuthorizationResponseSchema = import_zod5.z.object({
signerId: import_zod5.z.string().describe("NEAR account ID"),
isAuthorized: import_zod5.z.boolean().describe("Whether the account is authorized")
}).describe("NEAR authorization response");
var NearAuthorizationStatusResponseSchema = import_zod5.z.object({
signerId: import_zod5.z.string().describe("NEAR account ID"),
isAuthorized: import_zod5.z.boolean().describe("Whether the account is authorized"),
authorizedAt: import_zod5.z.string().optional().describe("When the account was authorized")
}).describe("NEAR authorization status response");
// src/post.ts
var import_zod6 = require("zod");
var MediaContentSchema = import_zod6.z.object({
data: import_zod6.z.union([import_zod6.z.string(), import_zod6.z.instanceof(Blob)]).describe("Media data as string or Blob"),
mimeType: import_zod6.z.string().optional().describe("Media MIME type"),
altText: import_zod6.z.string().optional().describe("Alt text for the media")
}).describe("Media content object");
var MediaSchema = import_zod6.z.object({
id: import_zod6.z.string().describe("Media ID"),
type: import_zod6.z.enum(["image", "video", "gif"]).describe("Media type"),
url: import_zod6.z.string().optional().describe("Media URL"),
altText: import_zod6.z.string().optional().describe("Alt text for the media")
}).describe("Media object");
var PostMetricsSchema = import_zod6.z.object({
retweets: import_zod6.z.number().describe("Number of retweets"),
quotes: import_zod6.z.number().describe("Number of quotes"),
likes: import_zod6.z.number().describe("Number of likes"),
replies: import_zod6.z.number().describe("Number of replies")
}).describe("Post metrics");
var PostSchema = import_zod6.z.object({
id: import_zod6.z.string().describe("Post ID"),
text: import_zod6.z.string().describe("Post text content"),
createdAt: import_zod6.z.string().describe("Post creation date"),
authorId: import_zod6.z.string().describe("Author ID"),
media: import_zod6.z.array(MediaSchema).optional().describe("Media attached to the post"),
metrics: PostMetricsSchema.optional().describe("Post metrics"),
inReplyToId: import_zod6.z.string().optional().describe("ID of the post this is a reply to"),
quotedPostId: import_zod6.z.string().optional().describe("ID of the post this is quoting")
}).describe("Post object");
var PostContentSchema = import_zod6.z.object({
text: import_zod6.z.string().optional().describe("Text content for the post"),
media: import_zod6.z.array(MediaContentSchema).optional().describe("Media attachments for the post")
}).describe("Post content");
var PostResultSchema = import_zod6.z.object({
id: import_zod6.z.string().describe("Post ID"),
text: import_zod6.z.string().optional().describe("Post text content"),
createdAt: import_zod6.z.string().describe("Post creation date"),
mediaIds: import_zod6.z.array(import_zod6.z.string()).optional().describe("Media IDs attached to the post"),
threadIds: import_zod6.z.array(import_zod6.z.string()).optional().describe("Thread IDs for threaded posts"),
quotedPostId: import_zod6.z.string().optional().describe("ID of the post this is quoting"),
inReplyToId: import_zod6.z.string().optional().describe("ID of the post this is a reply to"),
success: import_zod6.z.boolean().optional().describe("Whether the operation was successful")
}).catchall(import_zod6.z.any()).describe("Post result");
var DeleteResultSchema = import_zod6.z.object({
success: import_zod6.z.boolean().describe("Whether the deletion was successful"),
id: import_zod6.z.string().describe("ID of the deleted post")
}).describe("Delete result");
var LikeResultSchema = import_zod6.z.object({
success: import_zod6.z.boolean().describe("Whether the like was successful"),
id: import_zod6.z.string().describe("ID of the liked post")
}).describe("Like result");
var TargetSchema = import_zod6.z.object({
platform: PlatformSchema.describe('The platform to post to (e.g., "twitter")'),
userId: import_zod6.z.string().describe("User ID on the platform")
}).describe("Target for posting operations");
var CreatePostRequestSchema = import_zod6.z.object({
targets: import_zod6.z.array(TargetSchema).describe("Array of targets to post to (can be a single target)"),
content: import_zod6.z.array(PostContentSchema).describe(
"The content of the post, always an array of PostContent objects, even for a single post"
)
}).describe("Create post request");
var RepostRequestSchema = import_zod6.z.object({
targets: import_zod6.z.array(TargetSchema).describe("Array of targets to post to"),
platform: PlatformSchema.describe("Platform of the post being reposted"),
postId: import_zod6.z.string().describe("ID of the post to repost")
}).describe("Repost request");
var QuotePostRequestSchema = import_zod6.z.object({
targets: import_zod6.z.array(TargetSchema).describe(
"Array of targets to post to (must be on the same platform as the post being quoted)"
),
platform: PlatformSchema.describe("Platform of the post being quoted"),
postId: import_zod6.z.string().describe("ID of the post to quote"),
content: import_zod6.z.array(PostContentSchema).describe(
"Content for the quote post(s), always an array, even for a single post"
)
}).describe("Quote post request");
var ReplyToPostRequestSchema = import_zod6.z.object({
targets: import_zod6.z.array(TargetSchema).describe(
"Array of targets to post to (must be on the same platform as the post being replied to)"
),
platform: PlatformSchema.describe("Platform of the post being replied to"),
postId: import_zod6.z.string().describe("ID of the post to reply to"),
content: import_zod6.z.array(PostContentSchema).describe(
"Content for the reply post(s), always an array, even for a single post"
)
}).describe("Reply to post request");
var PostToDeleteSchema = import_zod6.z.object({
platform: PlatformSchema.describe("Platform of the post to delete"),
userId: import_zod6.z.string().describe("User ID on the platform"),
postId: import_zod6.z.string().describe("ID of the post to delete")
}).describe("Post to delete");
var DeletePostRequestSchema = import_zod6.z.object({
targets: import_zod6.z.array(TargetSchema).describe("Array of targets to delete posts"),
posts: import_zod6.z.array(PostToDeleteSchema).describe("Array of posts to delete")
}).describe("Delete post request");
var LikePostRequestSchema = import_zod6.z.object({
targets: import_zod6.z.array(TargetSchema).describe(
"Array of targets to like the post (must be on the same platform as the post being liked)"
),
platform: PlatformSchema.describe("Platform of the post being liked"),
postId: import_zod6.z.string().describe("ID of the post to like")
}).describe("Like post request");
var UnlikePostRequestSchema = import_zod6.z.object({
targets: import_zod6.z.array(TargetSchema).describe(
"Array of targets to unlike the post (must be on the same platform as the post being unliked)"
),
platform: PlatformSchema.describe("Platform of the post being unliked"),
postId: import_zod6.z.string().describe("ID of the post to unlike")
}).describe("Unlike post request");
var PostResponseSchema = import_zod6.z.union([PostSchema, import_zod6.z.array(PostSchema)]).describe(
"Post response"
);
var CreatePostResponseSchema = PostResponseSchema.describe(
"Create post response"
);
var RepostResponseSchema = PostResponseSchema.describe("Repost response");
var QuotePostResponseSchema = PostResponseSchema.describe("Quote post response");
var ReplyToPostResponseSchema = PostResponseSchema.describe("Reply to post response");
var DeletePostResponseSchema = import_zod6.z.object({
id: import_zod6.z.string().describe("ID of the deleted post")
}).describe("Delete post response");
var LikePostResponseSchema = import_zod6.z.object({
id: import_zod6.z.string().describe("ID of the liked post")
}).describe("Like post response");
var UnlikePostResponseSchema = import_zod6.z.object({
id: import_zod6.z.string().describe("ID of the unliked post")
}).describe("Unlike post response");
// src/rate-limit.ts
var import_zod7 = require("zod");
var RateLimitEndpointParamSchema = import_zod7.z.object({
endpoint: import_zod7.z.string().optional().describe(
"Specific endpoint to get rate limit information for (optional)"
)
}).describe("Rate limit endpoint parameter");
var RateLimitEndpointSchema = import_zod7.z.object({
endpoint: import_zod7.z.string().describe("API endpoint"),
method: import_zod7.z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
limit: import_zod7.z.number().describe("Rate limit"),
remaining: import_zod7.z.number().describe("Remaining requests"),
reset: import_zod7.z.number().describe("Reset timestamp (Unix timestamp in seconds)"),
resetDate: import_zod7.z.string().describe("Reset date (ISO string)")
}).describe("Rate limit endpoint");
var RateLimitStatusSchema = import_zod7.z.object({
endpoint: import_zod7.z.string().describe("API endpoint or action"),
limit: import_zod7.z.number().describe("Maximum number of requests allowed in the time window"),
remaining: import_zod7.z.number().describe("Number of requests remaining in the current time window"),
reset: import_zod7.z.string().datetime().describe("Timestamp when the rate limit will reset"),
resetSeconds: import_zod7.z.number().describe("Seconds until the rate limit will reset")
}).describe("Rate limit status");
var PlatformRateLimitSchema = import_zod7.z.object({
platform: PlatformSchema,
endpoints: import_zod7.z.record(import_zod7.z.string(), RateLimitStatusSchema).describe(
"Rate limit status for each endpoint"
)
}).describe("Platform-specific rate limit");
var UsageRateLimitSchema = import_zod7.z.object({
endpoint: import_zod7.z.string().describe("API endpoint or action"),
limit: import_zod7.z.number().describe("Maximum number of requests allowed in the time window"),
remaining: import_zod7.z.number().describe("Number of requests remaining in the current time window"),
reset: import_zod7.z.string().datetime().describe("Timestamp when the rate limit will reset"),
resetSeconds: import_zod7.z.number().describe("Seconds until the rate limit will reset"),
timeWindow: import_zod7.z.string().describe("Time window for the rate limit")
}).describe("Usage rate limit");
var RateLimitStatusResponseSchema = import_zod7.z.object({
platform: PlatformSchema,
userId: import_zod7.z.string().optional().describe("User ID"),
endpoints: import_zod7.z.array(RateLimitEndpointSchema).describe("Rate limits for specific endpoints"),
app: import_zod7.z.object({
limit: import_zod7.z.number().describe("App-wide rate limit"),
remaining: import_zod7.z.number().describe("Remaining requests"),
reset: import_zod7.z.number().describe("Reset timestamp (Unix timestamp in seconds)"),
resetDate: import_zod7.z.string().describe("Reset date (ISO string)")
}).optional().describe("App-wide rate limits")
}).describe("Rate limit status response");
var AllRateLimitsResponseSchema = import_zod7.z.object({
platforms: import_zod7.z.record(
PlatformSchema,
import_zod7.z.object({
users: import_zod7.z.record(
import_zod7.z.string(),
import_zod7.z.object({
endpoints: import_zod7.z.array(RateLimitEndpointSchema).describe(
"Rate limits for specific endpoints"
),
lastUpdated: import_zod7.z.string().describe("Last updated date (ISO string)")
})
).describe("User-specific rate limits"),
app: import_zod7.z.object({
limit: import_zod7.z.number().describe("App-wide rate limit"),
remaining: import_zod7.z.number().describe("Remaining requests"),
reset: import_zod7.z.number().describe("Reset timestamp (Unix timestamp in seconds)"),
resetDate: import_zod7.z.string().describe("Reset date (ISO string)")
}).optional().describe("App-wide rate limits")
})
).describe("Rate limits by platform")
}).describe("All rate limits response");
var RateLimitResponseSchema = import_zod7.z.object({
platformLimits: import_zod7.z.array(PlatformRateLimitSchema).describe("Platform-specific rate limits"),
usageLimits: import_zod7.z.record(import_zod7.z.string(), UsageRateLimitSchema).describe(
"Usage-based rate limits for the NEAR account"
),
signerId: import_zod7.z.string().describe("NEAR account ID")
}).describe("Rate limit response");
var EndpointRateLimitResponseSchema = import_zod7.z.object({
platformLimits: import_zod7.z.array(
import_zod7.z.object({
platform: PlatformSchema,
status: RateLimitStatusSchema.describe("Rate limit status for the endpoint")
})
).describe("Platform-specific rate limits for the endpoint"),
usageLimit: UsageRateLimitSchema.describe("Usage-based rate limit for the NEAR account"),
endpoint: import_zod7.z.string().describe("API endpoint or action"),
signerId: import_zod7.z.string().describe("NEAR account ID")
}).describe("Endpoint rate limit response");
// src/activity.ts
var import_zod8 = require("zod");
var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
ActivityType2["POST"] = "post";
ActivityType2["REPOST"] = "repost";
ActivityType2["REPLY"] = "reply";
ActivityType2["QUOTE"] = "quote";
ActivityType2["LIKE"] = "like";
ActivityType2["UNLIKE"] = "unlike";
ActivityType2["DELETE"] = "delete";
return ActivityType2;
})(ActivityType || {});
var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
TimePeriod2["ALL"] = "all";
TimePeriod2["YEARLY"] = "year";
TimePeriod2["MONTHLY"] = "month";
TimePeriod2["WEEKLY"] = "week";
TimePeriod2["DAILY"] = "day";
TimePeriod2["CUSTOM"] = "custom";
return TimePeriod2;
})(TimePeriod || {});
var FilterSchema = import_zod8.z.object({
platforms: import_zod8.z.string().optional().transform((val) => {
if (!val) return void 0;
return val.split(",").map((p) => p.trim()).map((p) => {
try {
return Platform[p.toUpperCase()];
} catch (_e) {
return p;
}
});
}).pipe(
import_zod8.z.array(import_zod8.z.nativeEnum(Platform)).optional()
).describe("Filter by platforms (comma-separated list, optional)"),
types: import_zod8.z.string().optional().transform((val) => {
if (!val) return void 0;
return val.split(",").map((t) => t.trim()).map((t) => {
try {
return ActivityType[t.toUpperCase()];
} catch (_e) {
return t;
}
});
}).pipe(
import_zod8.z.array(import_zod8.z.nativeEnum(ActivityType)).optional()
).describe("Filter by activity types (comma-separated list, optional)"),
timeframe: import_zod8.z.nativeEnum(TimePeriod).optional().describe(
"Timeframe for filtering (optional)"
),
startDate: import_zod8.z.string().datetime().optional().describe(
"Start date for custom timeframe (ISO 8601 format, optional - defaults to beginning when timeframe=custom)"
),
endDate: import_zod8.z.string().datetime().optional().describe(
"End date for custom timeframe (ISO 8601 format, optional - defaults to now when timeframe=custom)"
)
}).describe("Filter parameters");
var PaginationSchema = import_zod8.z.object({
limit: import_zod8.z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(import_zod8.z.number().min(1).max(100).optional()).describe("Maximum number of results to return (1-100)"),
offset: import_zod8.z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(import_zod8.z.number().min(0).optional()).describe("Offset for pagination")
}).describe("Pagination parameters");
var ActivityLeaderboardQuerySchema = FilterSchema.merge(PaginationSchema).describe(
"Account leaderboard query"
);
var AccountActivityEntrySchema = import_zod8.z.object({
signerId: import_zod8.z.string().describe("NEAR account ID"),
totalPosts: import_zod8.z.number().describe("Total number of posts"),
totalLikes: import_zod8.z.number().describe("Total number of likes"),
totalReposts: import_zod8.z.number().describe("Total number of reposts"),
totalReplies: import_zod8.z.number().describe("Total number of replies"),
totalQuotes: import_zod8.z.number().describe("Total number of quote posts"),
totalScore: import_zod8.z.number().describe("Total activity score"),
rank: import_zod8.z.number().describe("Rank on the leaderboard"),
lastActive: import_zod8.z.string().datetime().describe("Timestamp of last activity"),
firstPostTimestamp: import_zod8.z.string().datetime().describe("Timestamp of the first post")
}).describe("Account activity entry");
var ActivityLeaderboardResponseSchema = import_zod8.z.object({
timeframe: import_zod8.z.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
entries: import_zod8.z.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
generatedAt: import_zod8.z.string().datetime().describe("Timestamp when the leaderboard was generated"),
platforms: import_zod8.z.array(PlatformSchema).optional().describe("Platform filters (if applied)")
});
var AccountActivityParamsSchema = import_zod8.z.object({
signerId: import_zod8.z.string().describe("NEAR account ID")
}).describe("Account activity params");
var AccountActivityQuerySchema = FilterSchema.merge(PaginationSchema).describe(
"Account activity query"
);
var PlatformActivitySchema = import_zod8.z.object({
platform: PlatformSchema,
posts: import_zod8.z.number().describe("Number of posts on this platform"),
likes: import_zod8.z.number().describe("Number of likes on this platform"),
reposts: import_zod8.z.number().describe("Number of reposts on this platform"),
replies: import_zod8.z.number().describe("Number of replies on this platform"),
quotes: import_zod8.z.number().describe("Number of quote posts on this platform"),
score: import_zod8.z.number().describe("Activity score on this platform"),
lastActive: import_zod8.z.string().datetime().describe("Timestamp of last activity on this platform")
}).describe("Platform activity");
var AccountActivityResponseSchema = import_zod8.z.object({
signerId: import_zod8.z.string().describe("NEAR account ID"),
timeframe: import_zod8.z.nativeEnum(TimePeriod).describe("Timeframe for the activity"),
totalPosts: import_zod8.z.number().describe("Total number of posts across all platforms"),
totalLikes: import_zod8.z.number().describe("Total number of likes across all platforms"),
totalReposts: import_zod8.z.number().describe("Total number of reposts across all platforms"),
totalReplies: import_zod8.z.number().describe("Total number of replies across all platforms"),
totalQuotes: import_zod8.z.number().describe("Total number of quote posts across all platforms"),
totalScore: import_zod8.z.number().describe("Total activity score across all platforms"),
rank: import_zod8.z.number().describe("Rank on the leaderboard"),
lastActive: import_zod8.z.string().datetime().describe("Timestamp of last activity across all platforms"),
platforms: import_zod8.z.array(PlatformActivitySchema).describe("Activity breakdown by platform")
});
var AccountPostsParamsSchema = import_zod8.z.object({
signerId: import_zod8.z.string().describe("NEAR account ID")
}).describe("Account posts params");
var AccountPostsQuerySchema = FilterSchema.merge(PaginationSchema).describe(
"Account posts query"
);
var AccountPostSchema = import_zod8.z.object({
id: import_zod8.z.string().describe("Post ID"),
platform: PlatformSchema,
userId: import_zod8.z.string().describe("User ID on the platform"),
type: import_zod8.z.nativeEnum(ActivityType).describe("Type of post"),
content: import_zod8.z.string().optional().describe("Post content (if available)"),
url: import_zod8.z.string().url().optional().describe("URL to the post on the platform (if available)"),
createdAt: import_zod8.z.string().datetime().describe("Timestamp when the post was created"),
metrics: import_zod8.z.object({
likes: import_zod8.z.number().optional().describe("Number of likes (if available)"),
reposts: import_zod8.z.number().optional().describe("Number of reposts (if available)"),
replies: import_zod8.z.number().optional().describe("Number of replies (if available)"),
quotes: import_zod8.z.number().optional().describe("Number of quotes (if available)")
}).optional().describe("Post metrics (if available)"),
inReplyToId: import_zod8.z.string().optional().describe("ID of the post this is a reply to (if applicable)"),
quotedPostId: import_zod8.z.string().optional().describe("ID of the post this is quoting (if applicable)")
}).describe("Account post");
var AccountPostsResponseSchema = import_zod8.z.object({
signerId: import_zod8.z.string().describe("NEAR account ID"),
posts: import_zod8.z.array(AccountPostSchema).describe("List of posts"),
platforms: import_zod8.z.array(import_zod8.z.string()).optional().describe("Platform filters (if applied)"),
types: import_zod8.z.array(import_zod8.z.string()).optional().describe("Post type filters (if applied)")
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AccountActivityEntrySchema,
AccountActivityParamsSchema,
AccountActivityQuerySchema,
AccountPostSchema,
AccountPostsParamsSchema,
AccountPostsQuerySchema,
ActivityLeaderboardQuerySchema,
ActivityType,
AllRateLimitsResponseSchema,
ApiErrorCode,
ApiErrorCodeSchema,
AuthCallbackQuerySchema,
AuthCallbackResponseSchema,
AuthInitRequestSchema,
AuthRevokeResponseSchema,
AuthStatusParamsSchema,
AuthStatusResponseSchema,
AuthStatusSchema,
AuthTokenRequestSchema,
AuthUrlResponseSchema,
ConnectedAccountSchema,
ConnectedAccountsResponseSchema,
CreatePostRequestSchema,
CreatePostResponseSchema,
DeletePostRequestSchema,
DeletePostResponseSchema,
DeleteResultSchema,
EndpointRateLimitResponseSchema,
ErrorDetailSchema,
FilterSchema,
HealthStatusSchema,
LikePostRequestSchema,
LikePostResponseSchema,
LikeResultSchema,
MediaContentSchema,
MediaSchema,
MultiStatusDataSchema,
MultiStatusSummarySchema,
NearAuthorizationRequestSchema,
NearAuthorizationResponseSchema,
NearAuthorizationStatusResponseSchema,
NearUnauthorizationResponseSchema,
PaginationSchema,
Platform,
PlatformActivitySchema,
PlatformParamSchema,
PlatformRateLimitSchema,
PlatformSchema,
PostContentSchema,
PostMetricsSchema,
PostResponseSchema,
PostResultSchema,
PostSchema,
PostToDeleteSchema,
ProfileRefreshResponseSchema,
QuotePostRequestSchema,
QuotePostResponseSchema,
RateLimitEndpointParamSchema,
RateLimitEndpointSchema,
RateLimitResponseSchema,
RateLimitStatusResponseSchema,
RateLimitStatusSchema,
ReplyToPostRequestSchema,
ReplyToPostResponseSchema,
RepostRequestSchema,
RepostResponseSchema,
ResponseMetaSchema,
SUPPORTED_PLATFORMS,
SuccessDetailSchema,
SupportedPlatformSchema,
TargetSchema,
TimePeriod,
UnlikePostRequestSchema,
UnlikePostResponseSchema,
UsageRateLimitSchema,
UserProfileSchema,
createMultiStatusDataSchema,
createSuccessDetailSchema,
errorCodeToStatusCode,
isPlatformSupported
});