@crosspost/types 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,852 @@
1
+ // src/common.ts
2
+ import { z } from "zod";
3
+ var PlatformSchema = z.enum([
4
+ "unknown",
5
+ "twitter"
6
+ // Add more platforms as they're implemented
7
+ // 'linkedin',
8
+ // 'facebook',
9
+ // 'instagram',
10
+ ]).describe("Social media platform");
11
+ var Platform = /* @__PURE__ */ ((Platform2) => {
12
+ Platform2["UNKNOWN"] = "unknown";
13
+ Platform2["TWITTER"] = "twitter";
14
+ return Platform2;
15
+ })(Platform || {});
16
+
17
+ // src/response.ts
18
+ import { z as z2 } from "zod";
19
+ var ApiResponseSchema = z2.object({
20
+ data: z2.any().describe("Response data"),
21
+ meta: z2.object({
22
+ rateLimit: z2.object({
23
+ remaining: z2.number().describe("Number of requests remaining in the current window"),
24
+ limit: z2.number().describe("Total number of requests allowed in the window"),
25
+ reset: z2.number().describe("Timestamp when the rate limit resets (in seconds since epoch)")
26
+ }).optional().describe("Rate limit information"),
27
+ pagination: z2.object({
28
+ page: z2.number().describe("Current page number"),
29
+ perPage: z2.number().describe("Number of items per page"),
30
+ total: z2.number().describe("Total number of items"),
31
+ totalPages: z2.number().describe("Total number of pages"),
32
+ nextCursor: z2.string().optional().describe("Next page cursor (if applicable)"),
33
+ prevCursor: z2.string().optional().describe("Previous page cursor (if applicable)")
34
+ }).optional().describe("Pagination information")
35
+ }).optional().describe("Response metadata")
36
+ }).describe("Standard API response");
37
+ var ErrorResponseSchema = z2.object({
38
+ error: z2.object({
39
+ type: z2.string().describe("Error type"),
40
+ message: z2.string().describe("Error message"),
41
+ code: z2.string().optional().describe("Error code (if applicable)"),
42
+ details: z2.any().optional().describe("Additional error details")
43
+ }).describe("Error information")
44
+ }).describe("Error response");
45
+ var EnhancedResponseMetaSchema = z2.object({
46
+ requestId: z2.string().optional().describe("Unique request identifier"),
47
+ timestamp: z2.string().optional().describe("Request timestamp"),
48
+ rateLimit: z2.object({
49
+ remaining: z2.number().describe("Number of requests remaining in the current window"),
50
+ limit: z2.number().describe("Total number of requests allowed in the window"),
51
+ reset: z2.number().describe("Timestamp when the rate limit resets (in seconds since epoch)")
52
+ }).optional().describe("Rate limit information"),
53
+ pagination: z2.object({
54
+ page: z2.number().describe("Current page number"),
55
+ perPage: z2.number().describe("Number of items per page"),
56
+ total: z2.number().describe("Total number of items"),
57
+ totalPages: z2.number().describe("Total number of pages"),
58
+ nextCursor: z2.string().optional().describe("Next page cursor (if applicable)"),
59
+ prevCursor: z2.string().optional().describe("Previous page cursor (if applicable)")
60
+ }).optional().describe("Pagination information")
61
+ }).optional().describe("Response metadata");
62
+ var ErrorDetailSchema = z2.object({
63
+ platform: z2.string().optional().describe("Platform associated with the error (if applicable)"),
64
+ userId: z2.string().optional().describe("User ID associated with the error (if applicable)"),
65
+ status: z2.literal("error").describe("Error status"),
66
+ error: z2.string().describe("Human-readable error message"),
67
+ errorCode: z2.string().describe("Machine-readable error code"),
68
+ recoverable: z2.boolean().describe("Whether the error is recoverable (can be retried)"),
69
+ details: z2.record(z2.any()).optional().describe("Additional error details (platform-specific)")
70
+ }).describe("Error detail");
71
+ var EnhancedErrorResponseSchema = z2.object({
72
+ success: z2.literal(false).describe("Success indicator (always false for error responses)"),
73
+ errors: z2.array(ErrorDetailSchema).describe("Error information")
74
+ }).describe("Enhanced error response");
75
+ var SuccessDetailSchema = z2.object({
76
+ platform: z2.string().describe("Platform associated with the success"),
77
+ userId: z2.string().describe("User ID associated with the success"),
78
+ status: z2.literal("success").describe("Success status"),
79
+ postId: z2.string().optional().describe("Post ID (if applicable)"),
80
+ postUrl: z2.string().optional().describe("Post URL (if applicable)")
81
+ }).catchall(z2.any()).describe("Success detail");
82
+ var MultiStatusResponseSchema = z2.object({
83
+ success: z2.boolean().describe("Success indicator (true if at least one operation succeeded)"),
84
+ data: z2.object({
85
+ summary: z2.object({
86
+ total: z2.number().describe("Total number of operations"),
87
+ succeeded: z2.number().describe("Number of successful operations"),
88
+ failed: z2.number().describe("Number of failed operations")
89
+ }).describe("Summary of operations"),
90
+ results: z2.array(SuccessDetailSchema).describe("Successful results"),
91
+ errors: z2.array(ErrorDetailSchema).describe("Failed results")
92
+ }).describe("Response data")
93
+ }).describe("Multi-status response");
94
+ function EnhancedResponseSchema(schema) {
95
+ return z2.object({
96
+ success: z2.boolean().describe("Whether the request was successful"),
97
+ data: schema,
98
+ meta: EnhancedResponseMetaSchema
99
+ });
100
+ }
101
+ function createEnhancedApiResponse(data, meta) {
102
+ return {
103
+ success: true,
104
+ data,
105
+ meta
106
+ };
107
+ }
108
+ function createApiResponse(data, meta) {
109
+ return {
110
+ data,
111
+ meta
112
+ };
113
+ }
114
+ function createErrorResponse(type, message, code, details) {
115
+ return {
116
+ error: {
117
+ type,
118
+ message,
119
+ ...code ? { code } : {},
120
+ ...details ? { details } : {}
121
+ }
122
+ };
123
+ }
124
+ function createEnhancedErrorResponse(errors) {
125
+ return {
126
+ success: false,
127
+ errors
128
+ };
129
+ }
130
+ function createErrorDetail(error, errorCode, recoverable, platform, userId, details) {
131
+ return {
132
+ platform,
133
+ userId,
134
+ status: "error",
135
+ error,
136
+ errorCode,
137
+ recoverable,
138
+ details
139
+ };
140
+ }
141
+ function createSuccessDetail(platform, userId, additionalData) {
142
+ return {
143
+ platform,
144
+ userId,
145
+ status: "success",
146
+ ...additionalData
147
+ };
148
+ }
149
+ function createMultiStatusResponse(results, errors) {
150
+ const total = results.length + errors.length;
151
+ const succeeded = results.length;
152
+ const failed = errors.length;
153
+ return {
154
+ success: succeeded > 0,
155
+ data: {
156
+ summary: {
157
+ total,
158
+ succeeded,
159
+ failed
160
+ },
161
+ results,
162
+ errors
163
+ }
164
+ };
165
+ }
166
+
167
+ // src/errors/base-error.ts
168
+ var BaseError = class extends Error {
169
+ constructor(message) {
170
+ super(message);
171
+ this.name = this.constructor.name;
172
+ if (Error.captureStackTrace) {
173
+ Error.captureStackTrace(this, this.constructor);
174
+ }
175
+ }
176
+ };
177
+
178
+ // src/errors/api-error.ts
179
+ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
180
+ ApiErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
181
+ ApiErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
182
+ ApiErrorCode2["UNAUTHORIZED"] = "UNAUTHORIZED";
183
+ ApiErrorCode2["FORBIDDEN"] = "FORBIDDEN";
184
+ ApiErrorCode2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
185
+ ApiErrorCode2["INVALID_REQUEST"] = "INVALID_REQUEST";
186
+ ApiErrorCode2["RATE_LIMITED"] = "RATE_LIMITED";
187
+ ApiErrorCode2["NOT_FOUND"] = "NOT_FOUND";
188
+ ApiErrorCode2["PLATFORM_ERROR"] = "PLATFORM_ERROR";
189
+ ApiErrorCode2["PLATFORM_UNAVAILABLE"] = "PLATFORM_UNAVAILABLE";
190
+ ApiErrorCode2["CONTENT_POLICY_VIOLATION"] = "CONTENT_POLICY_VIOLATION";
191
+ ApiErrorCode2["DUPLICATE_CONTENT"] = "DUPLICATE_CONTENT";
192
+ ApiErrorCode2["MEDIA_UPLOAD_FAILED"] = "MEDIA_UPLOAD_FAILED";
193
+ ApiErrorCode2["POST_CREATION_FAILED"] = "POST_CREATION_FAILED";
194
+ ApiErrorCode2["THREAD_CREATION_FAILED"] = "THREAD_CREATION_FAILED";
195
+ ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
196
+ ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
197
+ ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
198
+ return ApiErrorCode2;
199
+ })(ApiErrorCode || {});
200
+ var ApiError = class _ApiError extends BaseError {
201
+ constructor(message, code = "INTERNAL_ERROR" /* INTERNAL_ERROR */, status = 500, details, recoverable = false) {
202
+ super(message);
203
+ this.code = code;
204
+ this.status = status;
205
+ this.details = details;
206
+ this.recoverable = recoverable;
207
+ }
208
+ /**
209
+ * Create a validation error
210
+ */
211
+ static validation(message, details) {
212
+ return new _ApiError(
213
+ message,
214
+ "VALIDATION_ERROR" /* VALIDATION_ERROR */,
215
+ 400,
216
+ details,
217
+ true
218
+ );
219
+ }
220
+ /**
221
+ * Create an unauthorized error
222
+ */
223
+ static unauthorized(message = "Unauthorized") {
224
+ return new _ApiError(
225
+ message,
226
+ "UNAUTHORIZED" /* UNAUTHORIZED */,
227
+ 401,
228
+ void 0,
229
+ true
230
+ );
231
+ }
232
+ /**
233
+ * Create a forbidden error
234
+ */
235
+ static forbidden(message = "Forbidden") {
236
+ return new _ApiError(
237
+ message,
238
+ "FORBIDDEN" /* FORBIDDEN */,
239
+ 403,
240
+ void 0,
241
+ false
242
+ );
243
+ }
244
+ /**
245
+ * Create a not found error
246
+ */
247
+ static notFound(message = "Resource not found") {
248
+ return new _ApiError(
249
+ message,
250
+ "NOT_FOUND" /* NOT_FOUND */,
251
+ 404,
252
+ void 0,
253
+ false
254
+ );
255
+ }
256
+ /**
257
+ * Create a rate limit error
258
+ */
259
+ static rateLimited(message = "Rate limit exceeded", details) {
260
+ return new _ApiError(
261
+ message,
262
+ "RATE_LIMITED" /* RATE_LIMITED */,
263
+ 429,
264
+ details,
265
+ true
266
+ );
267
+ }
268
+ /**
269
+ * Create an internal server error
270
+ */
271
+ static internal(message = "Internal server error", details) {
272
+ return new _ApiError(
273
+ message,
274
+ "INTERNAL_ERROR" /* INTERNAL_ERROR */,
275
+ 500,
276
+ details,
277
+ false
278
+ );
279
+ }
280
+ };
281
+
282
+ // src/errors/platform-error.ts
283
+ var PlatformError = class extends Error {
284
+ constructor(message, platform, code = "PLATFORM_ERROR" /* PLATFORM_ERROR */, recoverable = false, originalError, status, userId, details) {
285
+ super(message);
286
+ this.originalError = originalError;
287
+ this.status = status;
288
+ this.name = "PlatformError";
289
+ this.code = code;
290
+ this.recoverable = recoverable;
291
+ this.platform = platform;
292
+ this.userId = userId;
293
+ this.details = details;
294
+ }
295
+ };
296
+
297
+ // src/auth.ts
298
+ import { z as z3 } from "zod";
299
+ var PlatformParamSchema = z3.object({
300
+ platform: z3.string().describe("Social media platform")
301
+ }).describe("Platform parameter");
302
+ var AuthInitRequestSchema = z3.object({
303
+ successUrl: z3.string().url().optional().describe(
304
+ "URL to redirect to on successful authentication"
305
+ ),
306
+ errorUrl: z3.string().url().optional().describe("URL to redirect to on authentication error")
307
+ }).describe("Auth initialization request");
308
+ var AuthUrlResponseSchema = EnhancedResponseSchema(
309
+ z3.object({
310
+ url: z3.string().describe("Authentication URL to redirect the user to"),
311
+ state: z3.string().describe("State parameter for CSRF protection"),
312
+ platform: PlatformSchema
313
+ })
314
+ ).describe("Auth URL response");
315
+ var AuthCallbackQuerySchema = z3.object({
316
+ code: z3.string().describe("Authorization code from OAuth provider"),
317
+ state: z3.string().describe("State parameter for CSRF protection")
318
+ }).describe("Auth callback query");
319
+ var AuthCallbackResponseSchema = EnhancedResponseSchema(
320
+ z3.object({
321
+ success: z3.boolean().describe("Whether the authentication was successful"),
322
+ platform: PlatformSchema,
323
+ userId: z3.string().describe("User ID"),
324
+ redirectUrl: z3.string().optional().describe("URL to redirect the user to after authentication")
325
+ })
326
+ ).describe("Auth callback response");
327
+ var AuthStatusResponseSchema = EnhancedResponseSchema(
328
+ z3.object({
329
+ platform: PlatformSchema,
330
+ userId: z3.string().describe("User ID"),
331
+ authenticated: z3.boolean().describe("Whether the user is authenticated"),
332
+ tokenStatus: z3.object({
333
+ valid: z3.boolean().describe("Whether the token is valid"),
334
+ expired: z3.boolean().describe("Whether the token is expired"),
335
+ expiresAt: z3.string().optional().describe("When the token expires")
336
+ })
337
+ })
338
+ ).describe("Auth status response");
339
+ var AuthRevokeResponseSchema = EnhancedResponseSchema(
340
+ z3.object({
341
+ success: z3.boolean().describe("Whether the revocation was successful"),
342
+ platform: PlatformSchema,
343
+ userId: z3.string().describe("User ID")
344
+ })
345
+ ).describe("Auth revoke response");
346
+ var ConnectedAccountSchema = z3.object({
347
+ platform: PlatformSchema,
348
+ userId: z3.string().describe("User ID on the platform"),
349
+ username: z3.string().optional().describe("Username on the platform (if available)"),
350
+ profileUrl: z3.string().optional().describe("URL to the user profile"),
351
+ connectedAt: z3.string().optional().describe("When the account was connected")
352
+ }).describe("Connected account");
353
+ var ConnectedAccountsResponseSchema = EnhancedResponseSchema(
354
+ z3.array(ConnectedAccountSchema)
355
+ ).describe("Connected accounts response");
356
+ var NearAuthorizationRequestSchema = z3.object({
357
+ // No additional parameters needed, as the NEAR account ID is extracted from the signature
358
+ }).describe("NEAR authorization request");
359
+ var NearAuthorizationResponseSchema = EnhancedResponseSchema(
360
+ z3.object({
361
+ success: z3.boolean().describe("Whether the authorization was successful"),
362
+ nearAccount: z3.string().describe("NEAR account ID"),
363
+ authorized: z3.boolean().describe("Whether the account is authorized")
364
+ })
365
+ ).describe("NEAR authorization response");
366
+ var NearAuthorizationStatusResponseSchema = EnhancedResponseSchema(
367
+ z3.object({
368
+ nearAccount: z3.string().describe("NEAR account ID"),
369
+ authorized: z3.boolean().describe("Whether the account is authorized"),
370
+ authorizedAt: z3.string().optional().describe("When the account was authorized")
371
+ })
372
+ ).describe("NEAR authorization status response");
373
+
374
+ // src/post.ts
375
+ import { z as z4 } from "zod";
376
+ var MediaContentSchema = z4.object({
377
+ data: z4.union([z4.string(), z4.instanceof(Blob)]).describe("Media data as string or Blob"),
378
+ mimeType: z4.string().optional().describe("Media MIME type"),
379
+ altText: z4.string().optional().describe("Alt text for the media")
380
+ }).describe("Media content object");
381
+ var MediaSchema = z4.object({
382
+ id: z4.string().describe("Media ID"),
383
+ type: z4.enum(["image", "video", "gif"]).describe("Media type"),
384
+ url: z4.string().optional().describe("Media URL"),
385
+ altText: z4.string().optional().describe("Alt text for the media")
386
+ }).describe("Media object");
387
+ var PostMetricsSchema = z4.object({
388
+ retweets: z4.number().describe("Number of retweets"),
389
+ quotes: z4.number().describe("Number of quotes"),
390
+ likes: z4.number().describe("Number of likes"),
391
+ replies: z4.number().describe("Number of replies")
392
+ }).describe("Post metrics");
393
+ var PostSchema = z4.object({
394
+ id: z4.string().describe("Post ID"),
395
+ text: z4.string().describe("Post text content"),
396
+ createdAt: z4.string().describe("Post creation date"),
397
+ authorId: z4.string().describe("Author ID"),
398
+ media: z4.array(MediaSchema).optional().describe("Media attached to the post"),
399
+ metrics: PostMetricsSchema.optional().describe("Post metrics"),
400
+ inReplyToId: z4.string().optional().describe("ID of the post this is a reply to"),
401
+ quotedPostId: z4.string().optional().describe("ID of the post this is quoting")
402
+ }).describe("Post object");
403
+ var PostContentSchema = z4.object({
404
+ text: z4.string().optional().describe("Text content for the post"),
405
+ media: z4.array(MediaContentSchema).optional().describe("Media attachments for the post")
406
+ }).describe("Post content");
407
+ var PostResultSchema = z4.object({
408
+ id: z4.string().describe("Post ID"),
409
+ text: z4.string().optional().describe("Post text content"),
410
+ createdAt: z4.string().describe("Post creation date"),
411
+ mediaIds: z4.array(z4.string()).optional().describe("Media IDs attached to the post"),
412
+ threadIds: z4.array(z4.string()).optional().describe("Thread IDs for threaded posts"),
413
+ quotedPostId: z4.string().optional().describe("ID of the post this is quoting"),
414
+ inReplyToId: z4.string().optional().describe("ID of the post this is a reply to"),
415
+ success: z4.boolean().optional().describe("Whether the operation was successful")
416
+ }).catchall(z4.any()).describe("Post result");
417
+ var DeleteResultSchema = z4.object({
418
+ success: z4.boolean().describe("Whether the deletion was successful"),
419
+ id: z4.string().describe("ID of the deleted post")
420
+ }).describe("Delete result");
421
+ var LikeResultSchema = z4.object({
422
+ success: z4.boolean().describe("Whether the like was successful"),
423
+ id: z4.string().describe("ID of the liked post")
424
+ }).describe("Like result");
425
+ var PostSuccessDetailSchema = z4.object({
426
+ platform: PlatformSchema,
427
+ userId: z4.string().describe("User ID"),
428
+ status: z4.literal("success"),
429
+ postId: z4.string().optional().describe("Post ID"),
430
+ postUrl: z4.string().optional().describe("URL to the post")
431
+ }).catchall(z4.any()).describe("Post success detail");
432
+ var TargetSchema = z4.object({
433
+ platform: PlatformSchema.describe('The platform to post to (e.g., "twitter")'),
434
+ userId: z4.string().describe("User ID on the platform")
435
+ }).describe("Target for posting operations");
436
+ var CreatePostRequestSchema = z4.object({
437
+ targets: z4.array(TargetSchema).describe("Array of targets to post to (can be a single target)"),
438
+ content: z4.array(PostContentSchema).describe(
439
+ "The content of the post, always an array of PostContent objects, even for a single post"
440
+ )
441
+ }).describe("Create post request");
442
+ var RepostRequestSchema = z4.object({
443
+ targets: z4.array(TargetSchema).describe("Array of targets to post to"),
444
+ platform: PlatformSchema.describe("Platform of the post being reposted"),
445
+ postId: z4.string().describe("ID of the post to repost")
446
+ }).describe("Repost request");
447
+ var QuotePostRequestSchema = z4.object({
448
+ targets: z4.array(TargetSchema).describe(
449
+ "Array of targets to post to (must be on the same platform as the post being quoted)"
450
+ ),
451
+ platform: PlatformSchema.describe("Platform of the post being quoted"),
452
+ postId: z4.string().describe("ID of the post to quote"),
453
+ content: z4.array(PostContentSchema).describe(
454
+ "Content for the quote post(s), always an array, even for a single post"
455
+ )
456
+ }).describe("Quote post request");
457
+ var ReplyToPostRequestSchema = z4.object({
458
+ targets: z4.array(TargetSchema).describe(
459
+ "Array of targets to post to (must be on the same platform as the post being replied to)"
460
+ ),
461
+ platform: PlatformSchema.describe("Platform of the post being replied to"),
462
+ postId: z4.string().describe("ID of the post to reply to"),
463
+ content: z4.array(PostContentSchema).describe(
464
+ "Content for the reply post(s), always an array, even for a single post"
465
+ )
466
+ }).describe("Reply to post request");
467
+ var PostToDeleteSchema = z4.object({
468
+ platform: PlatformSchema.describe("Platform of the post to delete"),
469
+ userId: z4.string().describe("User ID on the platform"),
470
+ postId: z4.string().describe("ID of the post to delete")
471
+ }).describe("Post to delete");
472
+ var DeletePostRequestSchema = z4.object({
473
+ targets: z4.array(TargetSchema).describe("Array of targets to delete posts"),
474
+ posts: z4.array(PostToDeleteSchema).describe("Array of posts to delete")
475
+ }).describe("Delete post request");
476
+ var LikePostRequestSchema = z4.object({
477
+ targets: z4.array(TargetSchema).describe(
478
+ "Array of targets to like the post (must be on the same platform as the post being liked)"
479
+ ),
480
+ platform: PlatformSchema.describe("Platform of the post being liked"),
481
+ postId: z4.string().describe("ID of the post to like")
482
+ }).describe("Like post request");
483
+ var UnlikePostRequestSchema = z4.object({
484
+ targets: z4.array(TargetSchema).describe(
485
+ "Array of targets to unlike the post (must be on the same platform as the post being unliked)"
486
+ ),
487
+ platform: PlatformSchema.describe("Platform of the post being unliked"),
488
+ postId: z4.string().describe("ID of the post to unlike")
489
+ }).describe("Unlike post request");
490
+ var PostResponseSchema = EnhancedResponseSchema(
491
+ z4.union([PostSchema, z4.array(PostSchema)])
492
+ ).describe("Post response");
493
+ var CreatePostResponseLegacySchema = PostResponseSchema.describe(
494
+ "Create post response (legacy)"
495
+ );
496
+ var RepostResponseSchema = PostResponseSchema.describe("Repost response");
497
+ var QuotePostResponseSchema = PostResponseSchema.describe("Quote post response");
498
+ var ReplyToPostResponseSchema = PostResponseSchema.describe("Reply to post response");
499
+ var DeletePostResponseSchema = EnhancedResponseSchema(
500
+ z4.object({
501
+ success: z4.boolean().describe("Whether the deletion was successful"),
502
+ id: z4.string().describe("ID of the deleted post")
503
+ })
504
+ ).describe("Delete post response");
505
+ var LikePostResponseSchema = EnhancedResponseSchema(
506
+ z4.object({
507
+ success: z4.boolean().describe("Whether the like was successful"),
508
+ id: z4.string().describe("ID of the liked post")
509
+ })
510
+ ).describe("Like post response");
511
+ var UnlikePostResponseSchema = EnhancedResponseSchema(
512
+ z4.object({
513
+ success: z4.boolean().describe("Whether the unlike was successful"),
514
+ id: z4.string().describe("ID of the unliked post")
515
+ })
516
+ ).describe("Unlike post response");
517
+ var PostMultiStatusResponseSchema = z4.object({
518
+ success: z4.boolean().describe("Whether the operation was partially or fully successful"),
519
+ data: z4.object({
520
+ summary: z4.object({
521
+ total: z4.number().describe("Total number of operations"),
522
+ succeeded: z4.number().describe("Number of successful operations"),
523
+ failed: z4.number().describe("Number of failed operations")
524
+ }),
525
+ results: z4.array(PostSuccessDetailSchema).describe("Successful operations"),
526
+ errors: z4.array(ErrorDetailSchema).describe("Failed operations")
527
+ })
528
+ }).describe("Multi-status response for post operations");
529
+ var CreatePostTargetResultSchema = z4.object({
530
+ platform: PlatformSchema.describe("The platform the post was created on"),
531
+ userId: z4.string().describe("The user ID on the platform"),
532
+ result: z4.array(z4.any()).describe("The result of the post creation")
533
+ }).describe("Create post target result");
534
+ var CreatePostTargetErrorSchema = z4.object({
535
+ platform: PlatformSchema.optional().describe(
536
+ "The platform where the error occurred (if applicable)"
537
+ ),
538
+ userId: z4.string().optional().describe("The user ID where the error occurred (if applicable)"),
539
+ error: z4.string().describe("The error message")
540
+ }).describe("Create post target error");
541
+ var CreatePostResponseSchema = EnhancedResponseSchema(
542
+ z4.object({
543
+ results: z4.array(CreatePostTargetResultSchema).describe("Array of successful post results"),
544
+ errors: z4.array(CreatePostTargetErrorSchema).optional().describe(
545
+ "Array of errors that occurred (if any)"
546
+ )
547
+ })
548
+ ).describe("Create post response");
549
+
550
+ // src/rate-limit.ts
551
+ import { z as z5 } from "zod";
552
+ var RateLimitEndpointParamSchema = z5.object({
553
+ endpoint: z5.string().optional().describe(
554
+ "Specific endpoint to get rate limit information for (optional)"
555
+ )
556
+ }).describe("Rate limit endpoint parameter");
557
+ var RateLimitEndpointSchema = z5.object({
558
+ endpoint: z5.string().describe("API endpoint"),
559
+ method: z5.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
560
+ limit: z5.number().describe("Rate limit"),
561
+ remaining: z5.number().describe("Remaining requests"),
562
+ reset: z5.number().describe("Reset timestamp (Unix timestamp in seconds)"),
563
+ resetDate: z5.string().describe("Reset date (ISO string)")
564
+ }).describe("Rate limit endpoint");
565
+ var RateLimitStatusSchema = z5.object({
566
+ endpoint: z5.string().describe("API endpoint or action"),
567
+ limit: z5.number().describe("Maximum number of requests allowed in the time window"),
568
+ remaining: z5.number().describe("Number of requests remaining in the current time window"),
569
+ reset: z5.string().datetime().describe("Timestamp when the rate limit will reset"),
570
+ resetSeconds: z5.number().describe("Seconds until the rate limit will reset")
571
+ }).describe("Rate limit status");
572
+ var PlatformRateLimitSchema = z5.object({
573
+ platform: PlatformSchema,
574
+ endpoints: z5.record(z5.string(), RateLimitStatusSchema).describe(
575
+ "Rate limit status for each endpoint"
576
+ )
577
+ }).describe("Platform-specific rate limit");
578
+ var UsageRateLimitSchema = z5.object({
579
+ endpoint: z5.string().describe("API endpoint or action"),
580
+ limit: z5.number().describe("Maximum number of requests allowed in the time window"),
581
+ remaining: z5.number().describe("Number of requests remaining in the current time window"),
582
+ reset: z5.string().datetime().describe("Timestamp when the rate limit will reset"),
583
+ resetSeconds: z5.number().describe("Seconds until the rate limit will reset"),
584
+ timeWindow: z5.string().describe("Time window for the rate limit")
585
+ }).describe("Usage rate limit");
586
+ var RateLimitStatusResponseSchema = EnhancedResponseSchema(
587
+ z5.object({
588
+ platform: PlatformSchema,
589
+ userId: z5.string().optional().describe("User ID"),
590
+ endpoints: z5.array(RateLimitEndpointSchema).describe("Rate limits for specific endpoints"),
591
+ app: z5.object({
592
+ limit: z5.number().describe("App-wide rate limit"),
593
+ remaining: z5.number().describe("Remaining requests"),
594
+ reset: z5.number().describe("Reset timestamp (Unix timestamp in seconds)"),
595
+ resetDate: z5.string().describe("Reset date (ISO string)")
596
+ }).optional().describe("App-wide rate limits")
597
+ })
598
+ ).describe("Rate limit status response");
599
+ var AllRateLimitsResponseSchema = EnhancedResponseSchema(
600
+ z5.object({
601
+ platforms: z5.record(
602
+ PlatformSchema,
603
+ z5.object({
604
+ users: z5.record(
605
+ z5.string(),
606
+ z5.object({
607
+ endpoints: z5.array(RateLimitEndpointSchema).describe(
608
+ "Rate limits for specific endpoints"
609
+ ),
610
+ lastUpdated: z5.string().describe("Last updated date (ISO string)")
611
+ })
612
+ ).describe("User-specific rate limits"),
613
+ app: z5.object({
614
+ limit: z5.number().describe("App-wide rate limit"),
615
+ remaining: z5.number().describe("Remaining requests"),
616
+ reset: z5.number().describe("Reset timestamp (Unix timestamp in seconds)"),
617
+ resetDate: z5.string().describe("Reset date (ISO string)")
618
+ }).optional().describe("App-wide rate limits")
619
+ })
620
+ ).describe("Rate limits by platform")
621
+ })
622
+ ).describe("All rate limits response");
623
+ var RateLimitResponseSchema = z5.object({
624
+ platformLimits: z5.array(PlatformRateLimitSchema).describe("Platform-specific rate limits"),
625
+ usageLimits: z5.record(z5.string(), UsageRateLimitSchema).describe(
626
+ "Usage-based rate limits for the NEAR account"
627
+ ),
628
+ signerId: z5.string().describe("NEAR account ID")
629
+ }).describe("Rate limit response");
630
+ var EndpointRateLimitResponseSchema = z5.object({
631
+ platformLimits: z5.array(
632
+ z5.object({
633
+ platform: PlatformSchema,
634
+ status: RateLimitStatusSchema.describe("Rate limit status for the endpoint")
635
+ })
636
+ ).describe("Platform-specific rate limits for the endpoint"),
637
+ usageLimit: UsageRateLimitSchema.describe("Usage-based rate limit for the NEAR account"),
638
+ endpoint: z5.string().describe("API endpoint or action"),
639
+ signerId: z5.string().describe("NEAR account ID")
640
+ }).describe("Endpoint rate limit response");
641
+
642
+ // src/leaderboard.ts
643
+ import { z as z6 } from "zod";
644
+ var LeaderboardQuerySchema = z6.object({
645
+ timeframe: z6.enum(["day", "week", "month", "all"]).optional().describe(
646
+ "Timeframe for the leaderboard"
647
+ ),
648
+ 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)"),
649
+ offset: z6.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z6.number().min(0).optional()).describe("Offset for pagination")
650
+ }).describe("Leaderboard query");
651
+ var AccountActivityEntrySchema = z6.object({
652
+ signerId: z6.string().describe("NEAR account ID"),
653
+ totalPosts: z6.number().describe("Total number of posts"),
654
+ totalLikes: z6.number().describe("Total number of likes"),
655
+ totalReposts: z6.number().describe("Total number of reposts"),
656
+ totalReplies: z6.number().describe("Total number of replies"),
657
+ totalQuotes: z6.number().describe("Total number of quote posts"),
658
+ totalScore: z6.number().describe("Total activity score"),
659
+ rank: z6.number().describe("Rank on the leaderboard"),
660
+ lastActive: z6.string().datetime().describe("Timestamp of last activity")
661
+ }).describe("Account activity entry");
662
+ var LeaderboardResponseSchema = EnhancedResponseSchema(
663
+ z6.object({
664
+ timeframe: z6.enum(["day", "week", "month", "all"]).describe("Timeframe for the leaderboard"),
665
+ entries: z6.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
666
+ total: z6.number().describe("Total number of entries in the leaderboard"),
667
+ limit: z6.number().describe("Maximum number of results returned"),
668
+ offset: z6.number().describe("Offset for pagination"),
669
+ generatedAt: z6.string().datetime().describe("Timestamp when the leaderboard was generated")
670
+ })
671
+ ).describe("Leaderboard response");
672
+ var AccountActivityParamsSchema = z6.object({
673
+ signerId: z6.string().describe("NEAR account ID")
674
+ }).describe("Account activity params");
675
+ var AccountActivityQuerySchema = z6.object({
676
+ timeframe: z6.enum(["day", "week", "month", "all"]).optional().describe(
677
+ "Timeframe for the activity"
678
+ )
679
+ }).describe("Account activity query");
680
+ var PlatformActivitySchema = z6.object({
681
+ platform: PlatformSchema,
682
+ posts: z6.number().describe("Number of posts on this platform"),
683
+ likes: z6.number().describe("Number of likes on this platform"),
684
+ reposts: z6.number().describe("Number of reposts on this platform"),
685
+ replies: z6.number().describe("Number of replies on this platform"),
686
+ quotes: z6.number().describe("Number of quote posts on this platform"),
687
+ score: z6.number().describe("Activity score on this platform"),
688
+ lastActive: z6.string().datetime().describe("Timestamp of last activity on this platform")
689
+ }).describe("Platform activity");
690
+ var AccountActivityResponseSchema = EnhancedResponseSchema(
691
+ z6.object({
692
+ signerId: z6.string().describe("NEAR account ID"),
693
+ timeframe: z6.enum(["day", "week", "month", "all"]).describe("Timeframe for the activity"),
694
+ totalPosts: z6.number().describe("Total number of posts across all platforms"),
695
+ totalLikes: z6.number().describe("Total number of likes across all platforms"),
696
+ totalReposts: z6.number().describe("Total number of reposts across all platforms"),
697
+ totalReplies: z6.number().describe("Total number of replies across all platforms"),
698
+ totalQuotes: z6.number().describe("Total number of quote posts across all platforms"),
699
+ totalScore: z6.number().describe("Total activity score across all platforms"),
700
+ rank: z6.number().describe("Rank on the leaderboard"),
701
+ lastActive: z6.string().datetime().describe("Timestamp of last activity across all platforms"),
702
+ platforms: z6.array(PlatformActivitySchema).describe("Activity breakdown by platform")
703
+ })
704
+ ).describe("Account activity response");
705
+ var AccountPostsParamsSchema = z6.object({
706
+ signerId: z6.string().describe("NEAR account ID")
707
+ }).describe("Account posts params");
708
+ var AccountPostsQuerySchema = z6.object({
709
+ platform: z6.string().optional().describe("Filter by platform (optional)"),
710
+ 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)"),
711
+ offset: z6.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z6.number().min(0).optional()).describe("Offset for pagination"),
712
+ type: z6.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
713
+ "Filter by post type (optional)"
714
+ )
715
+ }).describe("Account posts query");
716
+ var AccountPostSchema = z6.object({
717
+ id: z6.string().describe("Post ID"),
718
+ platform: PlatformSchema,
719
+ type: z6.enum(["post", "repost", "reply", "quote", "like"]).describe("Type of post"),
720
+ content: z6.string().optional().describe("Post content (if available)"),
721
+ url: z6.string().url().optional().describe("URL to the post on the platform (if available)"),
722
+ createdAt: z6.string().datetime().describe("Timestamp when the post was created"),
723
+ metrics: z6.object({
724
+ likes: z6.number().optional().describe("Number of likes (if available)"),
725
+ reposts: z6.number().optional().describe("Number of reposts (if available)"),
726
+ replies: z6.number().optional().describe("Number of replies (if available)"),
727
+ quotes: z6.number().optional().describe("Number of quotes (if available)")
728
+ }).optional().describe("Post metrics (if available)"),
729
+ inReplyToId: z6.string().optional().describe("ID of the post this is a reply to (if applicable)"),
730
+ quotedPostId: z6.string().optional().describe("ID of the post this is quoting (if applicable)")
731
+ }).describe("Account post");
732
+ var AccountPostsResponseSchema = EnhancedResponseSchema(
733
+ z6.object({
734
+ signerId: z6.string().describe("NEAR account ID"),
735
+ posts: z6.array(AccountPostSchema).describe("List of posts"),
736
+ total: z6.number().describe("Total number of posts matching the query"),
737
+ limit: z6.number().describe("Maximum number of results returned"),
738
+ offset: z6.number().describe("Offset for pagination"),
739
+ platform: z6.string().optional().describe("Platform filter (if applied)"),
740
+ type: z6.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
741
+ "Post type filter (if applied)"
742
+ )
743
+ })
744
+ ).describe("Account posts response");
745
+
746
+ // src/user-profile.ts
747
+ import { z as z7 } from "zod";
748
+ var UserProfileSchema = z7.object({
749
+ userId: z7.string().describe("User ID on the platform"),
750
+ username: z7.string().describe("Username on the platform"),
751
+ url: z7.string().url().optional().describe("URL to the user profile"),
752
+ profileImageUrl: z7.string().describe("URL to the user profile image"),
753
+ isPremium: z7.boolean().optional().describe("Whether the user has a premium account"),
754
+ platform: PlatformSchema.describe("The platform the user profile is from"),
755
+ lastUpdated: z7.number().describe("Timestamp when the profile was last updated")
756
+ }).describe("User profile");
757
+ var ProfileRefreshResultSchema = z7.object({
758
+ success: z7.boolean().describe("Whether the profile refresh was successful"),
759
+ profile: UserProfileSchema.optional().describe("The refreshed user profile (if successful)"),
760
+ error: z7.string().optional().describe("Error message (if unsuccessful)")
761
+ }).describe("Profile refresh result");
762
+ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
763
+ ProfileRefreshResultSchema
764
+ ).describe("Profile refresh response");
765
+ export {
766
+ AccountActivityEntrySchema,
767
+ AccountActivityParamsSchema,
768
+ AccountActivityQuerySchema,
769
+ AccountActivityResponseSchema,
770
+ AccountPostSchema,
771
+ AccountPostsParamsSchema,
772
+ AccountPostsQuerySchema,
773
+ AccountPostsResponseSchema,
774
+ AllRateLimitsResponseSchema,
775
+ ApiError,
776
+ ApiErrorCode,
777
+ ApiResponseSchema,
778
+ AuthCallbackQuerySchema,
779
+ AuthCallbackResponseSchema,
780
+ AuthInitRequestSchema,
781
+ AuthRevokeResponseSchema,
782
+ AuthStatusResponseSchema,
783
+ AuthUrlResponseSchema,
784
+ BaseError,
785
+ ConnectedAccountSchema,
786
+ ConnectedAccountsResponseSchema,
787
+ CreatePostRequestSchema,
788
+ CreatePostResponseLegacySchema,
789
+ CreatePostResponseSchema,
790
+ CreatePostTargetErrorSchema,
791
+ CreatePostTargetResultSchema,
792
+ DeletePostRequestSchema,
793
+ DeletePostResponseSchema,
794
+ DeleteResultSchema,
795
+ EndpointRateLimitResponseSchema,
796
+ EnhancedErrorResponseSchema,
797
+ EnhancedResponseMetaSchema,
798
+ EnhancedResponseSchema,
799
+ ErrorDetailSchema,
800
+ ErrorResponseSchema,
801
+ LeaderboardQuerySchema,
802
+ LeaderboardResponseSchema,
803
+ LikePostRequestSchema,
804
+ LikePostResponseSchema,
805
+ LikeResultSchema,
806
+ MediaContentSchema,
807
+ MediaSchema,
808
+ MultiStatusResponseSchema,
809
+ NearAuthorizationRequestSchema,
810
+ NearAuthorizationResponseSchema,
811
+ NearAuthorizationStatusResponseSchema,
812
+ Platform,
813
+ PlatformActivitySchema,
814
+ PlatformError,
815
+ PlatformParamSchema,
816
+ PlatformRateLimitSchema,
817
+ PlatformSchema,
818
+ PostContentSchema,
819
+ PostMetricsSchema,
820
+ PostMultiStatusResponseSchema,
821
+ PostResponseSchema,
822
+ PostResultSchema,
823
+ PostSchema,
824
+ PostSuccessDetailSchema,
825
+ PostToDeleteSchema,
826
+ ProfileRefreshResponseSchema,
827
+ ProfileRefreshResultSchema,
828
+ QuotePostRequestSchema,
829
+ QuotePostResponseSchema,
830
+ RateLimitEndpointParamSchema,
831
+ RateLimitEndpointSchema,
832
+ RateLimitResponseSchema,
833
+ RateLimitStatusResponseSchema,
834
+ RateLimitStatusSchema,
835
+ ReplyToPostRequestSchema,
836
+ ReplyToPostResponseSchema,
837
+ RepostRequestSchema,
838
+ RepostResponseSchema,
839
+ SuccessDetailSchema,
840
+ TargetSchema,
841
+ UnlikePostRequestSchema,
842
+ UnlikePostResponseSchema,
843
+ UsageRateLimitSchema,
844
+ UserProfileSchema,
845
+ createApiResponse,
846
+ createEnhancedApiResponse,
847
+ createEnhancedErrorResponse,
848
+ createErrorDetail,
849
+ createErrorResponse,
850
+ createMultiStatusResponse,
851
+ createSuccessDetail
852
+ };