@crosspost/sdk 0.2.7 → 0.2.9
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 +20 -28
- package/dist/index.d.cts +9 -22
- package/dist/index.d.ts +9 -22
- package/dist/index.js +18 -22
- package/package.json +2 -2
- package/src/api/activity.ts +30 -26
- package/src/api/post.ts +15 -21
- package/src/index.ts +1 -6
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,
|
@@ -374,23 +371,24 @@ async function makeRequest(method, path, options, data, query) {
|
|
374
371
|
// src/api/activity.ts
|
375
372
|
function createFilterQuery(query) {
|
376
373
|
if (!query) return {};
|
377
|
-
const queryObj = query;
|
378
374
|
const result = {};
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
375
|
+
if (query.limit !== void 0) {
|
376
|
+
result.limit = query.limit;
|
377
|
+
}
|
378
|
+
if (query.offset !== void 0) {
|
379
|
+
result.offset = query.offset;
|
380
|
+
}
|
381
|
+
if (query.filter) {
|
382
|
+
const filterParams = query.filter;
|
383
|
+
for (const filterKey in filterParams) {
|
384
|
+
if (Object.prototype.hasOwnProperty.call(filterParams, filterKey) && filterParams[filterKey] !== void 0) {
|
385
|
+
const value = filterParams[filterKey];
|
386
|
+
if (Array.isArray(value)) {
|
387
|
+
result[`filter[${filterKey}]`] = value.join(",");
|
388
|
+
} else {
|
389
|
+
result[`filter[${filterKey}]`] = String(value);
|
390
|
+
}
|
391
|
+
}
|
394
392
|
}
|
395
393
|
}
|
396
394
|
return result;
|
@@ -883,22 +881,17 @@ var CrosspostClient = class {
|
|
883
881
|
this.options.nearAccount = void 0;
|
884
882
|
}
|
885
883
|
};
|
886
|
-
|
887
|
-
// src/index.ts
|
888
|
-
__reExport(index_exports, require("@crosspost/types"), module.exports);
|
889
884
|
// Annotate the CommonJS export names for ESM import in node:
|
890
885
|
0 && (module.exports = {
|
891
886
|
ActivityApi,
|
892
887
|
AuthApi,
|
893
888
|
CrosspostClient,
|
889
|
+
CrosspostError,
|
894
890
|
PostApi,
|
895
891
|
SystemApi,
|
896
892
|
apiWrapper,
|
897
|
-
createNetworkError,
|
898
|
-
enrichErrorWithContext,
|
899
893
|
getErrorDetails,
|
900
894
|
getErrorMessage,
|
901
|
-
handleErrorResponse,
|
902
895
|
isAuthError,
|
903
896
|
isContentError,
|
904
897
|
isMediaError,
|
@@ -907,6 +900,5 @@ __reExport(index_exports, require("@crosspost/types"), module.exports);
|
|
907
900
|
isPostError,
|
908
901
|
isRateLimitError,
|
909
902
|
isRecoverableError,
|
910
|
-
isValidationError
|
911
|
-
...require("@crosspost/types")
|
903
|
+
isValidationError
|
912
904
|
});
|
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,
|
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<
|
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<
|
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<
|
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<
|
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<
|
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<
|
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<
|
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,
|
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,
|
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<
|
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<
|
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<
|
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<
|
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<
|
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<
|
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<
|
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,
|
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
@@ -328,23 +328,24 @@ async function makeRequest(method, path, options, data, query) {
|
|
328
328
|
// src/api/activity.ts
|
329
329
|
function createFilterQuery(query) {
|
330
330
|
if (!query) return {};
|
331
|
-
const queryObj = query;
|
332
331
|
const result = {};
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
332
|
+
if (query.limit !== void 0) {
|
333
|
+
result.limit = query.limit;
|
334
|
+
}
|
335
|
+
if (query.offset !== void 0) {
|
336
|
+
result.offset = query.offset;
|
337
|
+
}
|
338
|
+
if (query.filter) {
|
339
|
+
const filterParams = query.filter;
|
340
|
+
for (const filterKey in filterParams) {
|
341
|
+
if (Object.prototype.hasOwnProperty.call(filterParams, filterKey) && filterParams[filterKey] !== void 0) {
|
342
|
+
const value = filterParams[filterKey];
|
343
|
+
if (Array.isArray(value)) {
|
344
|
+
result[`filter[${filterKey}]`] = value.join(",");
|
345
|
+
} else {
|
346
|
+
result[`filter[${filterKey}]`] = String(value);
|
347
|
+
}
|
348
|
+
}
|
348
349
|
}
|
349
350
|
}
|
350
351
|
return result;
|
@@ -837,21 +838,16 @@ var CrosspostClient = class {
|
|
837
838
|
this.options.nearAccount = void 0;
|
838
839
|
}
|
839
840
|
};
|
840
|
-
|
841
|
-
// src/index.ts
|
842
|
-
export * from "@crosspost/types";
|
843
841
|
export {
|
844
842
|
ActivityApi,
|
845
843
|
AuthApi,
|
846
844
|
CrosspostClient,
|
845
|
+
CrosspostError,
|
847
846
|
PostApi,
|
848
847
|
SystemApi,
|
849
848
|
apiWrapper,
|
850
|
-
createNetworkError,
|
851
|
-
enrichErrorWithContext,
|
852
849
|
getErrorDetails,
|
853
850
|
getErrorMessage,
|
854
|
-
handleErrorResponse,
|
855
851
|
isAuthError,
|
856
852
|
isContentError,
|
857
853
|
isMediaError,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@crosspost/sdk",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.9",
|
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.
|
39
|
+
"@crosspost/types": "^0.2.8",
|
40
40
|
"near-sign-verify": "^0.2.0"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
package/src/api/activity.ts
CHANGED
@@ -10,40 +10,44 @@ import type {
|
|
10
10
|
import { makeRequest, type RequestOptions } from '../core/request.ts';
|
11
11
|
|
12
12
|
/**
|
13
|
-
* Creates a modified query object with filter properties
|
13
|
+
* Creates a modified query object with filter properties
|
14
14
|
* @param query The original query object
|
15
|
-
* @returns A new query object with filter properties
|
15
|
+
* @returns A new query object with filter properties formatted as filter[key]=value.
|
16
16
|
*/
|
17
|
-
function createFilterQuery<
|
17
|
+
function createFilterQuery<
|
18
|
+
T extends { filter?: Record<string, any>; limit?: number; offset?: number },
|
19
|
+
>(
|
20
|
+
query?: T,
|
21
|
+
): Record<string, string | number | boolean> {
|
18
22
|
if (!query) return {};
|
19
23
|
|
20
|
-
const
|
21
|
-
const result: Record<string, unknown> = {};
|
24
|
+
const result: Record<string, string | number | boolean> = {};
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}
|
29
|
-
|
30
|
-
// Extract and flatten filter properties if they exist
|
31
|
-
if (queryObj.filter) {
|
32
|
-
const filter = queryObj.filter;
|
33
|
-
|
34
|
-
if (filter.platforms && Array.isArray(filter.platforms)) {
|
35
|
-
result.platforms = filter.platforms.join(',');
|
36
|
-
}
|
37
|
-
|
38
|
-
if (filter.types && Array.isArray(filter.types)) {
|
39
|
-
result.types = filter.types.join(',');
|
40
|
-
}
|
26
|
+
if (query.limit !== undefined) {
|
27
|
+
result.limit = query.limit;
|
28
|
+
}
|
29
|
+
if (query.offset !== undefined) {
|
30
|
+
result.offset = query.offset;
|
31
|
+
}
|
41
32
|
|
42
|
-
|
43
|
-
|
33
|
+
// e.g., query.filter = { timeframe: 'month', platforms: ['twitter'] }
|
34
|
+
// becomes result['filter[timeframe]'] = 'month', result['filter[platforms]'] = 'twitter'
|
35
|
+
if (query.filter) {
|
36
|
+
const filterParams = query.filter;
|
37
|
+
for (const filterKey in filterParams) {
|
38
|
+
if (
|
39
|
+
Object.prototype.hasOwnProperty.call(filterParams, filterKey) &&
|
40
|
+
filterParams[filterKey] !== undefined
|
41
|
+
) {
|
42
|
+
const value = filterParams[filterKey];
|
43
|
+
if (Array.isArray(value)) {
|
44
|
+
result[`filter[${filterKey}]`] = value.join(',');
|
45
|
+
} else {
|
46
|
+
result[`filter[${filterKey}]`] = String(value);
|
47
|
+
}
|
48
|
+
}
|
44
49
|
}
|
45
50
|
}
|
46
|
-
|
47
51
|
return result;
|
48
52
|
}
|
49
53
|
|
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
|
-
|
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<
|
40
|
-
return makeRequest<
|
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<
|
54
|
-
return makeRequest<
|
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<
|
68
|
-
return makeRequest<
|
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<
|
82
|
-
return makeRequest<
|
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<
|
96
|
-
return makeRequest<
|
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<
|
110
|
-
return makeRequest<
|
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<
|
124
|
-
return makeRequest<
|
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
|
-
|
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';
|