@crosspost/types 0.1.3 → 0.1.5

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
@@ -1,18 +1,20 @@
1
1
  // src/common.ts
2
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
3
  var Platform = /* @__PURE__ */ ((Platform2) => {
12
4
  Platform2["UNKNOWN"] = "unknown";
13
5
  Platform2["TWITTER"] = "twitter";
14
6
  return Platform2;
15
7
  })(Platform || {});
8
+ var PlatformSchema = z.nativeEnum(Platform).describe("Social media platform");
9
+ var SUPPORTED_PLATFORMS = [
10
+ "twitter" /* TWITTER */
11
+ // Add more platforms here as they're implemented
12
+ ];
13
+ var SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0 ? z.enum(SUPPORTED_PLATFORMS) : z.never();
14
+ SupportedPlatformSchema.describe("Currently supported social media platforms");
15
+ function isPlatformSupported(platform) {
16
+ return SUPPORTED_PLATFORMS.includes(platform);
17
+ }
16
18
 
17
19
  // src/response.ts
18
20
  import { z as z2 } from "zod";
@@ -642,15 +644,15 @@ var EndpointRateLimitResponseSchema = z5.object({
642
644
  // src/activity.ts
643
645
  import { z as z6 } from "zod";
644
646
  var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
645
- TimePeriod2["ALL_TIME"] = "all";
646
- TimePeriod2["YEARLY"] = "yearly";
647
- TimePeriod2["MONTHLY"] = "monthly";
648
- TimePeriod2["WEEKLY"] = "weekly";
649
- TimePeriod2["DAILY"] = "daily";
647
+ TimePeriod2["ALL"] = "all";
648
+ TimePeriod2["YEARLY"] = "year";
649
+ TimePeriod2["MONTHLY"] = "month";
650
+ TimePeriod2["WEEKLY"] = "week";
651
+ TimePeriod2["DAILY"] = "day";
650
652
  return TimePeriod2;
651
653
  })(TimePeriod || {});
652
654
  var ActivityLeaderboardQuerySchema = z6.object({
653
- timeframe: z6.enum(["day", "week", "month", "all"]).optional().describe(
655
+ timeframe: z6.nativeEnum(TimePeriod).optional().describe(
654
656
  "Timeframe for the leaderboard"
655
657
  ),
656
658
  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)"),
@@ -669,7 +671,7 @@ var AccountActivityEntrySchema = z6.object({
669
671
  }).describe("Account activity entry");
670
672
  var ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
671
673
  z6.object({
672
- timeframe: z6.enum(["day", "week", "month", "all"]).describe("Timeframe for the leaderboard"),
674
+ timeframe: z6.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
673
675
  entries: z6.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
674
676
  total: z6.number().describe("Total number of entries in the leaderboard"),
675
677
  limit: z6.number().describe("Maximum number of results returned"),
@@ -681,7 +683,7 @@ var AccountActivityParamsSchema = z6.object({
681
683
  signerId: z6.string().describe("NEAR account ID")
682
684
  }).describe("Account activity params");
683
685
  var AccountActivityQuerySchema = z6.object({
684
- timeframe: z6.enum(["day", "week", "month", "all"]).optional().describe(
686
+ timeframe: z6.nativeEnum(TimePeriod).optional().describe(
685
687
  "Timeframe for the activity"
686
688
  )
687
689
  }).describe("Account activity query");
@@ -698,7 +700,7 @@ var PlatformActivitySchema = z6.object({
698
700
  var AccountActivityResponseSchema = EnhancedResponseSchema(
699
701
  z6.object({
700
702
  signerId: z6.string().describe("NEAR account ID"),
701
- timeframe: z6.enum(["day", "week", "month", "all"]).describe("Timeframe for the activity"),
703
+ timeframe: z6.nativeEnum(TimePeriod).describe("Timeframe for the activity"),
702
704
  totalPosts: z6.number().describe("Total number of posts across all platforms"),
703
705
  totalLikes: z6.number().describe("Total number of likes across all platforms"),
704
706
  totalReposts: z6.number().describe("Total number of reposts across all platforms"),
@@ -844,7 +846,9 @@ export {
844
846
  ReplyToPostResponseSchema,
845
847
  RepostRequestSchema,
846
848
  RepostResponseSchema,
849
+ SUPPORTED_PLATFORMS,
847
850
  SuccessDetailSchema,
851
+ SupportedPlatformSchema,
848
852
  TargetSchema,
849
853
  TimePeriod,
850
854
  UnlikePostRequestSchema,
@@ -857,5 +861,6 @@ export {
857
861
  createErrorDetail,
858
862
  createErrorResponse,
859
863
  createMultiStatusResponse,
860
- createSuccessDetail
864
+ createSuccessDetail,
865
+ isPlatformSupported
861
866
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crosspost/types",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Shared type definitions for Crosspost API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/activity.ts CHANGED
@@ -12,18 +12,18 @@ import { PlatformSchema } from './common.ts';
12
12
  * Time periods for activity filtering
13
13
  */
14
14
  export enum TimePeriod {
15
- ALL_TIME = 'all',
16
- YEARLY = 'yearly',
17
- MONTHLY = 'monthly',
18
- WEEKLY = 'weekly',
19
- DAILY = 'daily',
15
+ ALL = 'all',
16
+ YEARLY = 'year',
17
+ MONTHLY = 'month',
18
+ WEEKLY = 'week',
19
+ DAILY = 'day',
20
20
  }
21
21
 
22
22
  /**
23
23
  * Activity leaderboard query schema
24
24
  */
25
25
  export const ActivityLeaderboardQuerySchema = z.object({
26
- timeframe: z.enum(['day', 'week', 'month', 'all']).optional().describe(
26
+ timeframe: z.nativeEnum(TimePeriod).optional().describe(
27
27
  'Timeframe for the leaderboard',
28
28
  ),
29
29
  limit: z.string().optional()
@@ -56,7 +56,7 @@ export const AccountActivityEntrySchema = z.object({
56
56
  */
57
57
  export const ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
58
58
  z.object({
59
- timeframe: z.enum(['day', 'week', 'month', 'all']).describe('Timeframe for the leaderboard'),
59
+ timeframe: z.nativeEnum(TimePeriod).describe('Timeframe for the leaderboard'),
60
60
  entries: z.array(AccountActivityEntrySchema).describe('Leaderboard entries'),
61
61
  total: z.number().describe('Total number of entries in the leaderboard'),
62
62
  limit: z.number().describe('Maximum number of results returned'),
@@ -76,7 +76,7 @@ export const AccountActivityParamsSchema = z.object({
76
76
  * Account activity query schema
77
77
  */
78
78
  export const AccountActivityQuerySchema = z.object({
79
- timeframe: z.enum(['day', 'week', 'month', 'all']).optional().describe(
79
+ timeframe: z.nativeEnum(TimePeriod).optional().describe(
80
80
  'Timeframe for the activity',
81
81
  ),
82
82
  }).describe('Account activity query');
@@ -101,7 +101,7 @@ export const PlatformActivitySchema = z.object({
101
101
  export const AccountActivityResponseSchema = EnhancedResponseSchema(
102
102
  z.object({
103
103
  signerId: z.string().describe('NEAR account ID'),
104
- timeframe: z.enum(['day', 'week', 'month', 'all']).describe('Timeframe for the activity'),
104
+ timeframe: z.nativeEnum(TimePeriod).describe('Timeframe for the activity'),
105
105
  totalPosts: z.number().describe('Total number of posts across all platforms'),
106
106
  totalLikes: z.number().describe('Total number of likes across all platforms'),
107
107
  totalReposts: z.number().describe('Total number of reposts across all platforms'),
package/src/common.ts CHANGED
@@ -6,22 +6,7 @@
6
6
  import { z } from 'zod';
7
7
 
8
8
  /**
9
- * Platform schema
10
- */
11
- export const PlatformSchema = z.enum([
12
- 'unknown',
13
- 'twitter',
14
- // Add more platforms as they're implemented
15
- // 'linkedin',
16
- // 'facebook',
17
- // 'instagram',
18
- ]).describe('Social media platform');
19
-
20
- // Derive TypeScript types from Zod schemas
21
- export type PlatformName = z.infer<typeof PlatformSchema>;
22
-
23
- /**
24
- * Enum for supported platforms (for backward compatibility)
9
+ * Platform enum - All platforms (including planned ones)
25
10
  */
26
11
  export enum Platform {
27
12
  UNKNOWN = 'unknown',
@@ -31,3 +16,34 @@ export enum Platform {
31
16
  // FACEBOOK = 'facebook',
32
17
  // INSTAGRAM = 'instagram',
33
18
  }
19
+
20
+ export const PlatformSchema = z.nativeEnum(Platform)
21
+ .describe('Social media platform');
22
+
23
+ /**
24
+ * Platform type - Derived from the Platform enum
25
+ */
26
+ export type PlatformName = Platform;
27
+
28
+ /**
29
+ * Array of currently supported platforms
30
+ */
31
+ export const SUPPORTED_PLATFORMS = [
32
+ Platform.TWITTER,
33
+ // Add more platforms here as they're implemented
34
+ ] as const;
35
+
36
+ export type SupportedPlatformName = typeof SUPPORTED_PLATFORMS[number];
37
+
38
+ export const SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0
39
+ ? z.enum(SUPPORTED_PLATFORMS)
40
+ : z.never();
41
+
42
+ SupportedPlatformSchema.describe('Currently supported social media platforms');
43
+
44
+ /**
45
+ * Check if a platform is currently supported
46
+ */
47
+ export function isPlatformSupported(platform: Platform): platform is SupportedPlatformName {
48
+ return (SUPPORTED_PLATFORMS as readonly Platform[]).includes(platform);
49
+ }
@@ -1,179 +0,0 @@
1
- /**
2
- * Leaderboard Schemas and Types
3
- * Defines Zod schemas for leaderboard-related requests and responses
4
- * TypeScript types are derived from Zod schemas for type safety
5
- */
6
-
7
- import { z } from 'zod';
8
- import { EnhancedResponseSchema } from './response.ts';
9
- import { PlatformSchema } from './common.ts';
10
-
11
- /**
12
- * Leaderboard query schema
13
- */
14
- export const LeaderboardQuerySchema = z.object({
15
- timeframe: z.enum(['day', 'week', 'month', 'all']).optional().describe(
16
- 'Timeframe for the leaderboard',
17
- ),
18
- limit: z.string().optional()
19
- .transform((val) => val ? parseInt(val, 10) : undefined)
20
- .pipe(z.number().min(1).max(100).optional())
21
- .describe('Maximum number of results to return (1-100)'),
22
- offset: z.string().optional()
23
- .transform((val) => val ? parseInt(val, 10) : undefined)
24
- .pipe(z.number().min(0).optional())
25
- .describe('Offset for pagination'),
26
- }).describe('Leaderboard query');
27
-
28
- /**
29
- * Account activity entry schema
30
- */
31
- export const AccountActivityEntrySchema = z.object({
32
- signerId: z.string().describe('NEAR account ID'),
33
- totalPosts: z.number().describe('Total number of posts'),
34
- totalLikes: z.number().describe('Total number of likes'),
35
- totalReposts: z.number().describe('Total number of reposts'),
36
- totalReplies: z.number().describe('Total number of replies'),
37
- totalQuotes: z.number().describe('Total number of quote posts'),
38
- totalScore: z.number().describe('Total activity score'),
39
- rank: z.number().describe('Rank on the leaderboard'),
40
- lastActive: z.string().datetime().describe('Timestamp of last activity'),
41
- }).describe('Account activity entry');
42
-
43
- /**
44
- * Leaderboard response schema
45
- */
46
- export const LeaderboardResponseSchema = EnhancedResponseSchema(
47
- z.object({
48
- timeframe: z.enum(['day', 'week', 'month', 'all']).describe('Timeframe for the leaderboard'),
49
- entries: z.array(AccountActivityEntrySchema).describe('Leaderboard entries'),
50
- total: z.number().describe('Total number of entries in the leaderboard'),
51
- limit: z.number().describe('Maximum number of results returned'),
52
- offset: z.number().describe('Offset for pagination'),
53
- generatedAt: z.string().datetime().describe('Timestamp when the leaderboard was generated'),
54
- }),
55
- ).describe('Leaderboard response');
56
-
57
- /**
58
- * Account activity params schema
59
- */
60
- export const AccountActivityParamsSchema = z.object({
61
- signerId: z.string().describe('NEAR account ID'),
62
- }).describe('Account activity params');
63
-
64
- /**
65
- * Account activity query schema
66
- */
67
- export const AccountActivityQuerySchema = z.object({
68
- timeframe: z.enum(['day', 'week', 'month', 'all']).optional().describe(
69
- 'Timeframe for the activity',
70
- ),
71
- }).describe('Account activity query');
72
-
73
- /**
74
- * Platform activity schema
75
- */
76
- export const PlatformActivitySchema = z.object({
77
- platform: PlatformSchema,
78
- posts: z.number().describe('Number of posts on this platform'),
79
- likes: z.number().describe('Number of likes on this platform'),
80
- reposts: z.number().describe('Number of reposts on this platform'),
81
- replies: z.number().describe('Number of replies on this platform'),
82
- quotes: z.number().describe('Number of quote posts on this platform'),
83
- score: z.number().describe('Activity score on this platform'),
84
- lastActive: z.string().datetime().describe('Timestamp of last activity on this platform'),
85
- }).describe('Platform activity');
86
-
87
- /**
88
- * Account activity response schema
89
- */
90
- export const AccountActivityResponseSchema = EnhancedResponseSchema(
91
- z.object({
92
- signerId: z.string().describe('NEAR account ID'),
93
- timeframe: z.enum(['day', 'week', 'month', 'all']).describe('Timeframe for the activity'),
94
- totalPosts: z.number().describe('Total number of posts across all platforms'),
95
- totalLikes: z.number().describe('Total number of likes across all platforms'),
96
- totalReposts: z.number().describe('Total number of reposts across all platforms'),
97
- totalReplies: z.number().describe('Total number of replies across all platforms'),
98
- totalQuotes: z.number().describe('Total number of quote posts across all platforms'),
99
- totalScore: z.number().describe('Total activity score across all platforms'),
100
- rank: z.number().describe('Rank on the leaderboard'),
101
- lastActive: z.string().datetime().describe('Timestamp of last activity across all platforms'),
102
- platforms: z.array(PlatformActivitySchema).describe('Activity breakdown by platform'),
103
- }),
104
- ).describe('Account activity response');
105
-
106
- /**
107
- * Account posts params schema
108
- */
109
- export const AccountPostsParamsSchema = z.object({
110
- signerId: z.string().describe('NEAR account ID'),
111
- }).describe('Account posts params');
112
-
113
- /**
114
- * Account posts query schema
115
- */
116
- export const AccountPostsQuerySchema = z.object({
117
- platform: z.string().optional().describe('Filter by platform (optional)'),
118
- limit: z.string().optional()
119
- .transform((val) => val ? parseInt(val, 10) : undefined)
120
- .pipe(z.number().min(1).max(100).optional())
121
- .describe('Maximum number of results to return (1-100)'),
122
- offset: z.string().optional()
123
- .transform((val) => val ? parseInt(val, 10) : undefined)
124
- .pipe(z.number().min(0).optional())
125
- .describe('Offset for pagination'),
126
- type: z.enum(['post', 'repost', 'reply', 'quote', 'like', 'all']).optional().describe(
127
- 'Filter by post type (optional)',
128
- ),
129
- }).describe('Account posts query');
130
-
131
- /**
132
- * Account post schema
133
- */
134
- export const AccountPostSchema = z.object({
135
- id: z.string().describe('Post ID'),
136
- platform: PlatformSchema,
137
- type: z.enum(['post', 'repost', 'reply', 'quote', 'like']).describe('Type of post'),
138
- content: z.string().optional().describe('Post content (if available)'),
139
- url: z.string().url().optional().describe('URL to the post on the platform (if available)'),
140
- createdAt: z.string().datetime().describe('Timestamp when the post was created'),
141
- metrics: z.object({
142
- likes: z.number().optional().describe('Number of likes (if available)'),
143
- reposts: z.number().optional().describe('Number of reposts (if available)'),
144
- replies: z.number().optional().describe('Number of replies (if available)'),
145
- quotes: z.number().optional().describe('Number of quotes (if available)'),
146
- }).optional().describe('Post metrics (if available)'),
147
- inReplyToId: z.string().optional().describe('ID of the post this is a reply to (if applicable)'),
148
- quotedPostId: z.string().optional().describe('ID of the post this is quoting (if applicable)'),
149
- }).describe('Account post');
150
-
151
- /**
152
- * Account posts response schema
153
- */
154
- export const AccountPostsResponseSchema = EnhancedResponseSchema(
155
- z.object({
156
- signerId: z.string().describe('NEAR account ID'),
157
- posts: z.array(AccountPostSchema).describe('List of posts'),
158
- total: z.number().describe('Total number of posts matching the query'),
159
- limit: z.number().describe('Maximum number of results returned'),
160
- offset: z.number().describe('Offset for pagination'),
161
- platform: z.string().optional().describe('Platform filter (if applied)'),
162
- type: z.enum(['post', 'repost', 'reply', 'quote', 'like', 'all']).optional().describe(
163
- 'Post type filter (if applied)',
164
- ),
165
- }),
166
- ).describe('Account posts response');
167
-
168
- // Derive TypeScript types from Zod schemas
169
- export type LeaderboardQuery = z.infer<typeof LeaderboardQuerySchema>;
170
- export type AccountActivityEntry = z.infer<typeof AccountActivityEntrySchema>;
171
- export type LeaderboardResponse = z.infer<typeof LeaderboardResponseSchema>;
172
- export type AccountActivityParams = z.infer<typeof AccountActivityParamsSchema>;
173
- export type AccountActivityQuery = z.infer<typeof AccountActivityQuerySchema>;
174
- export type PlatformActivity = z.infer<typeof PlatformActivitySchema>;
175
- export type AccountActivityResponse = z.infer<typeof AccountActivityResponseSchema>;
176
- export type AccountPostsParams = z.infer<typeof AccountPostsParamsSchema>;
177
- export type AccountPostsQuery = z.infer<typeof AccountPostsQuerySchema>;
178
- export type AccountPost = z.infer<typeof AccountPostSchema>;
179
- export type AccountPostsResponse = z.infer<typeof AccountPostsResponseSchema>;