@crosspost/types 0.1.2 → 0.1.4
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 +21 -0
- package/README.md +4 -32
- package/dist/index.cjs +37 -19
- package/dist/index.d.cts +273 -228
- package/dist/index.d.ts +273 -228
- package/dist/index.js +30 -16
- package/package.json +1 -1
- package/src/activity.ts +247 -0
- package/src/common.ts +32 -16
- package/src/index.ts +1 -1
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
|
3
|
+
Shared type definitions for the Crosspost API and SDK.
|
4
4
|
|
5
5
|
## Overview
|
6
6
|
|
7
|
-
This package contains TypeScript type definitions
|
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
|
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
@@ -28,6 +28,8 @@ __export(index_exports, {
|
|
28
28
|
AccountPostsParamsSchema: () => AccountPostsParamsSchema,
|
29
29
|
AccountPostsQuerySchema: () => AccountPostsQuerySchema,
|
30
30
|
AccountPostsResponseSchema: () => AccountPostsResponseSchema,
|
31
|
+
ActivityLeaderboardQuerySchema: () => ActivityLeaderboardQuerySchema,
|
32
|
+
ActivityLeaderboardResponseSchema: () => ActivityLeaderboardResponseSchema,
|
31
33
|
AllRateLimitsResponseSchema: () => AllRateLimitsResponseSchema,
|
32
34
|
ApiError: () => ApiError,
|
33
35
|
ApiErrorCode: () => ApiErrorCode,
|
@@ -55,8 +57,6 @@ __export(index_exports, {
|
|
55
57
|
EnhancedResponseSchema: () => EnhancedResponseSchema,
|
56
58
|
ErrorDetailSchema: () => ErrorDetailSchema,
|
57
59
|
ErrorResponseSchema: () => ErrorResponseSchema,
|
58
|
-
LeaderboardQuerySchema: () => LeaderboardQuerySchema,
|
59
|
-
LeaderboardResponseSchema: () => LeaderboardResponseSchema,
|
60
60
|
LikePostRequestSchema: () => LikePostRequestSchema,
|
61
61
|
LikePostResponseSchema: () => LikePostResponseSchema,
|
62
62
|
LikeResultSchema: () => LikeResultSchema,
|
@@ -93,8 +93,11 @@ __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,
|
100
|
+
TimePeriod: () => TimePeriod,
|
98
101
|
UnlikePostRequestSchema: () => UnlikePostRequestSchema,
|
99
102
|
UnlikePostResponseSchema: () => UnlikePostResponseSchema,
|
100
103
|
UsageRateLimitSchema: () => UsageRateLimitSchema,
|
@@ -105,25 +108,28 @@ __export(index_exports, {
|
|
105
108
|
createErrorDetail: () => createErrorDetail,
|
106
109
|
createErrorResponse: () => createErrorResponse,
|
107
110
|
createMultiStatusResponse: () => createMultiStatusResponse,
|
108
|
-
createSuccessDetail: () => createSuccessDetail
|
111
|
+
createSuccessDetail: () => createSuccessDetail,
|
112
|
+
isPlatformSupported: () => isPlatformSupported
|
109
113
|
});
|
110
114
|
module.exports = __toCommonJS(index_exports);
|
111
115
|
|
112
116
|
// src/common.ts
|
113
117
|
var import_zod = require("zod");
|
114
|
-
var PlatformSchema = import_zod.z.enum([
|
115
|
-
"unknown",
|
116
|
-
"twitter"
|
117
|
-
// Add more platforms as they're implemented
|
118
|
-
// 'linkedin',
|
119
|
-
// 'facebook',
|
120
|
-
// 'instagram',
|
121
|
-
]).describe("Social media platform");
|
122
118
|
var Platform = /* @__PURE__ */ ((Platform2) => {
|
123
119
|
Platform2["UNKNOWN"] = "unknown";
|
124
120
|
Platform2["TWITTER"] = "twitter";
|
125
121
|
return Platform2;
|
126
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
|
+
}
|
127
133
|
|
128
134
|
// src/response.ts
|
129
135
|
var import_zod2 = require("zod");
|
@@ -750,15 +756,23 @@ var EndpointRateLimitResponseSchema = import_zod5.z.object({
|
|
750
756
|
signerId: import_zod5.z.string().describe("NEAR account ID")
|
751
757
|
}).describe("Endpoint rate limit response");
|
752
758
|
|
753
|
-
// src/
|
759
|
+
// src/activity.ts
|
754
760
|
var import_zod6 = require("zod");
|
755
|
-
var
|
761
|
+
var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
|
762
|
+
TimePeriod2["ALL_TIME"] = "all";
|
763
|
+
TimePeriod2["YEARLY"] = "yearly";
|
764
|
+
TimePeriod2["MONTHLY"] = "monthly";
|
765
|
+
TimePeriod2["WEEKLY"] = "weekly";
|
766
|
+
TimePeriod2["DAILY"] = "daily";
|
767
|
+
return TimePeriod2;
|
768
|
+
})(TimePeriod || {});
|
769
|
+
var ActivityLeaderboardQuerySchema = import_zod6.z.object({
|
756
770
|
timeframe: import_zod6.z.enum(["day", "week", "month", "all"]).optional().describe(
|
757
771
|
"Timeframe for the leaderboard"
|
758
772
|
),
|
759
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)"),
|
760
774
|
offset: import_zod6.z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(import_zod6.z.number().min(0).optional()).describe("Offset for pagination")
|
761
|
-
}).describe("
|
775
|
+
}).describe("Activity leaderboard query");
|
762
776
|
var AccountActivityEntrySchema = import_zod6.z.object({
|
763
777
|
signerId: import_zod6.z.string().describe("NEAR account ID"),
|
764
778
|
totalPosts: import_zod6.z.number().describe("Total number of posts"),
|
@@ -770,7 +784,7 @@ var AccountActivityEntrySchema = import_zod6.z.object({
|
|
770
784
|
rank: import_zod6.z.number().describe("Rank on the leaderboard"),
|
771
785
|
lastActive: import_zod6.z.string().datetime().describe("Timestamp of last activity")
|
772
786
|
}).describe("Account activity entry");
|
773
|
-
var
|
787
|
+
var ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
|
774
788
|
import_zod6.z.object({
|
775
789
|
timeframe: import_zod6.z.enum(["day", "week", "month", "all"]).describe("Timeframe for the leaderboard"),
|
776
790
|
entries: import_zod6.z.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
|
@@ -779,7 +793,7 @@ var LeaderboardResponseSchema = EnhancedResponseSchema(
|
|
779
793
|
offset: import_zod6.z.number().describe("Offset for pagination"),
|
780
794
|
generatedAt: import_zod6.z.string().datetime().describe("Timestamp when the leaderboard was generated")
|
781
795
|
})
|
782
|
-
).describe("
|
796
|
+
).describe("Activity leaderboard response");
|
783
797
|
var AccountActivityParamsSchema = import_zod6.z.object({
|
784
798
|
signerId: import_zod6.z.string().describe("NEAR account ID")
|
785
799
|
}).describe("Account activity params");
|
@@ -883,6 +897,8 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
|
|
883
897
|
AccountPostsParamsSchema,
|
884
898
|
AccountPostsQuerySchema,
|
885
899
|
AccountPostsResponseSchema,
|
900
|
+
ActivityLeaderboardQuerySchema,
|
901
|
+
ActivityLeaderboardResponseSchema,
|
886
902
|
AllRateLimitsResponseSchema,
|
887
903
|
ApiError,
|
888
904
|
ApiErrorCode,
|
@@ -910,8 +926,6 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
|
|
910
926
|
EnhancedResponseSchema,
|
911
927
|
ErrorDetailSchema,
|
912
928
|
ErrorResponseSchema,
|
913
|
-
LeaderboardQuerySchema,
|
914
|
-
LeaderboardResponseSchema,
|
915
929
|
LikePostRequestSchema,
|
916
930
|
LikePostResponseSchema,
|
917
931
|
LikeResultSchema,
|
@@ -948,8 +962,11 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
|
|
948
962
|
ReplyToPostResponseSchema,
|
949
963
|
RepostRequestSchema,
|
950
964
|
RepostResponseSchema,
|
965
|
+
SUPPORTED_PLATFORMS,
|
951
966
|
SuccessDetailSchema,
|
967
|
+
SupportedPlatformSchema,
|
952
968
|
TargetSchema,
|
969
|
+
TimePeriod,
|
953
970
|
UnlikePostRequestSchema,
|
954
971
|
UnlikePostResponseSchema,
|
955
972
|
UsageRateLimitSchema,
|
@@ -960,5 +977,6 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
|
|
960
977
|
createErrorDetail,
|
961
978
|
createErrorResponse,
|
962
979
|
createMultiStatusResponse,
|
963
|
-
createSuccessDetail
|
980
|
+
createSuccessDetail,
|
981
|
+
isPlatformSupported
|
964
982
|
});
|