@crosspost/sdk 0.2.7 → 0.2.8

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.cjs CHANGED
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
 
21
20
  // src/index.ts
@@ -24,14 +23,12 @@ __export(index_exports, {
24
23
  ActivityApi: () => ActivityApi,
25
24
  AuthApi: () => AuthApi,
26
25
  CrosspostClient: () => CrosspostClient,
26
+ CrosspostError: () => CrosspostError,
27
27
  PostApi: () => PostApi,
28
28
  SystemApi: () => SystemApi,
29
29
  apiWrapper: () => apiWrapper,
30
- createNetworkError: () => createNetworkError,
31
- enrichErrorWithContext: () => enrichErrorWithContext,
32
30
  getErrorDetails: () => getErrorDetails,
33
31
  getErrorMessage: () => getErrorMessage,
34
- handleErrorResponse: () => handleErrorResponse,
35
32
  isAuthError: () => isAuthError,
36
33
  isContentError: () => isContentError,
37
34
  isMediaError: () => isMediaError,
@@ -883,22 +880,17 @@ var CrosspostClient = class {
883
880
  this.options.nearAccount = void 0;
884
881
  }
885
882
  };
886
-
887
- // src/index.ts
888
- __reExport(index_exports, require("@crosspost/types"), module.exports);
889
883
  // Annotate the CommonJS export names for ESM import in node:
890
884
  0 && (module.exports = {
891
885
  ActivityApi,
892
886
  AuthApi,
893
887
  CrosspostClient,
888
+ CrosspostError,
894
889
  PostApi,
895
890
  SystemApi,
896
891
  apiWrapper,
897
- createNetworkError,
898
- enrichErrorWithContext,
899
892
  getErrorDetails,
900
893
  getErrorMessage,
901
- handleErrorResponse,
902
894
  isAuthError,
903
895
  isContentError,
904
896
  isMediaError,
@@ -907,6 +899,5 @@ __reExport(index_exports, require("@crosspost/types"), module.exports);
907
899
  isPostError,
908
900
  isRateLimitError,
909
901
  isRecoverableError,
910
- isValidationError,
911
- ...require("@crosspost/types")
902
+ isValidationError
912
903
  });
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { NearAuthData } from 'near-sign-verify';
2
- import { ActivityLeaderboardQuery, ApiResponse, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, AuthInitRequest, AuthCallbackResponse, AuthUrlResponse, ConnectedAccount, AuthStatusResponse, NearUnauthorizationResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, HealthStatus, ApiErrorCode, StatusCode, ErrorDetails } from '@crosspost/types';
3
- export * from '@crosspost/types';
2
+ import { ActivityLeaderboardQuery, ApiResponse, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, AuthInitRequest, AuthCallbackResponse, AuthUrlResponse, ConnectedAccount, AuthStatusResponse, NearUnauthorizationResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, MultiStatusData, RepostRequest, QuotePostRequest, ReplyToPostRequest, LikePostRequest, UnlikePostRequest, DeletePostRequest, RateLimitResponse, EndpointRateLimitResponse, HealthStatus, ApiErrorCode, StatusCode, ErrorDetails } from '@crosspost/types';
4
3
 
5
4
  /**
6
5
  * Options for making a request to the API
@@ -139,43 +138,43 @@ declare class PostApi {
139
138
  * @param request The post creation request details.
140
139
  * @returns A promise resolving with the post creation response.
141
140
  */
142
- createPost(request: CreatePostRequest): Promise<ApiResponse<CreatePostResponse>>;
141
+ createPost(request: CreatePostRequest): Promise<ApiResponse<MultiStatusData>>;
143
142
  /**
144
143
  * Reposts an existing post on the specified target platforms.
145
144
  * @param request The repost request details.
146
145
  * @returns A promise resolving with the repost response.
147
146
  */
148
- repost(request: RepostRequest): Promise<ApiResponse<RepostResponse>>;
147
+ repost(request: RepostRequest): Promise<ApiResponse<MultiStatusData>>;
149
148
  /**
150
149
  * Quotes an existing post on the specified target platforms.
151
150
  * @param request The quote post request details.
152
151
  * @returns A promise resolving with the quote post response.
153
152
  */
154
- quotePost(request: QuotePostRequest): Promise<ApiResponse<QuotePostResponse>>;
153
+ quotePost(request: QuotePostRequest): Promise<ApiResponse<MultiStatusData>>;
155
154
  /**
156
155
  * Replies to an existing post on the specified target platforms.
157
156
  * @param request The reply request details.
158
157
  * @returns A promise resolving with the reply response.
159
158
  */
160
- replyToPost(request: ReplyToPostRequest): Promise<ApiResponse<ReplyToPostResponse>>;
159
+ replyToPost(request: ReplyToPostRequest): Promise<ApiResponse<MultiStatusData>>;
161
160
  /**
162
161
  * Likes a post on the specified target platforms.
163
162
  * @param request The like request details.
164
163
  * @returns A promise resolving with the like response.
165
164
  */
166
- likePost(request: LikePostRequest): Promise<ApiResponse<LikePostResponse>>;
165
+ likePost(request: LikePostRequest): Promise<ApiResponse<MultiStatusData>>;
167
166
  /**
168
167
  * Unlikes a post on the specified target platforms.
169
168
  * @param request The unlike request details.
170
169
  * @returns A promise resolving with the unlike response.
171
170
  */
172
- unlikePost(request: UnlikePostRequest): Promise<ApiResponse<UnlikePostResponse>>;
171
+ unlikePost(request: UnlikePostRequest): Promise<ApiResponse<MultiStatusData>>;
173
172
  /**
174
173
  * Deletes one or more posts.
175
174
  * @param request The delete request details.
176
175
  * @returns A promise resolving with the delete response.
177
176
  */
178
- deletePost(request: DeletePostRequest): Promise<ApiResponse<DeletePostResponse>>;
177
+ deletePost(request: DeletePostRequest): Promise<ApiResponse<MultiStatusData>>;
179
178
  }
180
179
 
181
180
  /**
@@ -337,21 +336,9 @@ declare function getErrorMessage(error: unknown, defaultMessage?: string): strin
337
336
  * Get error details if available
338
337
  */
339
338
  declare function getErrorDetails(error: unknown): ErrorDetails | undefined;
340
- /**
341
- * Enrich an error with additional context
342
- */
343
- declare function enrichErrorWithContext(error: unknown, context: Record<string, unknown>): Error;
344
339
  /**
345
340
  * Wrapper for API calls with consistent error handling
346
341
  */
347
342
  declare function apiWrapper<T>(apiCall: () => Promise<T>, context?: Record<string, unknown>): Promise<T>;
348
- /**
349
- * Handles error responses from the API and converts them to appropriate error objects.
350
- */
351
- declare function handleErrorResponse(data: any, status: number): CrosspostError;
352
- /**
353
- * Creates a network error with appropriate details
354
- */
355
- declare function createNetworkError(error: unknown, url: string, timeout: number): CrosspostError;
356
343
 
357
- export { ActivityApi, AuthApi, CrosspostClient, type CrosspostClientConfig, PostApi, SystemApi, apiWrapper, createNetworkError, enrichErrorWithContext, getErrorDetails, getErrorMessage, handleErrorResponse, isAuthError, isContentError, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError };
344
+ export { ActivityApi, AuthApi, CrosspostClient, type CrosspostClientConfig, CrosspostError, PostApi, SystemApi, apiWrapper, getErrorDetails, getErrorMessage, isAuthError, isContentError, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { NearAuthData } from 'near-sign-verify';
2
- import { ActivityLeaderboardQuery, ApiResponse, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, AuthInitRequest, AuthCallbackResponse, AuthUrlResponse, ConnectedAccount, AuthStatusResponse, NearUnauthorizationResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, HealthStatus, ApiErrorCode, StatusCode, ErrorDetails } from '@crosspost/types';
3
- export * from '@crosspost/types';
2
+ import { ActivityLeaderboardQuery, ApiResponse, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, AuthInitRequest, AuthCallbackResponse, AuthUrlResponse, ConnectedAccount, AuthStatusResponse, NearUnauthorizationResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, MultiStatusData, RepostRequest, QuotePostRequest, ReplyToPostRequest, LikePostRequest, UnlikePostRequest, DeletePostRequest, RateLimitResponse, EndpointRateLimitResponse, HealthStatus, ApiErrorCode, StatusCode, ErrorDetails } from '@crosspost/types';
4
3
 
5
4
  /**
6
5
  * Options for making a request to the API
@@ -139,43 +138,43 @@ declare class PostApi {
139
138
  * @param request The post creation request details.
140
139
  * @returns A promise resolving with the post creation response.
141
140
  */
142
- createPost(request: CreatePostRequest): Promise<ApiResponse<CreatePostResponse>>;
141
+ createPost(request: CreatePostRequest): Promise<ApiResponse<MultiStatusData>>;
143
142
  /**
144
143
  * Reposts an existing post on the specified target platforms.
145
144
  * @param request The repost request details.
146
145
  * @returns A promise resolving with the repost response.
147
146
  */
148
- repost(request: RepostRequest): Promise<ApiResponse<RepostResponse>>;
147
+ repost(request: RepostRequest): Promise<ApiResponse<MultiStatusData>>;
149
148
  /**
150
149
  * Quotes an existing post on the specified target platforms.
151
150
  * @param request The quote post request details.
152
151
  * @returns A promise resolving with the quote post response.
153
152
  */
154
- quotePost(request: QuotePostRequest): Promise<ApiResponse<QuotePostResponse>>;
153
+ quotePost(request: QuotePostRequest): Promise<ApiResponse<MultiStatusData>>;
155
154
  /**
156
155
  * Replies to an existing post on the specified target platforms.
157
156
  * @param request The reply request details.
158
157
  * @returns A promise resolving with the reply response.
159
158
  */
160
- replyToPost(request: ReplyToPostRequest): Promise<ApiResponse<ReplyToPostResponse>>;
159
+ replyToPost(request: ReplyToPostRequest): Promise<ApiResponse<MultiStatusData>>;
161
160
  /**
162
161
  * Likes a post on the specified target platforms.
163
162
  * @param request The like request details.
164
163
  * @returns A promise resolving with the like response.
165
164
  */
166
- likePost(request: LikePostRequest): Promise<ApiResponse<LikePostResponse>>;
165
+ likePost(request: LikePostRequest): Promise<ApiResponse<MultiStatusData>>;
167
166
  /**
168
167
  * Unlikes a post on the specified target platforms.
169
168
  * @param request The unlike request details.
170
169
  * @returns A promise resolving with the unlike response.
171
170
  */
172
- unlikePost(request: UnlikePostRequest): Promise<ApiResponse<UnlikePostResponse>>;
171
+ unlikePost(request: UnlikePostRequest): Promise<ApiResponse<MultiStatusData>>;
173
172
  /**
174
173
  * Deletes one or more posts.
175
174
  * @param request The delete request details.
176
175
  * @returns A promise resolving with the delete response.
177
176
  */
178
- deletePost(request: DeletePostRequest): Promise<ApiResponse<DeletePostResponse>>;
177
+ deletePost(request: DeletePostRequest): Promise<ApiResponse<MultiStatusData>>;
179
178
  }
180
179
 
181
180
  /**
@@ -337,21 +336,9 @@ declare function getErrorMessage(error: unknown, defaultMessage?: string): strin
337
336
  * Get error details if available
338
337
  */
339
338
  declare function getErrorDetails(error: unknown): ErrorDetails | undefined;
340
- /**
341
- * Enrich an error with additional context
342
- */
343
- declare function enrichErrorWithContext(error: unknown, context: Record<string, unknown>): Error;
344
339
  /**
345
340
  * Wrapper for API calls with consistent error handling
346
341
  */
347
342
  declare function apiWrapper<T>(apiCall: () => Promise<T>, context?: Record<string, unknown>): Promise<T>;
348
- /**
349
- * Handles error responses from the API and converts them to appropriate error objects.
350
- */
351
- declare function handleErrorResponse(data: any, status: number): CrosspostError;
352
- /**
353
- * Creates a network error with appropriate details
354
- */
355
- declare function createNetworkError(error: unknown, url: string, timeout: number): CrosspostError;
356
343
 
357
- export { ActivityApi, AuthApi, CrosspostClient, type CrosspostClientConfig, PostApi, SystemApi, apiWrapper, createNetworkError, enrichErrorWithContext, getErrorDetails, getErrorMessage, handleErrorResponse, isAuthError, isContentError, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError };
344
+ export { ActivityApi, AuthApi, CrosspostClient, type CrosspostClientConfig, CrosspostError, PostApi, SystemApi, apiWrapper, getErrorDetails, getErrorMessage, isAuthError, isContentError, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError };
package/dist/index.js CHANGED
@@ -837,21 +837,16 @@ var CrosspostClient = class {
837
837
  this.options.nearAccount = void 0;
838
838
  }
839
839
  };
840
-
841
- // src/index.ts
842
- export * from "@crosspost/types";
843
840
  export {
844
841
  ActivityApi,
845
842
  AuthApi,
846
843
  CrosspostClient,
844
+ CrosspostError,
847
845
  PostApi,
848
846
  SystemApi,
849
847
  apiWrapper,
850
- createNetworkError,
851
- enrichErrorWithContext,
852
848
  getErrorDetails,
853
849
  getErrorMessage,
854
- handleErrorResponse,
855
850
  isAuthError,
856
851
  isContentError,
857
852
  isMediaError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crosspost/sdk",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "SDK for interacting with the Crosspost API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -36,7 +36,7 @@
36
36
  "author": "crosspost.near",
37
37
  "license": "MIT",
38
38
  "dependencies": {
39
- "@crosspost/types": "^0.2.4",
39
+ "@crosspost/types": "^0.2.8",
40
40
  "near-sign-verify": "^0.2.0"
41
41
  },
42
42
  "devDependencies": {
package/src/api/post.ts CHANGED
@@ -1,19 +1,13 @@
1
1
  import type {
2
2
  ApiResponse,
3
3
  CreatePostRequest,
4
- CreatePostResponse,
5
4
  DeletePostRequest,
6
- DeletePostResponse,
7
5
  LikePostRequest,
8
- LikePostResponse,
6
+ MultiStatusData,
9
7
  QuotePostRequest,
10
- QuotePostResponse,
11
8
  ReplyToPostRequest,
12
- ReplyToPostResponse,
13
9
  RepostRequest,
14
- RepostResponse,
15
10
  UnlikePostRequest,
16
- UnlikePostResponse,
17
11
  } from '@crosspost/types';
18
12
  import { makeRequest, type RequestOptions } from '../core/request.ts';
19
13
 
@@ -36,8 +30,8 @@ export class PostApi {
36
30
  * @param request The post creation request details.
37
31
  * @returns A promise resolving with the post creation response.
38
32
  */
39
- async createPost(request: CreatePostRequest): Promise<ApiResponse<CreatePostResponse>> {
40
- return makeRequest<CreatePostResponse, CreatePostRequest>(
33
+ async createPost(request: CreatePostRequest): Promise<ApiResponse<MultiStatusData>> {
34
+ return makeRequest<MultiStatusData, CreatePostRequest>(
41
35
  'POST',
42
36
  '/api/post',
43
37
  this.options,
@@ -50,8 +44,8 @@ export class PostApi {
50
44
  * @param request The repost request details.
51
45
  * @returns A promise resolving with the repost response.
52
46
  */
53
- async repost(request: RepostRequest): Promise<ApiResponse<RepostResponse>> {
54
- return makeRequest<RepostResponse, RepostRequest>(
47
+ async repost(request: RepostRequest): Promise<ApiResponse<MultiStatusData>> {
48
+ return makeRequest<MultiStatusData, RepostRequest>(
55
49
  'POST',
56
50
  '/api/post/repost',
57
51
  this.options,
@@ -64,8 +58,8 @@ export class PostApi {
64
58
  * @param request The quote post request details.
65
59
  * @returns A promise resolving with the quote post response.
66
60
  */
67
- async quotePost(request: QuotePostRequest): Promise<ApiResponse<QuotePostResponse>> {
68
- return makeRequest<QuotePostResponse, QuotePostRequest>(
61
+ async quotePost(request: QuotePostRequest): Promise<ApiResponse<MultiStatusData>> {
62
+ return makeRequest<MultiStatusData, QuotePostRequest>(
69
63
  'POST',
70
64
  '/api/post/quote',
71
65
  this.options,
@@ -78,8 +72,8 @@ export class PostApi {
78
72
  * @param request The reply request details.
79
73
  * @returns A promise resolving with the reply response.
80
74
  */
81
- async replyToPost(request: ReplyToPostRequest): Promise<ApiResponse<ReplyToPostResponse>> {
82
- return makeRequest<ReplyToPostResponse, ReplyToPostRequest>(
75
+ async replyToPost(request: ReplyToPostRequest): Promise<ApiResponse<MultiStatusData>> {
76
+ return makeRequest<MultiStatusData, ReplyToPostRequest>(
83
77
  'POST',
84
78
  '/api/post/reply',
85
79
  this.options,
@@ -92,8 +86,8 @@ export class PostApi {
92
86
  * @param request The like request details.
93
87
  * @returns A promise resolving with the like response.
94
88
  */
95
- async likePost(request: LikePostRequest): Promise<ApiResponse<LikePostResponse>> {
96
- return makeRequest<LikePostResponse, LikePostRequest>(
89
+ async likePost(request: LikePostRequest): Promise<ApiResponse<MultiStatusData>> {
90
+ return makeRequest<MultiStatusData, LikePostRequest>(
97
91
  'POST',
98
92
  `/api/post/like`,
99
93
  this.options,
@@ -106,8 +100,8 @@ export class PostApi {
106
100
  * @param request The unlike request details.
107
101
  * @returns A promise resolving with the unlike response.
108
102
  */
109
- async unlikePost(request: UnlikePostRequest): Promise<ApiResponse<UnlikePostResponse>> {
110
- return makeRequest<UnlikePostResponse, UnlikePostRequest>(
103
+ async unlikePost(request: UnlikePostRequest): Promise<ApiResponse<MultiStatusData>> {
104
+ return makeRequest<MultiStatusData, UnlikePostRequest>(
111
105
  'DELETE',
112
106
  `/api/post/like`,
113
107
  this.options,
@@ -120,8 +114,8 @@ export class PostApi {
120
114
  * @param request The delete request details.
121
115
  * @returns A promise resolving with the delete response.
122
116
  */
123
- async deletePost(request: DeletePostRequest): Promise<ApiResponse<DeletePostResponse>> {
124
- return makeRequest<DeletePostResponse, DeletePostRequest>(
117
+ async deletePost(request: DeletePostRequest): Promise<ApiResponse<MultiStatusData>> {
118
+ return makeRequest<MultiStatusData, DeletePostRequest>(
125
119
  'DELETE',
126
120
  `/api/post`,
127
121
  this.options,
package/src/index.ts CHANGED
@@ -8,11 +8,9 @@ export { SystemApi } from './api/system.ts';
8
8
 
9
9
  export {
10
10
  apiWrapper,
11
- createNetworkError,
12
- enrichErrorWithContext,
11
+ CrosspostError,
13
12
  getErrorDetails,
14
13
  getErrorMessage,
15
- handleErrorResponse,
16
14
  isAuthError,
17
15
  isContentError,
18
16
  isMediaError,
@@ -23,6 +21,3 @@ export {
23
21
  isRecoverableError,
24
22
  isValidationError,
25
23
  } from './utils/error.ts';
26
-
27
- // Re-export types from @crosspost/types for convenience
28
- export * from '@crosspost/types';