@crosspost/types 0.2.0 → 0.2.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 CHANGED
@@ -88,14 +88,9 @@ var ResponseMetaSchema = z3.object({
88
88
  reset: z3.number().int().positive().describe("Unix timestamp (seconds)")
89
89
  }).optional().describe("Rate limit information if applicable"),
90
90
  pagination: z3.object({
91
- page: z3.number().int().positive().optional(),
92
- perPage: z3.number().int().positive().optional(),
93
- total: z3.number().int().nonnegative().optional(),
94
91
  limit: z3.number().int().nonnegative().optional(),
95
92
  offset: z3.number().int().nonnegative().optional(),
96
- totalPages: z3.number().int().nonnegative().optional(),
97
- nextCursor: z3.string().optional(),
98
- prevCursor: z3.string().optional()
93
+ total: z3.number().int().nonnegative().optional()
99
94
  }).optional().describe("Pagination information if applicable")
100
95
  });
101
96
  var SuccessDetailSchema = z3.object({
@@ -207,12 +202,12 @@ var NearAuthorizationRequestSchema = z5.object({
207
202
  // No additional parameters needed, as the NEAR account ID is extracted from the signature
208
203
  }).describe("NEAR authorization request");
209
204
  var NearAuthorizationResponseSchema = z5.object({
210
- nearAccount: z5.string().describe("NEAR account ID"),
211
- authorized: z5.boolean().describe("Whether the account is authorized")
205
+ signerId: z5.string().describe("NEAR account ID"),
206
+ isAuthorized: z5.boolean().describe("Whether the account is authorized")
212
207
  }).describe("NEAR authorization response");
213
208
  var NearAuthorizationStatusResponseSchema = z5.object({
214
- nearAccount: z5.string().describe("NEAR account ID"),
215
- authorized: z5.boolean().describe("Whether the account is authorized"),
209
+ signerId: z5.string().describe("NEAR account ID"),
210
+ isAuthorized: z5.boolean().describe("Whether the account is authorized"),
216
211
  authorizedAt: z5.string().optional().describe("When the account was authorized")
217
212
  }).describe("NEAR authorization status response");
218
213
 
@@ -434,6 +429,16 @@ var EndpointRateLimitResponseSchema = z7.object({
434
429
 
435
430
  // src/activity.ts
436
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 || {});
437
442
  var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
438
443
  TimePeriod2["ALL"] = "all";
439
444
  TimePeriod2["YEARLY"] = "year";
@@ -442,13 +447,45 @@ var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
442
447
  TimePeriod2["DAILY"] = "day";
443
448
  return TimePeriod2;
444
449
  })(TimePeriod || {});
445
- var ActivityLeaderboardQuerySchema = z8.object({
446
- timeframe: z8.nativeEnum(TimePeriod).optional().describe(
447
- "Timeframe for the leaderboard"
448
- ),
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({
449
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)"),
450
484
  offset: z8.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z8.number().min(0).optional()).describe("Offset for pagination")
451
- }).describe("Activity leaderboard query");
485
+ }).describe("Pagination parameters");
486
+ var ActivityLeaderboardQuerySchema = z8.object({
487
+ filter: FilterSchema.optional()
488
+ }).describe("Account leaderboard query").merge(PaginationSchema);
452
489
  var AccountActivityEntrySchema = z8.object({
453
490
  signerId: z8.string().describe("NEAR account ID"),
454
491
  totalPosts: z8.number().describe("Total number of posts"),
@@ -458,22 +495,21 @@ var AccountActivityEntrySchema = z8.object({
458
495
  totalQuotes: z8.number().describe("Total number of quote posts"),
459
496
  totalScore: z8.number().describe("Total activity score"),
460
497
  rank: z8.number().describe("Rank on the leaderboard"),
461
- 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")
462
500
  }).describe("Account activity entry");
463
501
  var ActivityLeaderboardResponseSchema = z8.object({
464
502
  timeframe: z8.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
465
503
  entries: z8.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
466
504
  generatedAt: z8.string().datetime().describe("Timestamp when the leaderboard was generated"),
467
- platform: PlatformSchema.optional().describe("Platform filter (if applied)")
505
+ platforms: z8.array(PlatformSchema).optional().describe("Platform filters (if applied)")
468
506
  });
469
507
  var AccountActivityParamsSchema = z8.object({
470
508
  signerId: z8.string().describe("NEAR account ID")
471
509
  }).describe("Account activity params");
472
510
  var AccountActivityQuerySchema = z8.object({
473
- timeframe: z8.nativeEnum(TimePeriod).optional().describe(
474
- "Timeframe for the activity"
475
- )
476
- }).describe("Account activity query");
511
+ filter: FilterSchema.optional()
512
+ }).describe("Account activity query").merge(PaginationSchema);
477
513
  var PlatformActivitySchema = z8.object({
478
514
  platform: PlatformSchema,
479
515
  posts: z8.number().describe("Number of posts on this platform"),
@@ -501,17 +537,13 @@ var AccountPostsParamsSchema = z8.object({
501
537
  signerId: z8.string().describe("NEAR account ID")
502
538
  }).describe("Account posts params");
503
539
  var AccountPostsQuerySchema = z8.object({
504
- platform: z8.string().optional().describe("Filter by platform (optional)"),
505
- 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)"),
506
- offset: z8.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z8.number().min(0).optional()).describe("Offset for pagination"),
507
- type: z8.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
508
- "Filter by post type (optional)"
509
- )
510
- }).describe("Account posts query");
540
+ filter: FilterSchema.optional()
541
+ }).describe("Account posts query").merge(PaginationSchema);
511
542
  var AccountPostSchema = z8.object({
512
543
  id: z8.string().describe("Post ID"),
513
544
  platform: PlatformSchema,
514
- 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"),
515
547
  content: z8.string().optional().describe("Post content (if available)"),
516
548
  url: z8.string().url().optional().describe("URL to the post on the platform (if available)"),
517
549
  createdAt: z8.string().datetime().describe("Timestamp when the post was created"),
@@ -527,10 +559,8 @@ var AccountPostSchema = z8.object({
527
559
  var AccountPostsResponseSchema = z8.object({
528
560
  signerId: z8.string().describe("NEAR account ID"),
529
561
  posts: z8.array(AccountPostSchema).describe("List of posts"),
530
- platform: z8.string().optional().describe("Platform filter (if applied)"),
531
- type: z8.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
532
- "Post type filter (if applied)"
533
- )
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)")
534
564
  });
535
565
  export {
536
566
  AccountActivityEntrySchema,
@@ -540,6 +570,7 @@ export {
540
570
  AccountPostsParamsSchema,
541
571
  AccountPostsQuerySchema,
542
572
  ActivityLeaderboardQuerySchema,
573
+ ActivityType,
543
574
  AllRateLimitsResponseSchema,
544
575
  ApiErrorCode,
545
576
  ApiErrorCodeSchema,
@@ -561,6 +592,7 @@ export {
561
592
  DeleteResultSchema,
562
593
  EndpointRateLimitResponseSchema,
563
594
  ErrorDetailSchema,
595
+ FilterSchema,
564
596
  HealthStatusSchema,
565
597
  LikePostRequestSchema,
566
598
  LikePostResponseSchema,
@@ -573,6 +605,7 @@ export {
573
605
  NearAuthorizationResponseSchema,
574
606
  NearAuthorizationStatusResponseSchema,
575
607
  NearUnauthorizationResponseSchema,
608
+ PaginationSchema,
576
609
  Platform,
577
610
  PlatformActivitySchema,
578
611
  PlatformParamSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crosspost/types",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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/auth.ts CHANGED
@@ -84,13 +84,13 @@ export const NearAuthorizationRequestSchema = z.object({
84
84
  }).describe('NEAR authorization request');
85
85
 
86
86
  export const NearAuthorizationResponseSchema = z.object({
87
- nearAccount: z.string().describe('NEAR account ID'),
88
- authorized: z.boolean().describe('Whether the account is authorized'),
87
+ signerId: z.string().describe('NEAR account ID'),
88
+ isAuthorized: z.boolean().describe('Whether the account is authorized'),
89
89
  }).describe('NEAR authorization response');
90
90
 
91
91
  export const NearAuthorizationStatusResponseSchema = z.object({
92
- nearAccount: z.string().describe('NEAR account ID'),
93
- authorized: z.boolean().describe('Whether the account is authorized'),
92
+ signerId: z.string().describe('NEAR account ID'),
93
+ isAuthorized: z.boolean().describe('Whether the account is authorized'),
94
94
  authorizedAt: z.string().optional().describe('When the account was authorized'),
95
95
  }).describe('NEAR authorization status response');
96
96
 
package/src/response.ts CHANGED
@@ -10,14 +10,9 @@ 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
 
@@ -48,7 +43,7 @@ export const MultiStatusDataSchema = z.object({
48
43
 
49
44
  export interface ApiResponse<T> {
50
45
  success: boolean;
51
- data?: T | MultiStatusData | null; // Allow null for success without data, updated type name
46
+ data?: T | null; // Allow null for success without data, updated type name
52
47
  errors?: ErrorDetail[] | null; // Allow null for success
53
48
  meta: ResponseMeta; // Mandatory, holds request id
54
49
  }