@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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Open Crosspost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # @crosspost/types
2
2
 
3
- Shared type definitions for the Crosspost API ecosystem.
3
+ Shared type definitions for the Crosspost API and SDK.
4
4
 
5
5
  ## Overview
6
6
 
7
- This package contains TypeScript type definitions used across the Crosspost API ecosystem,
8
- including:
7
+ This package contains TypeScript type definitions, including:
9
8
 
10
9
  - Common types (PlatformName, ApiErrorCode, etc.)
11
10
  - Request types for all API endpoints
@@ -13,20 +12,10 @@ including:
13
12
 
14
13
  ## Installation
15
14
 
16
- ### Node.js / npm
15
+ ### Node.js
17
16
 
18
17
  ```bash
19
- # Using npm
20
18
  npm install @crosspost/types
21
-
22
- # Using yarn
23
- yarn add @crosspost/types
24
-
25
- # Using pnpm
26
- pnpm add @crosspost/types
27
-
28
- # Using bun
29
- bun add @crosspost/types
30
19
  ```
31
20
 
32
21
  ### Deno
@@ -48,6 +37,7 @@ import { CreatePostRequest, CreatePostResponse, PlatformName } from '@crosspost/
48
37
  const platform: PlatformName = 'twitter';
49
38
 
50
39
  const request: CreatePostRequest = {
40
+ targets: [{ platform: 'twitter', userId: 'your-twitter-id' }],
51
41
  content: {
52
42
  text: 'Hello, world!',
53
43
  },
@@ -105,21 +95,3 @@ const errorResponse = createEnhancedErrorResponse([
105
95
  ),
106
96
  ]);
107
97
  ```
108
-
109
- ### Request Types
110
-
111
- - Authentication requests
112
- - Post creation and management requests
113
- - Media upload requests
114
- - Rate limit requests
115
-
116
- ### Response Types
117
-
118
- - Authentication responses
119
- - Post creation and management responses
120
- - Media upload responses
121
- - Rate limit responses
122
-
123
- ## License
124
-
125
- MIT
package/dist/index.cjs CHANGED
@@ -93,7 +93,9 @@ __export(index_exports, {
93
93
  ReplyToPostResponseSchema: () => ReplyToPostResponseSchema,
94
94
  RepostRequestSchema: () => RepostRequestSchema,
95
95
  RepostResponseSchema: () => RepostResponseSchema,
96
+ SUPPORTED_PLATFORMS: () => SUPPORTED_PLATFORMS,
96
97
  SuccessDetailSchema: () => SuccessDetailSchema,
98
+ SupportedPlatformSchema: () => SupportedPlatformSchema,
97
99
  TargetSchema: () => TargetSchema,
98
100
  TimePeriod: () => TimePeriod,
99
101
  UnlikePostRequestSchema: () => UnlikePostRequestSchema,
@@ -106,25 +108,28 @@ __export(index_exports, {
106
108
  createErrorDetail: () => createErrorDetail,
107
109
  createErrorResponse: () => createErrorResponse,
108
110
  createMultiStatusResponse: () => createMultiStatusResponse,
109
- createSuccessDetail: () => createSuccessDetail
111
+ createSuccessDetail: () => createSuccessDetail,
112
+ isPlatformSupported: () => isPlatformSupported
110
113
  });
111
114
  module.exports = __toCommonJS(index_exports);
112
115
 
113
116
  // src/common.ts
114
117
  var import_zod = require("zod");
115
- var PlatformSchema = import_zod.z.enum([
116
- "unknown",
117
- "twitter"
118
- // Add more platforms as they're implemented
119
- // 'linkedin',
120
- // 'facebook',
121
- // 'instagram',
122
- ]).describe("Social media platform");
123
118
  var Platform = /* @__PURE__ */ ((Platform2) => {
124
119
  Platform2["UNKNOWN"] = "unknown";
125
120
  Platform2["TWITTER"] = "twitter";
126
121
  return Platform2;
127
122
  })(Platform || {});
123
+ var PlatformSchema = import_zod.z.nativeEnum(Platform).describe("Social media platform");
124
+ var SUPPORTED_PLATFORMS = [
125
+ "twitter" /* TWITTER */
126
+ // Add more platforms here as they're implemented
127
+ ];
128
+ var SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0 ? import_zod.z.enum(SUPPORTED_PLATFORMS) : import_zod.z.never();
129
+ SupportedPlatformSchema.describe("Currently supported social media platforms");
130
+ function isPlatformSupported(platform) {
131
+ return SUPPORTED_PLATFORMS.includes(platform);
132
+ }
128
133
 
129
134
  // src/response.ts
130
135
  var import_zod2 = require("zod");
@@ -754,15 +759,15 @@ var EndpointRateLimitResponseSchema = import_zod5.z.object({
754
759
  // src/activity.ts
755
760
  var import_zod6 = require("zod");
756
761
  var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
757
- TimePeriod2["ALL_TIME"] = "all";
758
- TimePeriod2["YEARLY"] = "yearly";
759
- TimePeriod2["MONTHLY"] = "monthly";
760
- TimePeriod2["WEEKLY"] = "weekly";
761
- TimePeriod2["DAILY"] = "daily";
762
+ TimePeriod2["ALL"] = "all";
763
+ TimePeriod2["YEARLY"] = "year";
764
+ TimePeriod2["MONTHLY"] = "month";
765
+ TimePeriod2["WEEKLY"] = "week";
766
+ TimePeriod2["DAILY"] = "day";
762
767
  return TimePeriod2;
763
768
  })(TimePeriod || {});
764
769
  var ActivityLeaderboardQuerySchema = import_zod6.z.object({
765
- timeframe: import_zod6.z.enum(["day", "week", "month", "all"]).optional().describe(
770
+ timeframe: import_zod6.z.nativeEnum(TimePeriod).optional().describe(
766
771
  "Timeframe for the leaderboard"
767
772
  ),
768
773
  limit: import_zod6.z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(import_zod6.z.number().min(1).max(100).optional()).describe("Maximum number of results to return (1-100)"),
@@ -781,7 +786,7 @@ var AccountActivityEntrySchema = import_zod6.z.object({
781
786
  }).describe("Account activity entry");
782
787
  var ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
783
788
  import_zod6.z.object({
784
- timeframe: import_zod6.z.enum(["day", "week", "month", "all"]).describe("Timeframe for the leaderboard"),
789
+ timeframe: import_zod6.z.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
785
790
  entries: import_zod6.z.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
786
791
  total: import_zod6.z.number().describe("Total number of entries in the leaderboard"),
787
792
  limit: import_zod6.z.number().describe("Maximum number of results returned"),
@@ -793,7 +798,7 @@ var AccountActivityParamsSchema = import_zod6.z.object({
793
798
  signerId: import_zod6.z.string().describe("NEAR account ID")
794
799
  }).describe("Account activity params");
795
800
  var AccountActivityQuerySchema = import_zod6.z.object({
796
- timeframe: import_zod6.z.enum(["day", "week", "month", "all"]).optional().describe(
801
+ timeframe: import_zod6.z.nativeEnum(TimePeriod).optional().describe(
797
802
  "Timeframe for the activity"
798
803
  )
799
804
  }).describe("Account activity query");
@@ -810,7 +815,7 @@ var PlatformActivitySchema = import_zod6.z.object({
810
815
  var AccountActivityResponseSchema = EnhancedResponseSchema(
811
816
  import_zod6.z.object({
812
817
  signerId: import_zod6.z.string().describe("NEAR account ID"),
813
- timeframe: import_zod6.z.enum(["day", "week", "month", "all"]).describe("Timeframe for the activity"),
818
+ timeframe: import_zod6.z.nativeEnum(TimePeriod).describe("Timeframe for the activity"),
814
819
  totalPosts: import_zod6.z.number().describe("Total number of posts across all platforms"),
815
820
  totalLikes: import_zod6.z.number().describe("Total number of likes across all platforms"),
816
821
  totalReposts: import_zod6.z.number().describe("Total number of reposts across all platforms"),
@@ -957,7 +962,9 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
957
962
  ReplyToPostResponseSchema,
958
963
  RepostRequestSchema,
959
964
  RepostResponseSchema,
965
+ SUPPORTED_PLATFORMS,
960
966
  SuccessDetailSchema,
967
+ SupportedPlatformSchema,
961
968
  TargetSchema,
962
969
  TimePeriod,
963
970
  UnlikePostRequestSchema,
@@ -970,5 +977,6 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
970
977
  createErrorDetail,
971
978
  createErrorResponse,
972
979
  createMultiStatusResponse,
973
- createSuccessDetail
980
+ createSuccessDetail,
981
+ isPlatformSupported
974
982
  });