@crosspost/types 0.1.14 → 0.2.1

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 CHANGED
@@ -42,6 +42,8 @@ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
42
42
  ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
43
43
  ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
44
44
  ApiErrorCode2["INVALID_RESPONSE"] = "INVALID_RESPONSE";
45
+ ApiErrorCode2["TOKEN_REFRESH_FAILED"] = "TOKEN_REFRESH_FAILED";
46
+ ApiErrorCode2["PROFILE_REFRESH_FAILED"] = "PROFILE_REFRESH_FAILED";
45
47
  return ApiErrorCode2;
46
48
  })(ApiErrorCode || {});
47
49
  var ApiErrorCodeSchema = z2.enum(Object.values(ApiErrorCode));
@@ -65,7 +67,9 @@ var errorCodeToStatusCode = {
65
67
  ["POST_DELETION_FAILED" /* POST_DELETION_FAILED */]: 500,
66
68
  ["POST_INTERACTION_FAILED" /* POST_INTERACTION_FAILED */]: 500,
67
69
  ["NETWORK_ERROR" /* NETWORK_ERROR */]: 503,
68
- ["INVALID_RESPONSE" /* INVALID_RESPONSE */]: 500
70
+ ["INVALID_RESPONSE" /* INVALID_RESPONSE */]: 500,
71
+ ["TOKEN_REFRESH_FAILED" /* TOKEN_REFRESH_FAILED */]: 500,
72
+ ["PROFILE_REFRESH_FAILED" /* PROFILE_REFRESH_FAILED */]: 500
69
73
  };
70
74
  var ErrorDetailSchema = z2.object({
71
75
  message: z2.string().describe("Human-readable error message"),
@@ -84,20 +88,15 @@ var ResponseMetaSchema = z3.object({
84
88
  reset: z3.number().int().positive().describe("Unix timestamp (seconds)")
85
89
  }).optional().describe("Rate limit information if applicable"),
86
90
  pagination: z3.object({
87
- page: z3.number().int().positive().optional(),
88
- perPage: z3.number().int().positive().optional(),
89
- total: z3.number().int().nonnegative().optional(),
90
91
  limit: z3.number().int().nonnegative().optional(),
91
92
  offset: z3.number().int().nonnegative().optional(),
92
- totalPages: z3.number().int().nonnegative().optional(),
93
- nextCursor: z3.string().optional(),
94
- prevCursor: z3.string().optional()
93
+ total: z3.number().int().nonnegative().optional()
95
94
  }).optional().describe("Pagination information if applicable")
96
95
  });
97
96
  var SuccessDetailSchema = z3.object({
98
97
  platform: z3.string(),
99
98
  userId: z3.string(),
100
- additionalData: z3.any().optional(),
99
+ details: z3.any().optional(),
101
100
  status: z3.literal("success")
102
101
  }).catchall(z3.any());
103
102
  var HealthStatusSchema = z3.object({
@@ -105,12 +104,13 @@ var HealthStatusSchema = z3.object({
105
104
  version: z3.string().optional().describe("API version"),
106
105
  timestamp: z3.string().datetime().describe("Current server time")
107
106
  }).describe("Health status response");
107
+ var MultiStatusSummarySchema = z3.object({
108
+ total: z3.number().int().nonnegative(),
109
+ succeeded: z3.number().int().nonnegative(),
110
+ failed: z3.number().int().nonnegative()
111
+ });
108
112
  var MultiStatusDataSchema = z3.object({
109
- summary: z3.object({
110
- total: z3.number().int().nonnegative(),
111
- succeeded: z3.number().int().nonnegative(),
112
- failed: z3.number().int().nonnegative()
113
- }),
113
+ summary: MultiStatusSummarySchema,
114
114
  results: z3.array(SuccessDetailSchema),
115
115
  errors: z3.array(ErrorDetailSchema)
116
116
  });
@@ -262,13 +262,6 @@ var LikeResultSchema = z6.object({
262
262
  success: z6.boolean().describe("Whether the like was successful"),
263
263
  id: z6.string().describe("ID of the liked post")
264
264
  }).describe("Like result");
265
- var PostSuccessDetailSchema = z6.object({
266
- platform: PlatformSchema,
267
- userId: z6.string().describe("User ID"),
268
- status: z6.literal("success"),
269
- postId: z6.string().optional().describe("Post ID"),
270
- postUrl: z6.string().optional().describe("URL to the post")
271
- }).catchall(z6.any()).describe("Post success detail");
272
265
  var TargetSchema = z6.object({
273
266
  platform: PlatformSchema.describe('The platform to post to (e.g., "twitter")'),
274
267
  userId: z6.string().describe("User ID on the platform")
@@ -345,15 +338,6 @@ var LikePostResponseSchema = z6.object({
345
338
  var UnlikePostResponseSchema = z6.object({
346
339
  id: z6.string().describe("ID of the unliked post")
347
340
  }).describe("Unlike post response");
348
- var PostMultiStatusResponseSchema = z6.object({
349
- summary: z6.object({
350
- total: z6.number().describe("Total number of operations"),
351
- succeeded: z6.number().describe("Number of successful operations"),
352
- failed: z6.number().describe("Number of failed operations")
353
- }),
354
- results: z6.array(PostSuccessDetailSchema).describe("Successful operations"),
355
- errors: z6.array(ErrorDetailSchema).describe("Failed operations")
356
- }).describe("Multi-status response for post operations");
357
341
 
358
342
  // src/rate-limit.ts
359
343
  import { z as z7 } from "zod";
@@ -445,6 +429,16 @@ var EndpointRateLimitResponseSchema = z7.object({
445
429
 
446
430
  // src/activity.ts
447
431
  import { z as z8 } from "zod";
432
+ var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
433
+ ActivityType2["POST"] = "post";
434
+ ActivityType2["REPOST"] = "repost";
435
+ ActivityType2["REPLY"] = "reply";
436
+ ActivityType2["QUOTE"] = "quote";
437
+ ActivityType2["LIKE"] = "like";
438
+ ActivityType2["UNLIKE"] = "unlike";
439
+ ActivityType2["DELETE"] = "delete";
440
+ return ActivityType2;
441
+ })(ActivityType || {});
448
442
  var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
449
443
  TimePeriod2["ALL"] = "all";
450
444
  TimePeriod2["YEARLY"] = "year";
@@ -453,13 +447,45 @@ var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
453
447
  TimePeriod2["DAILY"] = "day";
454
448
  return TimePeriod2;
455
449
  })(TimePeriod || {});
456
- var ActivityLeaderboardQuerySchema = z8.object({
457
- timeframe: z8.nativeEnum(TimePeriod).optional().describe(
458
- "Timeframe for the leaderboard"
459
- ),
450
+ var FilterSchema = z8.object({
451
+ platforms: z8.string().optional().transform((val) => {
452
+ if (!val) return void 0;
453
+ return val.split(",").map((p) => p.trim()).map((p) => {
454
+ try {
455
+ return Platform[p.toUpperCase()];
456
+ } catch (_e) {
457
+ return p;
458
+ }
459
+ });
460
+ }).pipe(
461
+ z8.array(z8.nativeEnum(Platform)).optional()
462
+ ).describe("Filter by platforms (comma-separated list, optional)"),
463
+ types: z8.string().optional().transform((val) => {
464
+ if (!val) return void 0;
465
+ return val.split(",").map((t) => t.trim()).map((t) => {
466
+ try {
467
+ return ActivityType[t.toUpperCase()];
468
+ } catch (_e) {
469
+ return t;
470
+ }
471
+ });
472
+ }).pipe(
473
+ z8.array(z8.nativeEnum(ActivityType)).optional()
474
+ ).describe("Filter by activity types (comma-separated list, optional)"),
475
+ timeframe: z8.nativeEnum(TimePeriod).optional().transform((val) => {
476
+ if (!val) return "all" /* ALL */;
477
+ return val;
478
+ }).describe(
479
+ "Timeframe for filtering (optional)"
480
+ )
481
+ }).describe("Filter parameters");
482
+ var PaginationSchema = z8.object({
460
483
  limit: z8.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z8.number().min(1).max(100).optional()).describe("Maximum number of results to return (1-100)"),
461
484
  offset: z8.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z8.number().min(0).optional()).describe("Offset for pagination")
462
- }).describe("Activity leaderboard query");
485
+ }).describe("Pagination parameters");
486
+ var ActivityLeaderboardQuerySchema = z8.object({
487
+ filter: FilterSchema.optional()
488
+ }).describe("Account leaderboard query").merge(PaginationSchema);
463
489
  var AccountActivityEntrySchema = z8.object({
464
490
  signerId: z8.string().describe("NEAR account ID"),
465
491
  totalPosts: z8.number().describe("Total number of posts"),
@@ -469,22 +495,21 @@ var AccountActivityEntrySchema = z8.object({
469
495
  totalQuotes: z8.number().describe("Total number of quote posts"),
470
496
  totalScore: z8.number().describe("Total activity score"),
471
497
  rank: z8.number().describe("Rank on the leaderboard"),
472
- lastActive: z8.string().datetime().describe("Timestamp of last activity")
498
+ lastActive: z8.string().datetime().describe("Timestamp of last activity"),
499
+ firstPostTimestamp: z8.string().datetime().describe("Timestamp of the first post")
473
500
  }).describe("Account activity entry");
474
501
  var ActivityLeaderboardResponseSchema = z8.object({
475
502
  timeframe: z8.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
476
503
  entries: z8.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
477
504
  generatedAt: z8.string().datetime().describe("Timestamp when the leaderboard was generated"),
478
- platform: PlatformSchema.optional().describe("Platform filter (if applied)")
505
+ platforms: z8.array(PlatformSchema).optional().describe("Platform filters (if applied)")
479
506
  });
480
507
  var AccountActivityParamsSchema = z8.object({
481
508
  signerId: z8.string().describe("NEAR account ID")
482
509
  }).describe("Account activity params");
483
510
  var AccountActivityQuerySchema = z8.object({
484
- timeframe: z8.nativeEnum(TimePeriod).optional().describe(
485
- "Timeframe for the activity"
486
- )
487
- }).describe("Account activity query");
511
+ filter: FilterSchema.optional()
512
+ }).describe("Account activity query").merge(PaginationSchema);
488
513
  var PlatformActivitySchema = z8.object({
489
514
  platform: PlatformSchema,
490
515
  posts: z8.number().describe("Number of posts on this platform"),
@@ -512,17 +537,13 @@ var AccountPostsParamsSchema = z8.object({
512
537
  signerId: z8.string().describe("NEAR account ID")
513
538
  }).describe("Account posts params");
514
539
  var AccountPostsQuerySchema = z8.object({
515
- platform: z8.string().optional().describe("Filter by platform (optional)"),
516
- limit: z8.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z8.number().min(1).max(100).optional()).describe("Maximum number of results to return (1-100)"),
517
- offset: z8.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z8.number().min(0).optional()).describe("Offset for pagination"),
518
- type: z8.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
519
- "Filter by post type (optional)"
520
- )
521
- }).describe("Account posts query");
540
+ filter: FilterSchema.optional()
541
+ }).describe("Account posts query").merge(PaginationSchema);
522
542
  var AccountPostSchema = z8.object({
523
543
  id: z8.string().describe("Post ID"),
524
544
  platform: PlatformSchema,
525
- type: z8.enum(["post", "repost", "reply", "quote", "like"]).describe("Type of post"),
545
+ userId: z8.string().describe("User ID on the platform"),
546
+ type: z8.nativeEnum(ActivityType).describe("Type of post"),
526
547
  content: z8.string().optional().describe("Post content (if available)"),
527
548
  url: z8.string().url().optional().describe("URL to the post on the platform (if available)"),
528
549
  createdAt: z8.string().datetime().describe("Timestamp when the post was created"),
@@ -538,10 +559,8 @@ var AccountPostSchema = z8.object({
538
559
  var AccountPostsResponseSchema = z8.object({
539
560
  signerId: z8.string().describe("NEAR account ID"),
540
561
  posts: z8.array(AccountPostSchema).describe("List of posts"),
541
- platform: z8.string().optional().describe("Platform filter (if applied)"),
542
- type: z8.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
543
- "Post type filter (if applied)"
544
- )
562
+ platforms: z8.array(z8.string()).optional().describe("Platform filters (if applied)"),
563
+ types: z8.array(z8.string()).optional().describe("Post type filters (if applied)")
545
564
  });
546
565
  export {
547
566
  AccountActivityEntrySchema,
@@ -551,6 +570,7 @@ export {
551
570
  AccountPostsParamsSchema,
552
571
  AccountPostsQuerySchema,
553
572
  ActivityLeaderboardQuerySchema,
573
+ ActivityType,
554
574
  AllRateLimitsResponseSchema,
555
575
  ApiErrorCode,
556
576
  ApiErrorCodeSchema,
@@ -572,6 +592,7 @@ export {
572
592
  DeleteResultSchema,
573
593
  EndpointRateLimitResponseSchema,
574
594
  ErrorDetailSchema,
595
+ FilterSchema,
575
596
  HealthStatusSchema,
576
597
  LikePostRequestSchema,
577
598
  LikePostResponseSchema,
@@ -579,10 +600,12 @@ export {
579
600
  MediaContentSchema,
580
601
  MediaSchema,
581
602
  MultiStatusDataSchema,
603
+ MultiStatusSummarySchema,
582
604
  NearAuthorizationRequestSchema,
583
605
  NearAuthorizationResponseSchema,
584
606
  NearAuthorizationStatusResponseSchema,
585
607
  NearUnauthorizationResponseSchema,
608
+ PaginationSchema,
586
609
  Platform,
587
610
  PlatformActivitySchema,
588
611
  PlatformParamSchema,
@@ -590,11 +613,9 @@ export {
590
613
  PlatformSchema,
591
614
  PostContentSchema,
592
615
  PostMetricsSchema,
593
- PostMultiStatusResponseSchema,
594
616
  PostResponseSchema,
595
617
  PostResultSchema,
596
618
  PostSchema,
597
- PostSuccessDetailSchema,
598
619
  PostToDeleteSchema,
599
620
  ProfileRefreshResponseSchema,
600
621
  QuotePostRequestSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crosspost/types",
3
- "version": "0.1.14",
3
+ "version": "0.2.1",
4
4
  "description": "Shared type definitions for Crosspost API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/activity.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import { z } from 'zod';
2
- import { PlatformSchema } from './common.ts';
2
+ import { Platform, PlatformSchema } from './common.ts';
3
+
4
+ export enum ActivityType {
5
+ POST = 'post',
6
+ REPOST = 'repost',
7
+ REPLY = 'reply',
8
+ QUOTE = 'quote',
9
+ LIKE = 'like',
10
+ UNLIKE = 'unlike',
11
+ DELETE = 'delete',
12
+ }
3
13
 
4
14
  export enum TimePeriod {
5
15
  ALL = 'all',
@@ -9,10 +19,57 @@ export enum TimePeriod {
9
19
  DAILY = 'day',
10
20
  }
11
21
 
12
- export const ActivityLeaderboardQuerySchema = z.object({
13
- timeframe: z.nativeEnum(TimePeriod).optional().describe(
14
- 'Timeframe for the leaderboard',
22
+ /**
23
+ * Schema for filtering by platform, activity type, and timeframe
24
+ * Handles comma-separated lists for platforms and types
25
+ */
26
+ export const FilterSchema = z.object({
27
+ platforms: z.string().optional()
28
+ .transform((val) => {
29
+ if (!val) return undefined;
30
+ return val.split(',')
31
+ .map((p) => p.trim())
32
+ .map((p) => {
33
+ try {
34
+ return Platform[p.toUpperCase() as keyof typeof Platform];
35
+ } catch (_e) {
36
+ return p;
37
+ }
38
+ });
39
+ })
40
+ .pipe(
41
+ z.array(z.nativeEnum(Platform)).optional(),
42
+ )
43
+ .describe('Filter by platforms (comma-separated list, optional)'),
44
+ types: z.string().optional()
45
+ .transform((val) => {
46
+ if (!val) return undefined;
47
+ return val.split(',')
48
+ .map((t) => t.trim())
49
+ .map((t) => {
50
+ try {
51
+ return ActivityType[t.toUpperCase() as keyof typeof ActivityType];
52
+ } catch (_e) {
53
+ return t;
54
+ }
55
+ });
56
+ })
57
+ .pipe(
58
+ z.array(z.nativeEnum(ActivityType)).optional(),
59
+ )
60
+ .describe('Filter by activity types (comma-separated list, optional)'),
61
+ timeframe: z.nativeEnum(TimePeriod).optional().transform((val) => {
62
+ if (!val) return TimePeriod.ALL;
63
+ return val;
64
+ }).describe(
65
+ 'Timeframe for filtering (optional)',
15
66
  ),
67
+ }).describe('Filter parameters');
68
+
69
+ /**
70
+ * Common pagination schema used across queries
71
+ */
72
+ export const PaginationSchema = z.object({
16
73
  limit: z.string().optional()
17
74
  .transform((val) => val ? parseInt(val, 10) : undefined)
18
75
  .pipe(z.number().min(1).max(100).optional())
@@ -21,7 +78,14 @@ export const ActivityLeaderboardQuerySchema = z.object({
21
78
  .transform((val) => val ? parseInt(val, 10) : undefined)
22
79
  .pipe(z.number().min(0).optional())
23
80
  .describe('Offset for pagination'),
24
- }).describe('Activity leaderboard query');
81
+ }).describe('Pagination parameters');
82
+
83
+ /**
84
+ * Query schema for leaderboard endpoints
85
+ */
86
+ export const ActivityLeaderboardQuerySchema = z.object({
87
+ filter: FilterSchema.optional(),
88
+ }).describe('Account leaderboard query').merge(PaginationSchema);
25
89
 
26
90
  export const AccountActivityEntrySchema = z.object({
27
91
  signerId: z.string().describe('NEAR account ID'),
@@ -33,24 +97,26 @@ export const AccountActivityEntrySchema = z.object({
33
97
  totalScore: z.number().describe('Total activity score'),
34
98
  rank: z.number().describe('Rank on the leaderboard'),
35
99
  lastActive: z.string().datetime().describe('Timestamp of last activity'),
100
+ firstPostTimestamp: z.string().datetime().describe('Timestamp of the first post'),
36
101
  }).describe('Account activity entry');
37
102
 
38
103
  const ActivityLeaderboardResponseSchema = z.object({
39
104
  timeframe: z.nativeEnum(TimePeriod).describe('Timeframe for the leaderboard'),
40
105
  entries: z.array(AccountActivityEntrySchema).describe('Leaderboard entries'),
41
106
  generatedAt: z.string().datetime().describe('Timestamp when the leaderboard was generated'),
42
- platform: PlatformSchema.optional().describe('Platform filter (if applied)'),
107
+ platforms: z.array(PlatformSchema).optional().describe('Platform filters (if applied)'),
43
108
  });
44
109
 
45
110
  export const AccountActivityParamsSchema = z.object({
46
111
  signerId: z.string().describe('NEAR account ID'),
47
112
  }).describe('Account activity params');
48
113
 
114
+ /**
115
+ * Query schema for account activity endpoints
116
+ */
49
117
  export const AccountActivityQuerySchema = z.object({
50
- timeframe: z.nativeEnum(TimePeriod).optional().describe(
51
- 'Timeframe for the activity',
52
- ),
53
- }).describe('Account activity query');
118
+ filter: FilterSchema.optional(),
119
+ }).describe('Account activity query').merge(PaginationSchema);
54
120
 
55
121
  export const PlatformActivitySchema = z.object({
56
122
  platform: PlatformSchema,
@@ -81,25 +147,18 @@ export const AccountPostsParamsSchema = z.object({
81
147
  signerId: z.string().describe('NEAR account ID'),
82
148
  }).describe('Account posts params');
83
149
 
150
+ /**
151
+ * Query schema for account posts endpoints
152
+ */
84
153
  export const AccountPostsQuerySchema = z.object({
85
- platform: z.string().optional().describe('Filter by platform (optional)'),
86
- limit: z.string().optional()
87
- .transform((val) => val ? parseInt(val, 10) : undefined)
88
- .pipe(z.number().min(1).max(100).optional())
89
- .describe('Maximum number of results to return (1-100)'),
90
- offset: z.string().optional()
91
- .transform((val) => val ? parseInt(val, 10) : undefined)
92
- .pipe(z.number().min(0).optional())
93
- .describe('Offset for pagination'),
94
- type: z.enum(['post', 'repost', 'reply', 'quote', 'like', 'all']).optional().describe(
95
- 'Filter by post type (optional)',
96
- ),
97
- }).describe('Account posts query');
154
+ filter: FilterSchema.optional(),
155
+ }).describe('Account posts query').merge(PaginationSchema);
98
156
 
99
157
  export const AccountPostSchema = z.object({
100
158
  id: z.string().describe('Post ID'),
101
159
  platform: PlatformSchema,
102
- type: z.enum(['post', 'repost', 'reply', 'quote', 'like']).describe('Type of post'),
160
+ userId: z.string().describe('User ID on the platform'),
161
+ type: z.nativeEnum(ActivityType).describe('Type of post'),
103
162
  content: z.string().optional().describe('Post content (if available)'),
104
163
  url: z.string().url().optional().describe('URL to the post on the platform (if available)'),
105
164
  createdAt: z.string().datetime().describe('Timestamp when the post was created'),
@@ -116,10 +175,8 @@ export const AccountPostSchema = z.object({
116
175
  const AccountPostsResponseSchema = z.object({
117
176
  signerId: z.string().describe('NEAR account ID'),
118
177
  posts: z.array(AccountPostSchema).describe('List of posts'),
119
- platform: z.string().optional().describe('Platform filter (if applied)'),
120
- type: z.enum(['post', 'repost', 'reply', 'quote', 'like', 'all']).optional().describe(
121
- 'Post type filter (if applied)',
122
- ),
178
+ platforms: z.array(z.string()).optional().describe('Platform filters (if applied)'),
179
+ types: z.array(z.string()).optional().describe('Post type filters (if applied)'),
123
180
  });
124
181
 
125
182
  /**
@@ -147,6 +204,7 @@ export interface PostRecord {
147
204
  p: string; // platform
148
205
  t: number; // timestamp
149
206
  u: string; // userId
207
+ ty: string; // activity type ('post', 'like', 'repost', etc.)
150
208
  }
151
209
 
152
210
  export type ActivityLeaderboardQuery = z.infer<typeof ActivityLeaderboardQuerySchema>;
@@ -160,3 +218,4 @@ export type AccountPostsParams = z.infer<typeof AccountPostsParamsSchema>;
160
218
  export type AccountPostsQuery = z.infer<typeof AccountPostsQuerySchema>;
161
219
  export type AccountPost = z.infer<typeof AccountPostSchema>;
162
220
  export type AccountPostsResponse = z.infer<typeof AccountPostsResponseSchema>;
221
+ export type Filter = z.infer<typeof FilterSchema>;
package/src/errors.ts CHANGED
@@ -45,6 +45,10 @@ export enum ApiErrorCode {
45
45
 
46
46
  // Response format errors
47
47
  INVALID_RESPONSE = 'INVALID_RESPONSE',
48
+
49
+ // Refresh errors
50
+ TOKEN_REFRESH_FAILED = 'TOKEN_REFRESH_FAILED',
51
+ PROFILE_REFRESH_FAILED = 'PROFILE_REFRESH_FAILED',
48
52
  }
49
53
 
50
54
  export const ApiErrorCodeSchema = z.enum(Object.values(ApiErrorCode) as [string, ...string[]]);
@@ -74,6 +78,8 @@ export const errorCodeToStatusCode: Record<ApiErrorCode, StatusCode> = {
74
78
  [ApiErrorCode.POST_INTERACTION_FAILED]: 500,
75
79
  [ApiErrorCode.NETWORK_ERROR]: 503,
76
80
  [ApiErrorCode.INVALID_RESPONSE]: 500,
81
+ [ApiErrorCode.TOKEN_REFRESH_FAILED]: 500,
82
+ [ApiErrorCode.PROFILE_REFRESH_FAILED]: 500,
77
83
  };
78
84
 
79
85
  /**
package/src/post.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
2
  import { PlatformSchema } from './common.ts';
3
- import { ErrorDetailSchema } from './errors.ts';
4
3
 
5
4
  export const MediaContentSchema = z.object({
6
5
  data: z.union([z.string(), z.instanceof(Blob)]).describe('Media data as string or Blob'),
@@ -59,14 +58,6 @@ export const LikeResultSchema = z.object({
59
58
  id: z.string().describe('ID of the liked post'),
60
59
  }).describe('Like result');
61
60
 
62
- export const PostSuccessDetailSchema = z.object({
63
- platform: PlatformSchema,
64
- userId: z.string().describe('User ID'),
65
- status: z.literal('success'),
66
- postId: z.string().optional().describe('Post ID'),
67
- postUrl: z.string().optional().describe('URL to the post'),
68
- }).catchall(z.any()).describe('Post success detail');
69
-
70
61
  export const TargetSchema = z.object({
71
62
  platform: PlatformSchema.describe('The platform to post to (e.g., "twitter")'),
72
63
  userId: z.string().describe('User ID on the platform'),
@@ -160,16 +151,6 @@ export const UnlikePostResponseSchema = z.object({
160
151
  id: z.string().describe('ID of the unliked post'),
161
152
  }).describe('Unlike post response');
162
153
 
163
- export const PostMultiStatusResponseSchema = z.object({
164
- summary: z.object({
165
- total: z.number().describe('Total number of operations'),
166
- succeeded: z.number().describe('Number of successful operations'),
167
- failed: z.number().describe('Number of failed operations'),
168
- }),
169
- results: z.array(PostSuccessDetailSchema).describe('Successful operations'),
170
- errors: z.array(ErrorDetailSchema).describe('Failed operations'),
171
- }).describe('Multi-status response for post operations');
172
-
173
154
  export type Media = z.infer<typeof MediaSchema>;
174
155
  export type MediaContent = z.infer<typeof MediaContentSchema>;
175
156
  export type PostMetrics = z.infer<typeof PostMetricsSchema>;
@@ -178,7 +159,6 @@ export type PostContent = z.infer<typeof PostContentSchema>;
178
159
  export type PostResult = z.infer<typeof PostResultSchema>;
179
160
  export type DeleteResult = z.infer<typeof DeleteResultSchema>;
180
161
  export type LikeResult = z.infer<typeof LikeResultSchema>;
181
- export type PostSuccessDetail = z.infer<typeof PostSuccessDetailSchema>;
182
162
  export type Target = z.infer<typeof TargetSchema>;
183
163
  export type PostToDelete = z.infer<typeof PostToDeleteSchema>;
184
164
 
@@ -190,7 +170,6 @@ export type DeletePostRequest = z.infer<typeof DeletePostRequestSchema>;
190
170
  export type LikePostRequest = z.infer<typeof LikePostRequestSchema>;
191
171
  export type UnlikePostRequest = z.infer<typeof UnlikePostRequestSchema>;
192
172
 
193
- export type PostResponse = z.infer<typeof PostResponseSchema>;
194
173
  export type CreatePostResponse = z.infer<typeof CreatePostResponseSchema>;
195
174
  export type RepostResponse = z.infer<typeof RepostResponseSchema>;
196
175
  export type QuotePostResponse = z.infer<typeof QuotePostResponseSchema>;
@@ -198,4 +177,3 @@ export type ReplyToPostResponse = z.infer<typeof ReplyToPostResponseSchema>;
198
177
  export type DeletePostResponse = z.infer<typeof DeletePostResponseSchema>;
199
178
  export type LikePostResponse = z.infer<typeof LikePostResponseSchema>;
200
179
  export type UnlikePostResponse = z.infer<typeof UnlikePostResponseSchema>;
201
- export type PostMultiStatusResponse = z.infer<typeof PostMultiStatusResponseSchema>;
package/src/response.ts CHANGED
@@ -10,21 +10,16 @@ export const ResponseMetaSchema = z.object({
10
10
  reset: z.number().int().positive().describe('Unix timestamp (seconds)'),
11
11
  }).optional().describe('Rate limit information if applicable'),
12
12
  pagination: z.object({
13
- page: z.number().int().positive().optional(),
14
- perPage: z.number().int().positive().optional(),
15
- total: z.number().int().nonnegative().optional(),
16
13
  limit: z.number().int().nonnegative().optional(),
17
14
  offset: z.number().int().nonnegative().optional(),
18
- totalPages: z.number().int().nonnegative().optional(),
19
- nextCursor: z.string().optional(),
20
- prevCursor: z.string().optional(),
15
+ total: z.number().int().nonnegative().optional(),
21
16
  }).optional().describe('Pagination information if applicable'),
22
17
  });
23
18
 
24
19
  export const SuccessDetailSchema = z.object({
25
20
  platform: z.string(),
26
21
  userId: z.string(),
27
- additionalData: z.any().optional(),
22
+ details: z.any().optional(),
28
23
  status: z.literal('success'),
29
24
  }).catchall(z.any());
30
25
 
@@ -34,24 +29,27 @@ export const HealthStatusSchema = z.object({
34
29
  timestamp: z.string().datetime().describe('Current server time'),
35
30
  }).describe('Health status response');
36
31
 
32
+ export const MultiStatusSummarySchema = z.object({
33
+ total: z.number().int().nonnegative(),
34
+ succeeded: z.number().int().nonnegative(),
35
+ failed: z.number().int().nonnegative(),
36
+ });
37
+
37
38
  export const MultiStatusDataSchema = z.object({
38
- summary: z.object({
39
- total: z.number().int().nonnegative(),
40
- succeeded: z.number().int().nonnegative(),
41
- failed: z.number().int().nonnegative(),
42
- }),
39
+ summary: MultiStatusSummarySchema,
43
40
  results: z.array(SuccessDetailSchema),
44
41
  errors: z.array(ErrorDetailSchema),
45
42
  });
46
43
 
47
44
  export interface ApiResponse<T> {
48
45
  success: boolean;
49
- data?: T | MultiStatusData | null; // Allow null for success without data
46
+ data?: T | MultiStatusData | null; // Allow null for success without data, updated type name
50
47
  errors?: ErrorDetail[] | null; // Allow null for success
51
48
  meta: ResponseMeta; // Mandatory, holds request id
52
49
  }
53
50
 
54
51
  export type ResponseMeta = z.infer<typeof ResponseMetaSchema>;
55
52
  export type SuccessDetail = z.infer<typeof SuccessDetailSchema>;
56
- export type MultiStatusData = z.infer<typeof MultiStatusDataSchema>;
53
+ export type MultiStatusSummary = z.infer<typeof MultiStatusSummarySchema>;
54
+ export type MultiStatusData = z.infer<typeof MultiStatusDataSchema>; // Renamed type
57
55
  export type HealthStatus = z.infer<typeof HealthStatusSchema>;