@crosspost/sdk 0.1.6 → 0.1.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 +484 -681
- package/dist/index.d.cts +70 -89
- package/dist/index.d.ts +70 -89
- package/dist/index.js +476 -655
- package/package.json +1 -1
- package/src/api/activity.ts +3 -3
- package/src/api/auth.ts +44 -18
- package/src/api/post.ts +10 -22
- package/src/api/system.ts +12 -5
- package/src/core/client.ts +40 -1
- package/src/core/request.ts +71 -39
- package/src/index.ts +0 -10
- package/src/utils/error.ts +150 -247
package/dist/index.cjs
CHANGED
@@ -23,57 +23,46 @@ __export(index_exports, {
|
|
23
23
|
AccountActivityEntrySchema: () => AccountActivityEntrySchema,
|
24
24
|
AccountActivityParamsSchema: () => AccountActivityParamsSchema,
|
25
25
|
AccountActivityQuerySchema: () => AccountActivityQuerySchema,
|
26
|
-
AccountActivityResponseSchema: () => AccountActivityResponseSchema,
|
27
26
|
AccountPostSchema: () => AccountPostSchema,
|
28
27
|
AccountPostsParamsSchema: () => AccountPostsParamsSchema,
|
29
28
|
AccountPostsQuerySchema: () => AccountPostsQuerySchema,
|
30
|
-
AccountPostsResponseSchema: () => AccountPostsResponseSchema,
|
31
29
|
ActivityApi: () => ActivityApi,
|
32
30
|
ActivityLeaderboardQuerySchema: () => ActivityLeaderboardQuerySchema,
|
33
|
-
ActivityLeaderboardResponseSchema: () => ActivityLeaderboardResponseSchema,
|
34
31
|
AllRateLimitsResponseSchema: () => AllRateLimitsResponseSchema,
|
35
|
-
ApiError: () => ApiError,
|
36
32
|
ApiErrorCode: () => ApiErrorCode,
|
37
|
-
|
33
|
+
ApiErrorCodeSchema: () => ApiErrorCodeSchema,
|
38
34
|
AuthApi: () => AuthApi,
|
39
35
|
AuthCallbackQuerySchema: () => AuthCallbackQuerySchema,
|
40
36
|
AuthCallbackResponseSchema: () => AuthCallbackResponseSchema,
|
41
37
|
AuthInitRequestSchema: () => AuthInitRequestSchema,
|
42
38
|
AuthRevokeResponseSchema: () => AuthRevokeResponseSchema,
|
39
|
+
AuthStatusParamsSchema: () => AuthStatusParamsSchema,
|
43
40
|
AuthStatusResponseSchema: () => AuthStatusResponseSchema,
|
41
|
+
AuthTokenRequestSchema: () => AuthTokenRequestSchema,
|
44
42
|
AuthUrlResponseSchema: () => AuthUrlResponseSchema,
|
45
|
-
BaseError: () => BaseError,
|
46
|
-
CompositeApiError: () => CompositeApiError,
|
47
43
|
ConnectedAccountSchema: () => ConnectedAccountSchema,
|
48
44
|
ConnectedAccountsResponseSchema: () => ConnectedAccountsResponseSchema,
|
49
45
|
CreatePostRequestSchema: () => CreatePostRequestSchema,
|
50
|
-
CreatePostResponseLegacySchema: () => CreatePostResponseLegacySchema,
|
51
46
|
CreatePostResponseSchema: () => CreatePostResponseSchema,
|
52
|
-
CreatePostTargetErrorSchema: () => CreatePostTargetErrorSchema,
|
53
|
-
CreatePostTargetResultSchema: () => CreatePostTargetResultSchema,
|
54
47
|
CrosspostClient: () => CrosspostClient,
|
55
48
|
DeletePostRequestSchema: () => DeletePostRequestSchema,
|
56
49
|
DeletePostResponseSchema: () => DeletePostResponseSchema,
|
57
50
|
DeleteResultSchema: () => DeleteResultSchema,
|
58
|
-
ERROR_CATEGORIES: () => ERROR_CATEGORIES,
|
59
51
|
EndpointRateLimitResponseSchema: () => EndpointRateLimitResponseSchema,
|
60
|
-
EnhancedErrorResponseSchema: () => EnhancedErrorResponseSchema,
|
61
|
-
EnhancedResponseMetaSchema: () => EnhancedResponseMetaSchema,
|
62
|
-
EnhancedResponseSchema: () => EnhancedResponseSchema,
|
63
52
|
ErrorDetailSchema: () => ErrorDetailSchema,
|
64
|
-
|
53
|
+
HealthStatusSchema: () => HealthStatusSchema,
|
65
54
|
LikePostRequestSchema: () => LikePostRequestSchema,
|
66
55
|
LikePostResponseSchema: () => LikePostResponseSchema,
|
67
56
|
LikeResultSchema: () => LikeResultSchema,
|
68
57
|
MediaContentSchema: () => MediaContentSchema,
|
69
58
|
MediaSchema: () => MediaSchema,
|
70
|
-
|
59
|
+
MultiStatusDataSchema: () => MultiStatusDataSchema,
|
71
60
|
NearAuthorizationRequestSchema: () => NearAuthorizationRequestSchema,
|
72
61
|
NearAuthorizationResponseSchema: () => NearAuthorizationResponseSchema,
|
73
62
|
NearAuthorizationStatusResponseSchema: () => NearAuthorizationStatusResponseSchema,
|
63
|
+
NearUnauthorizationResponseSchema: () => NearUnauthorizationResponseSchema,
|
74
64
|
Platform: () => Platform,
|
75
65
|
PlatformActivitySchema: () => PlatformActivitySchema,
|
76
|
-
PlatformError: () => PlatformError,
|
77
66
|
PlatformParamSchema: () => PlatformParamSchema,
|
78
67
|
PlatformRateLimitSchema: () => PlatformRateLimitSchema,
|
79
68
|
PlatformSchema: () => PlatformSchema,
|
@@ -87,7 +76,6 @@ __export(index_exports, {
|
|
87
76
|
PostSuccessDetailSchema: () => PostSuccessDetailSchema,
|
88
77
|
PostToDeleteSchema: () => PostToDeleteSchema,
|
89
78
|
ProfileRefreshResponseSchema: () => ProfileRefreshResponseSchema,
|
90
|
-
ProfileRefreshResultSchema: () => ProfileRefreshResultSchema,
|
91
79
|
QuotePostRequestSchema: () => QuotePostRequestSchema,
|
92
80
|
QuotePostResponseSchema: () => QuotePostResponseSchema,
|
93
81
|
RateLimitEndpointParamSchema: () => RateLimitEndpointParamSchema,
|
@@ -99,6 +87,7 @@ __export(index_exports, {
|
|
99
87
|
ReplyToPostResponseSchema: () => ReplyToPostResponseSchema,
|
100
88
|
RepostRequestSchema: () => RepostRequestSchema,
|
101
89
|
RepostResponseSchema: () => RepostResponseSchema,
|
90
|
+
ResponseMetaSchema: () => ResponseMetaSchema,
|
102
91
|
SUPPORTED_PLATFORMS: () => SUPPORTED_PLATFORMS,
|
103
92
|
SuccessDetailSchema: () => SuccessDetailSchema,
|
104
93
|
SupportedPlatformSchema: () => SupportedPlatformSchema,
|
@@ -110,21 +99,14 @@ __export(index_exports, {
|
|
110
99
|
UsageRateLimitSchema: () => UsageRateLimitSchema,
|
111
100
|
UserProfileSchema: () => UserProfileSchema,
|
112
101
|
apiWrapper: () => apiWrapper,
|
113
|
-
createApiResponse: () => createApiResponse,
|
114
|
-
createEnhancedApiResponse: () => createEnhancedApiResponse,
|
115
|
-
createEnhancedErrorResponse: () => createEnhancedErrorResponse,
|
116
|
-
createErrorDetail: () => createErrorDetail,
|
117
|
-
createErrorResponse: () => createErrorResponse,
|
118
|
-
createMultiStatusResponse: () => createMultiStatusResponse,
|
119
102
|
createNetworkError: () => createNetworkError,
|
120
|
-
createSuccessDetail: () => createSuccessDetail,
|
121
103
|
enrichErrorWithContext: () => enrichErrorWithContext,
|
104
|
+
errorCodeToStatusCode: () => errorCodeToStatusCode,
|
122
105
|
getErrorDetails: () => getErrorDetails,
|
123
106
|
getErrorMessage: () => getErrorMessage,
|
124
107
|
handleErrorResponse: () => handleErrorResponse,
|
125
108
|
isAuthError: () => isAuthError,
|
126
109
|
isContentError: () => isContentError,
|
127
|
-
isErrorOfCategory: () => isErrorOfCategory,
|
128
110
|
isMediaError: () => isMediaError,
|
129
111
|
isNetworkError: () => isNetworkError,
|
130
112
|
isPlatformError: () => isPlatformError,
|
@@ -4213,162 +4195,6 @@ SupportedPlatformSchema.describe("Currently supported social media platforms");
|
|
4213
4195
|
function isPlatformSupported(platform) {
|
4214
4196
|
return SUPPORTED_PLATFORMS.includes(platform);
|
4215
4197
|
}
|
4216
|
-
var ApiResponseSchema = z.object({
|
4217
|
-
data: z.any().describe("Response data"),
|
4218
|
-
meta: z.object({
|
4219
|
-
rateLimit: z.object({
|
4220
|
-
remaining: z.number().describe("Number of requests remaining in the current window"),
|
4221
|
-
limit: z.number().describe("Total number of requests allowed in the window"),
|
4222
|
-
reset: z.number().describe("Timestamp when the rate limit resets (in seconds since epoch)")
|
4223
|
-
}).optional().describe("Rate limit information"),
|
4224
|
-
pagination: z.object({
|
4225
|
-
page: z.number().describe("Current page number"),
|
4226
|
-
perPage: z.number().describe("Number of items per page"),
|
4227
|
-
total: z.number().describe("Total number of items"),
|
4228
|
-
totalPages: z.number().describe("Total number of pages"),
|
4229
|
-
nextCursor: z.string().optional().describe("Next page cursor (if applicable)"),
|
4230
|
-
prevCursor: z.string().optional().describe("Previous page cursor (if applicable)")
|
4231
|
-
}).optional().describe("Pagination information")
|
4232
|
-
}).optional().describe("Response metadata")
|
4233
|
-
}).describe("Standard API response");
|
4234
|
-
var ErrorResponseSchema = z.object({
|
4235
|
-
error: z.object({
|
4236
|
-
type: z.string().describe("Error type"),
|
4237
|
-
message: z.string().describe("Error message"),
|
4238
|
-
code: z.string().optional().describe("Error code (if applicable)"),
|
4239
|
-
details: z.any().optional().describe("Additional error details")
|
4240
|
-
}).describe("Error information")
|
4241
|
-
}).describe("Error response");
|
4242
|
-
var EnhancedResponseMetaSchema = z.object({
|
4243
|
-
requestId: z.string().optional().describe("Unique request identifier"),
|
4244
|
-
timestamp: z.string().optional().describe("Request timestamp"),
|
4245
|
-
rateLimit: z.object({
|
4246
|
-
remaining: z.number().describe("Number of requests remaining in the current window"),
|
4247
|
-
limit: z.number().describe("Total number of requests allowed in the window"),
|
4248
|
-
reset: z.number().describe("Timestamp when the rate limit resets (in seconds since epoch)")
|
4249
|
-
}).optional().describe("Rate limit information"),
|
4250
|
-
pagination: z.object({
|
4251
|
-
page: z.number().describe("Current page number"),
|
4252
|
-
perPage: z.number().describe("Number of items per page"),
|
4253
|
-
total: z.number().describe("Total number of items"),
|
4254
|
-
totalPages: z.number().describe("Total number of pages"),
|
4255
|
-
nextCursor: z.string().optional().describe("Next page cursor (if applicable)"),
|
4256
|
-
prevCursor: z.string().optional().describe("Previous page cursor (if applicable)")
|
4257
|
-
}).optional().describe("Pagination information")
|
4258
|
-
}).optional().describe("Response metadata");
|
4259
|
-
var ErrorDetailSchema = z.object({
|
4260
|
-
platform: z.string().optional().describe("Platform associated with the error (if applicable)"),
|
4261
|
-
userId: z.string().optional().describe("User ID associated with the error (if applicable)"),
|
4262
|
-
status: z.literal("error").describe("Error status"),
|
4263
|
-
error: z.string().describe("Human-readable error message"),
|
4264
|
-
errorCode: z.string().describe("Machine-readable error code"),
|
4265
|
-
recoverable: z.boolean().describe("Whether the error is recoverable (can be retried)"),
|
4266
|
-
details: z.record(z.any()).optional().describe("Additional error details (platform-specific)")
|
4267
|
-
}).describe("Error detail");
|
4268
|
-
var EnhancedErrorResponseSchema = z.object({
|
4269
|
-
success: z.literal(false).describe("Success indicator (always false for error responses)"),
|
4270
|
-
errors: z.array(ErrorDetailSchema).describe("Error information")
|
4271
|
-
}).describe("Enhanced error response");
|
4272
|
-
var SuccessDetailSchema = z.object({
|
4273
|
-
platform: z.string().describe("Platform associated with the success"),
|
4274
|
-
userId: z.string().describe("User ID associated with the success"),
|
4275
|
-
status: z.literal("success").describe("Success status"),
|
4276
|
-
postId: z.string().optional().describe("Post ID (if applicable)"),
|
4277
|
-
postUrl: z.string().optional().describe("Post URL (if applicable)")
|
4278
|
-
}).catchall(z.any()).describe("Success detail");
|
4279
|
-
var MultiStatusResponseSchema = z.object({
|
4280
|
-
success: z.boolean().describe("Success indicator (true if at least one operation succeeded)"),
|
4281
|
-
data: z.object({
|
4282
|
-
summary: z.object({
|
4283
|
-
total: z.number().describe("Total number of operations"),
|
4284
|
-
succeeded: z.number().describe("Number of successful operations"),
|
4285
|
-
failed: z.number().describe("Number of failed operations")
|
4286
|
-
}).describe("Summary of operations"),
|
4287
|
-
results: z.array(SuccessDetailSchema).describe("Successful results"),
|
4288
|
-
errors: z.array(ErrorDetailSchema).describe("Failed results")
|
4289
|
-
}).describe("Response data")
|
4290
|
-
}).describe("Multi-status response");
|
4291
|
-
function EnhancedResponseSchema(schema) {
|
4292
|
-
return z.object({
|
4293
|
-
success: z.boolean().describe("Whether the request was successful"),
|
4294
|
-
data: schema,
|
4295
|
-
meta: EnhancedResponseMetaSchema
|
4296
|
-
});
|
4297
|
-
}
|
4298
|
-
function createEnhancedApiResponse(data, meta) {
|
4299
|
-
return {
|
4300
|
-
success: true,
|
4301
|
-
data,
|
4302
|
-
meta
|
4303
|
-
};
|
4304
|
-
}
|
4305
|
-
function createApiResponse(data, meta) {
|
4306
|
-
return {
|
4307
|
-
data,
|
4308
|
-
meta
|
4309
|
-
};
|
4310
|
-
}
|
4311
|
-
function createErrorResponse(type, message, code, details) {
|
4312
|
-
return {
|
4313
|
-
error: {
|
4314
|
-
type,
|
4315
|
-
message,
|
4316
|
-
...code ? { code } : {},
|
4317
|
-
...details ? { details } : {}
|
4318
|
-
}
|
4319
|
-
};
|
4320
|
-
}
|
4321
|
-
function createEnhancedErrorResponse(errors) {
|
4322
|
-
return {
|
4323
|
-
success: false,
|
4324
|
-
errors
|
4325
|
-
};
|
4326
|
-
}
|
4327
|
-
function createErrorDetail(error, errorCode, recoverable, platform, userId, details) {
|
4328
|
-
return {
|
4329
|
-
platform,
|
4330
|
-
userId,
|
4331
|
-
status: "error",
|
4332
|
-
error,
|
4333
|
-
errorCode,
|
4334
|
-
recoverable,
|
4335
|
-
details
|
4336
|
-
};
|
4337
|
-
}
|
4338
|
-
function createSuccessDetail(platform, userId, additionalData) {
|
4339
|
-
return {
|
4340
|
-
platform,
|
4341
|
-
userId,
|
4342
|
-
status: "success",
|
4343
|
-
...additionalData
|
4344
|
-
};
|
4345
|
-
}
|
4346
|
-
function createMultiStatusResponse(results, errors) {
|
4347
|
-
const total = results.length + errors.length;
|
4348
|
-
const succeeded = results.length;
|
4349
|
-
const failed = errors.length;
|
4350
|
-
return {
|
4351
|
-
success: succeeded > 0,
|
4352
|
-
data: {
|
4353
|
-
summary: {
|
4354
|
-
total,
|
4355
|
-
succeeded,
|
4356
|
-
failed
|
4357
|
-
},
|
4358
|
-
results,
|
4359
|
-
errors
|
4360
|
-
}
|
4361
|
-
};
|
4362
|
-
}
|
4363
|
-
var BaseError = class extends Error {
|
4364
|
-
constructor(message) {
|
4365
|
-
super(message);
|
4366
|
-
this.name = this.constructor.name;
|
4367
|
-
if (Error.captureStackTrace) {
|
4368
|
-
Error.captureStackTrace(this, this.constructor);
|
4369
|
-
}
|
4370
|
-
}
|
4371
|
-
};
|
4372
4198
|
var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
|
4373
4199
|
ApiErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
4374
4200
|
ApiErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
@@ -4383,120 +4209,138 @@ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
|
|
4383
4209
|
ApiErrorCode2["CONTENT_POLICY_VIOLATION"] = "CONTENT_POLICY_VIOLATION";
|
4384
4210
|
ApiErrorCode2["DUPLICATE_CONTENT"] = "DUPLICATE_CONTENT";
|
4385
4211
|
ApiErrorCode2["MEDIA_UPLOAD_FAILED"] = "MEDIA_UPLOAD_FAILED";
|
4212
|
+
ApiErrorCode2["MULTI_STATUS"] = "MULTI_STATUS";
|
4386
4213
|
ApiErrorCode2["POST_CREATION_FAILED"] = "POST_CREATION_FAILED";
|
4387
4214
|
ApiErrorCode2["THREAD_CREATION_FAILED"] = "THREAD_CREATION_FAILED";
|
4388
4215
|
ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
|
4389
4216
|
ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
|
4390
4217
|
ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
4391
|
-
ApiErrorCode2["MULTI_STATUS"] = "MULTI_STATUS";
|
4392
4218
|
return ApiErrorCode2;
|
4393
4219
|
})(ApiErrorCode || {});
|
4394
|
-
var
|
4395
|
-
|
4396
|
-
|
4397
|
-
|
4398
|
-
|
4399
|
-
|
4400
|
-
|
4401
|
-
|
4402
|
-
|
4403
|
-
|
4404
|
-
|
4405
|
-
|
4406
|
-
|
4407
|
-
|
4408
|
-
|
4409
|
-
|
4410
|
-
|
4411
|
-
|
4412
|
-
|
4413
|
-
|
4414
|
-
|
4415
|
-
|
4416
|
-
|
4417
|
-
|
4418
|
-
|
4419
|
-
|
4420
|
-
|
4421
|
-
|
4422
|
-
|
4423
|
-
|
4424
|
-
|
4425
|
-
|
4426
|
-
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
|
4439
|
-
|
4440
|
-
|
4441
|
-
|
4442
|
-
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
|
4451
|
-
|
4452
|
-
|
4453
|
-
|
4454
|
-
|
4455
|
-
|
4456
|
-
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4464
|
-
|
4465
|
-
|
4466
|
-
|
4467
|
-
|
4468
|
-
|
4469
|
-
|
4470
|
-
|
4471
|
-
|
4472
|
-
);
|
4473
|
-
}
|
4474
|
-
};
|
4475
|
-
var PlatformError = class extends Error {
|
4476
|
-
constructor(message, platform, code = "PLATFORM_ERROR", recoverable = false, originalError, status, userId, details) {
|
4477
|
-
super(message);
|
4478
|
-
this.originalError = originalError;
|
4479
|
-
this.status = status;
|
4480
|
-
this.name = "PlatformError";
|
4481
|
-
this.code = code;
|
4482
|
-
this.recoverable = recoverable;
|
4483
|
-
this.platform = platform;
|
4484
|
-
this.userId = userId;
|
4485
|
-
this.details = details;
|
4486
|
-
}
|
4487
|
-
};
|
4488
|
-
var CompositeApiError = class extends ApiError {
|
4489
|
-
constructor(message, errors, status = 207, details, recoverable = false) {
|
4490
|
-
super(
|
4491
|
-
message,
|
4492
|
-
"MULTI_STATUS",
|
4493
|
-
status,
|
4494
|
-
{ ...details, errors },
|
4495
|
-
recoverable
|
4496
|
-
);
|
4497
|
-
this.errors = errors;
|
4498
|
-
}
|
4220
|
+
var ApiErrorCodeSchema = z.enum(Object.values(ApiErrorCode));
|
4221
|
+
var errorCodeToStatusCode = {
|
4222
|
+
[
|
4223
|
+
"MULTI_STATUS"
|
4224
|
+
/* MULTI_STATUS */
|
4225
|
+
]: 207,
|
4226
|
+
[
|
4227
|
+
"UNKNOWN_ERROR"
|
4228
|
+
/* UNKNOWN_ERROR */
|
4229
|
+
]: 500,
|
4230
|
+
[
|
4231
|
+
"INTERNAL_ERROR"
|
4232
|
+
/* INTERNAL_ERROR */
|
4233
|
+
]: 500,
|
4234
|
+
[
|
4235
|
+
"VALIDATION_ERROR"
|
4236
|
+
/* VALIDATION_ERROR */
|
4237
|
+
]: 400,
|
4238
|
+
[
|
4239
|
+
"INVALID_REQUEST"
|
4240
|
+
/* INVALID_REQUEST */
|
4241
|
+
]: 400,
|
4242
|
+
[
|
4243
|
+
"NOT_FOUND"
|
4244
|
+
/* NOT_FOUND */
|
4245
|
+
]: 404,
|
4246
|
+
[
|
4247
|
+
"UNAUTHORIZED"
|
4248
|
+
/* UNAUTHORIZED */
|
4249
|
+
]: 401,
|
4250
|
+
[
|
4251
|
+
"FORBIDDEN"
|
4252
|
+
/* FORBIDDEN */
|
4253
|
+
]: 403,
|
4254
|
+
[
|
4255
|
+
"RATE_LIMITED"
|
4256
|
+
/* RATE_LIMITED */
|
4257
|
+
]: 429,
|
4258
|
+
[
|
4259
|
+
"PLATFORM_ERROR"
|
4260
|
+
/* PLATFORM_ERROR */
|
4261
|
+
]: 502,
|
4262
|
+
[
|
4263
|
+
"PLATFORM_UNAVAILABLE"
|
4264
|
+
/* PLATFORM_UNAVAILABLE */
|
4265
|
+
]: 503,
|
4266
|
+
[
|
4267
|
+
"CONTENT_POLICY_VIOLATION"
|
4268
|
+
/* CONTENT_POLICY_VIOLATION */
|
4269
|
+
]: 400,
|
4270
|
+
[
|
4271
|
+
"DUPLICATE_CONTENT"
|
4272
|
+
/* DUPLICATE_CONTENT */
|
4273
|
+
]: 400,
|
4274
|
+
[
|
4275
|
+
"MEDIA_UPLOAD_FAILED"
|
4276
|
+
/* MEDIA_UPLOAD_FAILED */
|
4277
|
+
]: 400,
|
4278
|
+
[
|
4279
|
+
"POST_CREATION_FAILED"
|
4280
|
+
/* POST_CREATION_FAILED */
|
4281
|
+
]: 500,
|
4282
|
+
[
|
4283
|
+
"THREAD_CREATION_FAILED"
|
4284
|
+
/* THREAD_CREATION_FAILED */
|
4285
|
+
]: 500,
|
4286
|
+
[
|
4287
|
+
"POST_DELETION_FAILED"
|
4288
|
+
/* POST_DELETION_FAILED */
|
4289
|
+
]: 500,
|
4290
|
+
[
|
4291
|
+
"POST_INTERACTION_FAILED"
|
4292
|
+
/* POST_INTERACTION_FAILED */
|
4293
|
+
]: 500,
|
4294
|
+
[
|
4295
|
+
"NETWORK_ERROR"
|
4296
|
+
/* NETWORK_ERROR */
|
4297
|
+
]: 503
|
4499
4298
|
};
|
4299
|
+
var ErrorDetailSchema = z.object({
|
4300
|
+
message: z.string().describe("Human-readable error message"),
|
4301
|
+
code: ApiErrorCodeSchema.describe("Machine-readable error code"),
|
4302
|
+
recoverable: z.boolean().describe("Whether the error can be recovered from"),
|
4303
|
+
details: z.record(z.unknown()).optional().describe("Additional error details")
|
4304
|
+
});
|
4305
|
+
var ResponseMetaSchema = z.object({
|
4306
|
+
requestId: z.string().uuid().describe("Unique identifier for the request"),
|
4307
|
+
timestamp: z.string().datetime().describe("ISO timestamp of response generation"),
|
4308
|
+
rateLimit: z.object({
|
4309
|
+
remaining: z.number().int().nonnegative(),
|
4310
|
+
limit: z.number().int().positive(),
|
4311
|
+
reset: z.number().int().positive().describe("Unix timestamp (seconds)")
|
4312
|
+
}).optional().describe("Rate limit information if applicable"),
|
4313
|
+
pagination: z.object({
|
4314
|
+
page: z.number().int().positive().optional(),
|
4315
|
+
perPage: z.number().int().positive().optional(),
|
4316
|
+
total: z.number().int().nonnegative().optional(),
|
4317
|
+
limit: z.number().int().nonnegative().optional(),
|
4318
|
+
offset: z.number().int().nonnegative().optional(),
|
4319
|
+
totalPages: z.number().int().nonnegative().optional(),
|
4320
|
+
nextCursor: z.string().optional(),
|
4321
|
+
prevCursor: z.string().optional()
|
4322
|
+
}).optional().describe("Pagination information if applicable")
|
4323
|
+
});
|
4324
|
+
var SuccessDetailSchema = z.object({
|
4325
|
+
platform: z.string(),
|
4326
|
+
userId: z.string(),
|
4327
|
+
additionalData: z.any().optional(),
|
4328
|
+
status: z.literal("success")
|
4329
|
+
}).catchall(z.any());
|
4330
|
+
var HealthStatusSchema = z.object({
|
4331
|
+
status: z.string().describe("Health status of the API"),
|
4332
|
+
version: z.string().optional().describe("API version"),
|
4333
|
+
timestamp: z.string().datetime().describe("Current server time")
|
4334
|
+
}).describe("Health status response");
|
4335
|
+
var MultiStatusDataSchema = z.object({
|
4336
|
+
summary: z.object({
|
4337
|
+
total: z.number().int().nonnegative(),
|
4338
|
+
succeeded: z.number().int().nonnegative(),
|
4339
|
+
failed: z.number().int().nonnegative()
|
4340
|
+
}),
|
4341
|
+
results: z.array(SuccessDetailSchema),
|
4342
|
+
errors: z.array(ErrorDetailSchema)
|
4343
|
+
});
|
4500
4344
|
var PlatformParamSchema = z.object({
|
4501
4345
|
platform: z.string().describe("Social media platform")
|
4502
4346
|
}).describe("Platform parameter");
|
@@ -4506,44 +4350,45 @@ var AuthInitRequestSchema = z.object({
|
|
4506
4350
|
),
|
4507
4351
|
errorUrl: z.string().url().optional().describe("URL to redirect to on authentication error")
|
4508
4352
|
}).describe("Auth initialization request");
|
4509
|
-
var AuthUrlResponseSchema =
|
4510
|
-
z.
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4514
|
-
})
|
4515
|
-
).describe("Auth URL response");
|
4353
|
+
var AuthUrlResponseSchema = z.object({
|
4354
|
+
url: z.string().describe("Authentication URL to redirect the user to"),
|
4355
|
+
state: z.string().describe("State parameter for CSRF protection"),
|
4356
|
+
platform: PlatformSchema
|
4357
|
+
}).describe("Auth URL response");
|
4516
4358
|
var AuthCallbackQuerySchema = z.object({
|
4517
4359
|
code: z.string().describe("Authorization code from OAuth provider"),
|
4518
4360
|
state: z.string().describe("State parameter for CSRF protection")
|
4519
4361
|
}).describe("Auth callback query");
|
4520
|
-
var AuthCallbackResponseSchema =
|
4521
|
-
|
4522
|
-
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4526
|
-
|
4527
|
-
).describe("
|
4528
|
-
|
4529
|
-
|
4530
|
-
|
4531
|
-
|
4532
|
-
|
4533
|
-
|
4534
|
-
|
4535
|
-
|
4536
|
-
|
4537
|
-
|
4538
|
-
|
4539
|
-
).describe("
|
4540
|
-
|
4541
|
-
z.object({
|
4542
|
-
success: z.boolean().describe("Whether the revocation was successful"),
|
4543
|
-
platform: PlatformSchema,
|
4544
|
-
userId: z.string().describe("User ID")
|
4362
|
+
var AuthCallbackResponseSchema = z.object({
|
4363
|
+
platform: PlatformSchema,
|
4364
|
+
userId: z.string().describe("User ID"),
|
4365
|
+
redirectUrl: z.string().optional().describe("URL to redirect the user to after authentication")
|
4366
|
+
}).describe("Auth callback response");
|
4367
|
+
var AuthStatusParamsSchema = z.object({
|
4368
|
+
platform: z.string().describe("Social media platform"),
|
4369
|
+
userId: z.string().describe("User ID on the platform")
|
4370
|
+
}).describe("Token status parameters");
|
4371
|
+
var NearUnauthorizationResponseSchema = z.object({
|
4372
|
+
success: z.boolean().describe("Whether the unauthorized operation was successful"),
|
4373
|
+
nearAccount: z.string().describe("NEAR account ID that was unauthorized")
|
4374
|
+
}).describe("NEAR unauthorized response");
|
4375
|
+
var AuthStatusResponseSchema = z.object({
|
4376
|
+
platform: PlatformSchema,
|
4377
|
+
userId: z.string().describe("User ID"),
|
4378
|
+
authenticated: z.boolean().describe("Whether the user is authenticated"),
|
4379
|
+
tokenStatus: z.object({
|
4380
|
+
valid: z.boolean().describe("Whether the token is valid"),
|
4381
|
+
expired: z.boolean().describe("Whether the token is expired"),
|
4382
|
+
expiresAt: z.string().optional().describe("When the token expires")
|
4545
4383
|
})
|
4546
|
-
).describe("Auth
|
4384
|
+
}).describe("Auth status response");
|
4385
|
+
var AuthTokenRequestSchema = z.object({
|
4386
|
+
userId: z.string().describe("User ID on the platform")
|
4387
|
+
}).describe("Auth token request");
|
4388
|
+
var AuthRevokeResponseSchema = z.object({
|
4389
|
+
platform: PlatformSchema,
|
4390
|
+
userId: z.string().describe("User ID")
|
4391
|
+
}).describe("Auth revoke response");
|
4547
4392
|
var ConnectedAccountSchema = z.object({
|
4548
4393
|
platform: PlatformSchema,
|
4549
4394
|
userId: z.string().describe("User ID on the platform"),
|
@@ -4551,26 +4396,21 @@ var ConnectedAccountSchema = z.object({
|
|
4551
4396
|
profileUrl: z.string().optional().describe("URL to the user profile"),
|
4552
4397
|
connectedAt: z.string().optional().describe("When the account was connected")
|
4553
4398
|
}).describe("Connected account");
|
4554
|
-
var ConnectedAccountsResponseSchema =
|
4555
|
-
|
4556
|
-
)
|
4399
|
+
var ConnectedAccountsResponseSchema = z.array(ConnectedAccountSchema).describe(
|
4400
|
+
"Connected accounts response"
|
4401
|
+
);
|
4557
4402
|
var NearAuthorizationRequestSchema = z.object({
|
4558
4403
|
// No additional parameters needed, as the NEAR account ID is extracted from the signature
|
4559
4404
|
}).describe("NEAR authorization request");
|
4560
|
-
var NearAuthorizationResponseSchema =
|
4561
|
-
z.
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
).describe("
|
4567
|
-
|
4568
|
-
|
4569
|
-
nearAccount: z.string().describe("NEAR account ID"),
|
4570
|
-
authorized: z.boolean().describe("Whether the account is authorized"),
|
4571
|
-
authorizedAt: z.string().optional().describe("When the account was authorized")
|
4572
|
-
})
|
4573
|
-
).describe("NEAR authorization status response");
|
4405
|
+
var NearAuthorizationResponseSchema = z.object({
|
4406
|
+
nearAccount: z.string().describe("NEAR account ID"),
|
4407
|
+
authorized: z.boolean().describe("Whether the account is authorized")
|
4408
|
+
}).describe("NEAR authorization response");
|
4409
|
+
var NearAuthorizationStatusResponseSchema = z.object({
|
4410
|
+
nearAccount: z.string().describe("NEAR account ID"),
|
4411
|
+
authorized: z.boolean().describe("Whether the account is authorized"),
|
4412
|
+
authorizedAt: z.string().optional().describe("When the account was authorized")
|
4413
|
+
}).describe("NEAR authorization status response");
|
4574
4414
|
var MediaContentSchema = z.object({
|
4575
4415
|
data: z.union([z.string(), z.instanceof(Blob)]).describe("Media data as string or Blob"),
|
4576
4416
|
mimeType: z.string().optional().describe("Media MIME type"),
|
@@ -4685,65 +4525,33 @@ var UnlikePostRequestSchema = z.object({
|
|
4685
4525
|
platform: PlatformSchema.describe("Platform of the post being unliked"),
|
4686
4526
|
postId: z.string().describe("ID of the post to unlike")
|
4687
4527
|
}).describe("Unlike post request");
|
4688
|
-
var PostResponseSchema =
|
4689
|
-
|
4690
|
-
)
|
4691
|
-
var
|
4692
|
-
"Create post response
|
4528
|
+
var PostResponseSchema = z.union([PostSchema, z.array(PostSchema)]).describe(
|
4529
|
+
"Post response"
|
4530
|
+
);
|
4531
|
+
var CreatePostResponseSchema = PostResponseSchema.describe(
|
4532
|
+
"Create post response"
|
4693
4533
|
);
|
4694
4534
|
var RepostResponseSchema = PostResponseSchema.describe("Repost response");
|
4695
4535
|
var QuotePostResponseSchema = PostResponseSchema.describe("Quote post response");
|
4696
4536
|
var ReplyToPostResponseSchema = PostResponseSchema.describe("Reply to post response");
|
4697
|
-
var DeletePostResponseSchema =
|
4698
|
-
z.
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4702
|
-
).describe("
|
4703
|
-
var
|
4704
|
-
z.
|
4705
|
-
|
4706
|
-
id: z.string().describe("ID of the liked post")
|
4707
|
-
})
|
4708
|
-
).describe("Like post response");
|
4709
|
-
var UnlikePostResponseSchema = EnhancedResponseSchema(
|
4710
|
-
z.object({
|
4711
|
-
success: z.boolean().describe("Whether the unlike was successful"),
|
4712
|
-
id: z.string().describe("ID of the unliked post")
|
4713
|
-
})
|
4714
|
-
).describe("Unlike post response");
|
4537
|
+
var DeletePostResponseSchema = z.object({
|
4538
|
+
id: z.string().describe("ID of the deleted post")
|
4539
|
+
}).describe("Delete post response");
|
4540
|
+
var LikePostResponseSchema = z.object({
|
4541
|
+
id: z.string().describe("ID of the liked post")
|
4542
|
+
}).describe("Like post response");
|
4543
|
+
var UnlikePostResponseSchema = z.object({
|
4544
|
+
id: z.string().describe("ID of the unliked post")
|
4545
|
+
}).describe("Unlike post response");
|
4715
4546
|
var PostMultiStatusResponseSchema = z.object({
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
4723
|
-
results: z.array(PostSuccessDetailSchema).describe("Successful operations"),
|
4724
|
-
errors: z.array(ErrorDetailSchema).describe("Failed operations")
|
4725
|
-
})
|
4547
|
+
summary: z.object({
|
4548
|
+
total: z.number().describe("Total number of operations"),
|
4549
|
+
succeeded: z.number().describe("Number of successful operations"),
|
4550
|
+
failed: z.number().describe("Number of failed operations")
|
4551
|
+
}),
|
4552
|
+
results: z.array(PostSuccessDetailSchema).describe("Successful operations"),
|
4553
|
+
errors: z.array(ErrorDetailSchema).describe("Failed operations")
|
4726
4554
|
}).describe("Multi-status response for post operations");
|
4727
|
-
var CreatePostTargetResultSchema = z.object({
|
4728
|
-
platform: PlatformSchema.describe("The platform the post was created on"),
|
4729
|
-
userId: z.string().describe("The user ID on the platform"),
|
4730
|
-
result: z.array(z.any()).describe("The result of the post creation")
|
4731
|
-
}).describe("Create post target result");
|
4732
|
-
var CreatePostTargetErrorSchema = z.object({
|
4733
|
-
platform: PlatformSchema.optional().describe(
|
4734
|
-
"The platform where the error occurred (if applicable)"
|
4735
|
-
),
|
4736
|
-
userId: z.string().optional().describe("The user ID where the error occurred (if applicable)"),
|
4737
|
-
error: z.string().describe("The error message")
|
4738
|
-
}).describe("Create post target error");
|
4739
|
-
var CreatePostResponseSchema = EnhancedResponseSchema(
|
4740
|
-
z.object({
|
4741
|
-
results: z.array(CreatePostTargetResultSchema).describe("Array of successful post results"),
|
4742
|
-
errors: z.array(CreatePostTargetErrorSchema).optional().describe(
|
4743
|
-
"Array of errors that occurred (if any)"
|
4744
|
-
)
|
4745
|
-
})
|
4746
|
-
).describe("Create post response");
|
4747
4555
|
var RateLimitEndpointParamSchema = z.object({
|
4748
4556
|
endpoint: z.string().optional().describe(
|
4749
4557
|
"Specific endpoint to get rate limit information for (optional)"
|
@@ -4778,43 +4586,39 @@ var UsageRateLimitSchema = z.object({
|
|
4778
4586
|
resetSeconds: z.number().describe("Seconds until the rate limit will reset"),
|
4779
4587
|
timeWindow: z.string().describe("Time window for the rate limit")
|
4780
4588
|
}).describe("Usage rate limit");
|
4781
|
-
var RateLimitStatusResponseSchema =
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4789
|
-
|
4790
|
-
|
4791
|
-
|
4792
|
-
|
4793
|
-
|
4794
|
-
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
).describe("
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
})
|
4815
|
-
).describe("Rate limits by platform")
|
4816
|
-
})
|
4817
|
-
).describe("All rate limits response");
|
4589
|
+
var RateLimitStatusResponseSchema = z.object({
|
4590
|
+
platform: PlatformSchema,
|
4591
|
+
userId: z.string().optional().describe("User ID"),
|
4592
|
+
endpoints: z.array(RateLimitEndpointSchema).describe("Rate limits for specific endpoints"),
|
4593
|
+
app: z.object({
|
4594
|
+
limit: z.number().describe("App-wide rate limit"),
|
4595
|
+
remaining: z.number().describe("Remaining requests"),
|
4596
|
+
reset: z.number().describe("Reset timestamp (Unix timestamp in seconds)"),
|
4597
|
+
resetDate: z.string().describe("Reset date (ISO string)")
|
4598
|
+
}).optional().describe("App-wide rate limits")
|
4599
|
+
}).describe("Rate limit status response");
|
4600
|
+
var AllRateLimitsResponseSchema = z.object({
|
4601
|
+
platforms: z.record(
|
4602
|
+
PlatformSchema,
|
4603
|
+
z.object({
|
4604
|
+
users: z.record(
|
4605
|
+
z.string(),
|
4606
|
+
z.object({
|
4607
|
+
endpoints: z.array(RateLimitEndpointSchema).describe(
|
4608
|
+
"Rate limits for specific endpoints"
|
4609
|
+
),
|
4610
|
+
lastUpdated: z.string().describe("Last updated date (ISO string)")
|
4611
|
+
})
|
4612
|
+
).describe("User-specific rate limits"),
|
4613
|
+
app: z.object({
|
4614
|
+
limit: z.number().describe("App-wide rate limit"),
|
4615
|
+
remaining: z.number().describe("Remaining requests"),
|
4616
|
+
reset: z.number().describe("Reset timestamp (Unix timestamp in seconds)"),
|
4617
|
+
resetDate: z.string().describe("Reset date (ISO string)")
|
4618
|
+
}).optional().describe("App-wide rate limits")
|
4619
|
+
})
|
4620
|
+
).describe("Rate limits by platform")
|
4621
|
+
}).describe("All rate limits response");
|
4818
4622
|
var RateLimitResponseSchema = z.object({
|
4819
4623
|
platformLimits: z.array(PlatformRateLimitSchema).describe("Platform-specific rate limits"),
|
4820
4624
|
usageLimits: z.record(z.string(), UsageRateLimitSchema).describe(
|
@@ -4859,16 +4663,12 @@ var AccountActivityEntrySchema = z.object({
|
|
4859
4663
|
rank: z.number().describe("Rank on the leaderboard"),
|
4860
4664
|
lastActive: z.string().datetime().describe("Timestamp of last activity")
|
4861
4665
|
}).describe("Account activity entry");
|
4862
|
-
var ActivityLeaderboardResponseSchema =
|
4863
|
-
z.
|
4864
|
-
|
4865
|
-
|
4866
|
-
|
4867
|
-
|
4868
|
-
offset: z.number().describe("Offset for pagination"),
|
4869
|
-
generatedAt: z.string().datetime().describe("Timestamp when the leaderboard was generated")
|
4870
|
-
})
|
4871
|
-
).describe("Activity leaderboard response");
|
4666
|
+
var ActivityLeaderboardResponseSchema = z.object({
|
4667
|
+
timeframe: z.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
|
4668
|
+
entries: z.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
|
4669
|
+
generatedAt: z.string().datetime().describe("Timestamp when the leaderboard was generated"),
|
4670
|
+
platform: PlatformSchema.optional().describe("Platform filter (if applied)")
|
4671
|
+
});
|
4872
4672
|
var AccountActivityParamsSchema = z.object({
|
4873
4673
|
signerId: z.string().describe("NEAR account ID")
|
4874
4674
|
}).describe("Account activity params");
|
@@ -4887,21 +4687,19 @@ var PlatformActivitySchema = z.object({
|
|
4887
4687
|
score: z.number().describe("Activity score on this platform"),
|
4888
4688
|
lastActive: z.string().datetime().describe("Timestamp of last activity on this platform")
|
4889
4689
|
}).describe("Platform activity");
|
4890
|
-
var AccountActivityResponseSchema =
|
4891
|
-
z.
|
4892
|
-
|
4893
|
-
|
4894
|
-
|
4895
|
-
|
4896
|
-
|
4897
|
-
|
4898
|
-
|
4899
|
-
|
4900
|
-
|
4901
|
-
|
4902
|
-
|
4903
|
-
})
|
4904
|
-
).describe("Account activity response");
|
4690
|
+
var AccountActivityResponseSchema = z.object({
|
4691
|
+
signerId: z.string().describe("NEAR account ID"),
|
4692
|
+
timeframe: z.nativeEnum(TimePeriod).describe("Timeframe for the activity"),
|
4693
|
+
totalPosts: z.number().describe("Total number of posts across all platforms"),
|
4694
|
+
totalLikes: z.number().describe("Total number of likes across all platforms"),
|
4695
|
+
totalReposts: z.number().describe("Total number of reposts across all platforms"),
|
4696
|
+
totalReplies: z.number().describe("Total number of replies across all platforms"),
|
4697
|
+
totalQuotes: z.number().describe("Total number of quote posts across all platforms"),
|
4698
|
+
totalScore: z.number().describe("Total activity score across all platforms"),
|
4699
|
+
rank: z.number().describe("Rank on the leaderboard"),
|
4700
|
+
lastActive: z.string().datetime().describe("Timestamp of last activity across all platforms"),
|
4701
|
+
platforms: z.array(PlatformActivitySchema).describe("Activity breakdown by platform")
|
4702
|
+
});
|
4905
4703
|
var AccountPostsParamsSchema = z.object({
|
4906
4704
|
signerId: z.string().describe("NEAR account ID")
|
4907
4705
|
}).describe("Account posts params");
|
@@ -4929,19 +4727,14 @@ var AccountPostSchema = z.object({
|
|
4929
4727
|
inReplyToId: z.string().optional().describe("ID of the post this is a reply to (if applicable)"),
|
4930
4728
|
quotedPostId: z.string().optional().describe("ID of the post this is quoting (if applicable)")
|
4931
4729
|
}).describe("Account post");
|
4932
|
-
var AccountPostsResponseSchema =
|
4933
|
-
z.
|
4934
|
-
|
4935
|
-
|
4936
|
-
|
4937
|
-
|
4938
|
-
|
4939
|
-
|
4940
|
-
type: z.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
|
4941
|
-
"Post type filter (if applied)"
|
4942
|
-
)
|
4943
|
-
})
|
4944
|
-
).describe("Account posts response");
|
4730
|
+
var AccountPostsResponseSchema = z.object({
|
4731
|
+
signerId: z.string().describe("NEAR account ID"),
|
4732
|
+
posts: z.array(AccountPostSchema).describe("List of posts"),
|
4733
|
+
platform: z.string().optional().describe("Platform filter (if applied)"),
|
4734
|
+
type: z.enum(["post", "repost", "reply", "quote", "like", "all"]).optional().describe(
|
4735
|
+
"Post type filter (if applied)"
|
4736
|
+
)
|
4737
|
+
});
|
4945
4738
|
var UserProfileSchema = z.object({
|
4946
4739
|
userId: z.string().describe("User ID on the platform"),
|
4947
4740
|
username: z.string().describe("Username on the platform"),
|
@@ -4951,118 +4744,107 @@ var UserProfileSchema = z.object({
|
|
4951
4744
|
platform: PlatformSchema.describe("The platform the user profile is from"),
|
4952
4745
|
lastUpdated: z.number().describe("Timestamp when the profile was last updated")
|
4953
4746
|
}).describe("User profile");
|
4954
|
-
var
|
4955
|
-
|
4956
|
-
|
4957
|
-
error: z.string().optional().describe("Error message (if unsuccessful)")
|
4958
|
-
}).describe("Profile refresh result");
|
4959
|
-
var ProfileRefreshResponseSchema = EnhancedResponseSchema(
|
4960
|
-
ProfileRefreshResultSchema
|
4961
|
-
).describe("Profile refresh response");
|
4747
|
+
var ProfileRefreshResponseSchema = z.object({
|
4748
|
+
profile: UserProfileSchema.optional().describe("The refreshed user profile (if successful)")
|
4749
|
+
}).describe("Profile refresh response");
|
4962
4750
|
|
4963
4751
|
// src/core/request.ts
|
4964
4752
|
var import_near_sign_verify = require("near-sign-verify");
|
4965
4753
|
|
4966
4754
|
// src/utils/error.ts
|
4967
|
-
var
|
4968
|
-
|
4969
|
-
|
4970
|
-
|
4971
|
-
|
4972
|
-
|
4973
|
-
|
4974
|
-
|
4975
|
-
],
|
4976
|
-
NETWORK: [
|
4977
|
-
ApiErrorCode.NETWORK_ERROR
|
4978
|
-
],
|
4979
|
-
PLATFORM: [
|
4980
|
-
ApiErrorCode.PLATFORM_ERROR,
|
4981
|
-
ApiErrorCode.PLATFORM_UNAVAILABLE
|
4982
|
-
],
|
4983
|
-
CONTENT: [
|
4984
|
-
ApiErrorCode.CONTENT_POLICY_VIOLATION,
|
4985
|
-
ApiErrorCode.DUPLICATE_CONTENT
|
4986
|
-
],
|
4987
|
-
RATE_LIMIT: [
|
4988
|
-
ApiErrorCode.RATE_LIMITED
|
4989
|
-
],
|
4990
|
-
POST: [
|
4991
|
-
ApiErrorCode.POST_CREATION_FAILED,
|
4992
|
-
ApiErrorCode.THREAD_CREATION_FAILED,
|
4993
|
-
ApiErrorCode.POST_DELETION_FAILED,
|
4994
|
-
ApiErrorCode.POST_INTERACTION_FAILED
|
4995
|
-
],
|
4996
|
-
MEDIA: [
|
4997
|
-
ApiErrorCode.MEDIA_UPLOAD_FAILED
|
4998
|
-
]
|
4999
|
-
};
|
5000
|
-
function isErrorOfCategory(error, category) {
|
5001
|
-
if (error instanceof ApiError) {
|
5002
|
-
return category.includes(error.code);
|
4755
|
+
var CrosspostError = class extends Error {
|
4756
|
+
constructor(message, code, status, details, recoverable = false) {
|
4757
|
+
super(message);
|
4758
|
+
this.name = "CrosspostError";
|
4759
|
+
this.code = code;
|
4760
|
+
this.status = status;
|
4761
|
+
this.details = details;
|
4762
|
+
this.recoverable = recoverable;
|
5003
4763
|
}
|
5004
|
-
|
5005
|
-
|
4764
|
+
/**
|
4765
|
+
* Get platform from details if available
|
4766
|
+
*/
|
4767
|
+
get platform() {
|
4768
|
+
return this.details?.platform;
|
5006
4769
|
}
|
5007
|
-
|
5008
|
-
|
4770
|
+
/**
|
4771
|
+
* Get userId from details if available
|
4772
|
+
*/
|
4773
|
+
get userId() {
|
4774
|
+
return this.details?.userId;
|
5009
4775
|
}
|
5010
|
-
|
4776
|
+
};
|
4777
|
+
function isErrorCode(error, codes) {
|
4778
|
+
return error instanceof CrosspostError && codes.includes(error.code);
|
5011
4779
|
}
|
5012
4780
|
function isAuthError(error) {
|
5013
|
-
return
|
4781
|
+
return isErrorCode(error, [
|
4782
|
+
ApiErrorCode.UNAUTHORIZED,
|
4783
|
+
ApiErrorCode.FORBIDDEN
|
4784
|
+
]);
|
5014
4785
|
}
|
5015
4786
|
function isValidationError(error) {
|
5016
|
-
return
|
4787
|
+
return isErrorCode(error, [
|
4788
|
+
ApiErrorCode.VALIDATION_ERROR,
|
4789
|
+
ApiErrorCode.INVALID_REQUEST
|
4790
|
+
]);
|
5017
4791
|
}
|
5018
4792
|
function isNetworkError(error) {
|
5019
|
-
return
|
4793
|
+
return isErrorCode(error, [
|
4794
|
+
ApiErrorCode.NETWORK_ERROR,
|
4795
|
+
ApiErrorCode.PLATFORM_UNAVAILABLE
|
4796
|
+
]);
|
5020
4797
|
}
|
5021
4798
|
function isPlatformError(error) {
|
5022
|
-
return
|
4799
|
+
return error instanceof CrosspostError && !!error.details?.platform;
|
5023
4800
|
}
|
5024
4801
|
function isContentError(error) {
|
5025
|
-
return
|
4802
|
+
return isErrorCode(error, [
|
4803
|
+
ApiErrorCode.CONTENT_POLICY_VIOLATION,
|
4804
|
+
ApiErrorCode.DUPLICATE_CONTENT
|
4805
|
+
]);
|
5026
4806
|
}
|
5027
4807
|
function isRateLimitError(error) {
|
5028
|
-
return
|
4808
|
+
return isErrorCode(error, [ApiErrorCode.RATE_LIMITED]);
|
5029
4809
|
}
|
5030
4810
|
function isPostError(error) {
|
5031
|
-
return
|
4811
|
+
return isErrorCode(error, [
|
4812
|
+
ApiErrorCode.POST_CREATION_FAILED,
|
4813
|
+
ApiErrorCode.THREAD_CREATION_FAILED,
|
4814
|
+
ApiErrorCode.POST_DELETION_FAILED,
|
4815
|
+
ApiErrorCode.POST_INTERACTION_FAILED
|
4816
|
+
]);
|
5032
4817
|
}
|
5033
4818
|
function isMediaError(error) {
|
5034
|
-
return
|
4819
|
+
return isErrorCode(error, [ApiErrorCode.MEDIA_UPLOAD_FAILED]);
|
5035
4820
|
}
|
5036
4821
|
function isRecoverableError(error) {
|
5037
|
-
|
5038
|
-
return error.recoverable;
|
5039
|
-
}
|
5040
|
-
return false;
|
4822
|
+
return error instanceof CrosspostError && error.recoverable;
|
5041
4823
|
}
|
5042
4824
|
function getErrorMessage(error, defaultMessage = "An error occurred") {
|
5043
4825
|
if (error instanceof Error) {
|
5044
4826
|
return error.message || defaultMessage;
|
5045
4827
|
}
|
5046
|
-
if (typeof error === "string") {
|
5047
|
-
return error;
|
5048
|
-
}
|
5049
|
-
if (error && typeof error === "object" && "message" in error) {
|
5050
|
-
return error.message || defaultMessage;
|
5051
|
-
}
|
5052
4828
|
return defaultMessage;
|
5053
4829
|
}
|
5054
4830
|
function getErrorDetails(error) {
|
5055
|
-
if (error instanceof
|
5056
|
-
return error.details;
|
5057
|
-
}
|
5058
|
-
if (error && typeof error === "object" && "details" in error) {
|
4831
|
+
if (error instanceof CrosspostError) {
|
5059
4832
|
return error.details;
|
5060
4833
|
}
|
5061
4834
|
return void 0;
|
5062
4835
|
}
|
4836
|
+
function createError(message, code, status, details, recoverable = false) {
|
4837
|
+
return new CrosspostError(
|
4838
|
+
message,
|
4839
|
+
code,
|
4840
|
+
status,
|
4841
|
+
details,
|
4842
|
+
recoverable
|
4843
|
+
);
|
4844
|
+
}
|
5063
4845
|
function enrichErrorWithContext(error, context) {
|
5064
|
-
if (error instanceof
|
5065
|
-
return
|
4846
|
+
if (error instanceof CrosspostError) {
|
4847
|
+
return createError(
|
5066
4848
|
error.message,
|
5067
4849
|
error.code,
|
5068
4850
|
error.status,
|
@@ -5070,25 +4852,12 @@ function enrichErrorWithContext(error, context) {
|
|
5070
4852
|
error.recoverable
|
5071
4853
|
);
|
5072
4854
|
}
|
5073
|
-
if (error instanceof PlatformError) {
|
5074
|
-
return new PlatformError(
|
5075
|
-
error.message,
|
5076
|
-
error.platform,
|
5077
|
-
error.code,
|
5078
|
-
error.recoverable,
|
5079
|
-
error.originalError,
|
5080
|
-
error.status,
|
5081
|
-
error.userId,
|
5082
|
-
{ ...error.details || {}, ...context }
|
5083
|
-
);
|
5084
|
-
}
|
5085
4855
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
5086
|
-
return
|
4856
|
+
return createError(
|
5087
4857
|
errorMessage || "An error occurred",
|
5088
4858
|
ApiErrorCode.INTERNAL_ERROR,
|
5089
4859
|
500,
|
5090
|
-
{ originalError: error, ...context }
|
5091
|
-
false
|
4860
|
+
{ originalError: error, ...context }
|
5092
4861
|
);
|
5093
4862
|
}
|
5094
4863
|
async function apiWrapper(apiCall, context) {
|
@@ -5105,7 +4874,7 @@ async function apiWrapper(apiCall, context) {
|
|
5105
4874
|
} catch (jsonError) {
|
5106
4875
|
if (jsonError instanceof Error && jsonError.name === "SyntaxError") {
|
5107
4876
|
throw enrichErrorWithContext(
|
5108
|
-
|
4877
|
+
createError(
|
5109
4878
|
`API request failed with status ${error.status} and non-JSON response`,
|
5110
4879
|
ApiErrorCode.NETWORK_ERROR,
|
5111
4880
|
error.status,
|
@@ -5117,7 +4886,7 @@ async function apiWrapper(apiCall, context) {
|
|
5117
4886
|
throw jsonError;
|
5118
4887
|
}
|
5119
4888
|
}
|
5120
|
-
if (error instanceof
|
4889
|
+
if (error instanceof CrosspostError) {
|
5121
4890
|
throw enrichErrorWithContext(error, context || {});
|
5122
4891
|
}
|
5123
4892
|
throw enrichErrorWithContext(
|
@@ -5127,80 +4896,68 @@ async function apiWrapper(apiCall, context) {
|
|
5127
4896
|
}
|
5128
4897
|
}
|
5129
4898
|
function handleErrorResponse(data, status) {
|
5130
|
-
if (data
|
5131
|
-
|
5132
|
-
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5141
|
-
|
5142
|
-
|
5143
|
-
|
5144
|
-
|
5145
|
-
|
5146
|
-
|
5147
|
-
|
5148
|
-
|
5149
|
-
|
5150
|
-
|
5151
|
-
|
5152
|
-
}
|
5153
|
-
} else if (data.errors.length > 1) {
|
5154
|
-
return new CompositeApiError(
|
5155
|
-
"Multiple errors occurred",
|
5156
|
-
data.errors,
|
4899
|
+
if (!data || typeof data !== "object" || !("success" in data)) {
|
4900
|
+
return createError(
|
4901
|
+
"Invalid API response format",
|
4902
|
+
ApiErrorCode.INTERNAL_ERROR,
|
4903
|
+
status,
|
4904
|
+
{ originalResponse: data }
|
4905
|
+
);
|
4906
|
+
}
|
4907
|
+
if (!data.errors || !Array.isArray(data.errors) || data.errors.length === 0) {
|
4908
|
+
return createError(
|
4909
|
+
"Invalid error response format",
|
4910
|
+
ApiErrorCode.INTERNAL_ERROR,
|
4911
|
+
status,
|
4912
|
+
{ originalResponse: data }
|
4913
|
+
);
|
4914
|
+
}
|
4915
|
+
if (data.errors.length === 1) {
|
4916
|
+
const errorDetail = data.errors[0];
|
4917
|
+
if (!errorDetail.message || !errorDetail.code) {
|
4918
|
+
return createError(
|
4919
|
+
"Invalid error detail format",
|
4920
|
+
ApiErrorCode.INTERNAL_ERROR,
|
5157
4921
|
status,
|
5158
4922
|
{ originalResponse: data }
|
5159
4923
|
);
|
5160
4924
|
}
|
5161
|
-
|
5162
|
-
|
5163
|
-
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
const platform = errorData?.platform || data?.platform;
|
5169
|
-
const enhancedDetails = { ...details };
|
5170
|
-
if (typeof enhancedDetails === "object" && !enhancedDetails.originalResponse) {
|
5171
|
-
enhancedDetails.originalResponse = data;
|
5172
|
-
}
|
5173
|
-
if (platform && Object.values(Platform).includes(platform)) {
|
5174
|
-
return new PlatformError(
|
5175
|
-
message,
|
5176
|
-
platform,
|
5177
|
-
code,
|
5178
|
-
recoverable,
|
5179
|
-
void 0,
|
4925
|
+
const finalDetails = {
|
4926
|
+
...errorDetail.details || {},
|
4927
|
+
...data.meta || {}
|
4928
|
+
};
|
4929
|
+
return createError(
|
4930
|
+
errorDetail.message,
|
4931
|
+
errorDetail.code,
|
5180
4932
|
status,
|
5181
|
-
|
5182
|
-
|
4933
|
+
finalDetails,
|
4934
|
+
errorDetail.recoverable ?? false
|
5183
4935
|
);
|
5184
4936
|
} else {
|
5185
|
-
|
5186
|
-
|
5187
|
-
|
4937
|
+
const firstError = data.errors[0];
|
4938
|
+
return createError(
|
4939
|
+
"Multiple errors occurred",
|
4940
|
+
firstError.code,
|
5188
4941
|
status,
|
5189
|
-
|
5190
|
-
|
4942
|
+
{
|
4943
|
+
errors: data.errors,
|
4944
|
+
...data.meta || {},
|
4945
|
+
originalResponse: data
|
4946
|
+
},
|
4947
|
+
false
|
5191
4948
|
);
|
5192
4949
|
}
|
5193
4950
|
}
|
5194
4951
|
function createNetworkError(error, url, timeout) {
|
5195
4952
|
if (error instanceof DOMException && error.name === "AbortError") {
|
5196
|
-
return
|
4953
|
+
return createError(
|
5197
4954
|
`Request timed out after ${timeout}ms`,
|
5198
4955
|
ApiErrorCode.NETWORK_ERROR,
|
5199
4956
|
408,
|
5200
4957
|
{ url }
|
5201
4958
|
);
|
5202
4959
|
}
|
5203
|
-
return
|
4960
|
+
return createError(
|
5204
4961
|
error instanceof Error ? error.message : "An unexpected error occurred during the request",
|
5205
4962
|
ApiErrorCode.INTERNAL_ERROR,
|
5206
4963
|
500,
|
@@ -5211,7 +4968,7 @@ function createNetworkError(error, url, timeout) {
|
|
5211
4968
|
// src/core/request.ts
|
5212
4969
|
async function makeRequest(method, path, options, data, query) {
|
5213
4970
|
let url = `${options.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
|
5214
|
-
if (query && Object.keys(query).length > 0) {
|
4971
|
+
if (query && typeof query === "object" && Object.keys(query).length > 0) {
|
5215
4972
|
const queryParams = new URLSearchParams();
|
5216
4973
|
for (const [key, value] of Object.entries(query)) {
|
5217
4974
|
if (value !== void 0 && value !== null) {
|
@@ -5223,9 +4980,6 @@ async function makeRequest(method, path, options, data, query) {
|
|
5223
4980
|
url += `?${queryString}`;
|
5224
4981
|
}
|
5225
4982
|
}
|
5226
|
-
if (!options.nearAuthData) {
|
5227
|
-
throw ApiError.unauthorized("Authentication required. Please provide NEAR signature.");
|
5228
|
-
}
|
5229
4983
|
const context = {
|
5230
4984
|
method,
|
5231
4985
|
path,
|
@@ -5240,9 +4994,28 @@ async function makeRequest(method, path, options, data, query) {
|
|
5240
4994
|
try {
|
5241
4995
|
const headers = {
|
5242
4996
|
"Content-Type": "application/json",
|
5243
|
-
"Accept": "application/json"
|
5244
|
-
"Authorization": `Bearer ${(0, import_near_sign_verify.createAuthToken)(options.nearAuthData)}`
|
4997
|
+
"Accept": "application/json"
|
5245
4998
|
};
|
4999
|
+
if (method === "GET") {
|
5000
|
+
const nearAccount = options.nearAccount || options.nearAuthData?.account_id;
|
5001
|
+
if (!nearAccount) {
|
5002
|
+
throw new CrosspostError(
|
5003
|
+
"No NEAR account provided for GET request",
|
5004
|
+
ApiErrorCode.UNAUTHORIZED,
|
5005
|
+
401
|
5006
|
+
);
|
5007
|
+
}
|
5008
|
+
headers["X-Near-Account"] = nearAccount;
|
5009
|
+
} else {
|
5010
|
+
if (!options.nearAuthData) {
|
5011
|
+
throw new CrosspostError(
|
5012
|
+
"NEAR authentication data required for non-GET request",
|
5013
|
+
ApiErrorCode.UNAUTHORIZED,
|
5014
|
+
401
|
5015
|
+
);
|
5016
|
+
}
|
5017
|
+
headers["Authorization"] = `Bearer ${(0, import_near_sign_verify.createAuthToken)(options.nearAuthData)}`;
|
5018
|
+
}
|
5246
5019
|
const requestOptions = {
|
5247
5020
|
method,
|
5248
5021
|
headers,
|
@@ -5256,15 +5029,14 @@ async function makeRequest(method, path, options, data, query) {
|
|
5256
5029
|
responseData = await response.json();
|
5257
5030
|
} catch (jsonError) {
|
5258
5031
|
if (!response.ok) {
|
5259
|
-
throw new
|
5032
|
+
throw new CrosspostError(
|
5260
5033
|
`API request failed with status ${response.status} and non-JSON response`,
|
5261
5034
|
ApiErrorCode.NETWORK_ERROR,
|
5262
5035
|
response.status,
|
5263
5036
|
{ originalStatusText: response.statusText }
|
5264
5037
|
);
|
5265
5038
|
}
|
5266
|
-
|
5267
|
-
throw new ApiError(
|
5039
|
+
throw new CrosspostError(
|
5268
5040
|
`Failed to parse JSON response: ${jsonError instanceof Error ? jsonError.message : String(jsonError)}`,
|
5269
5041
|
ApiErrorCode.INTERNAL_ERROR,
|
5270
5042
|
response.status
|
@@ -5272,23 +5044,26 @@ async function makeRequest(method, path, options, data, query) {
|
|
5272
5044
|
}
|
5273
5045
|
if (!response.ok) {
|
5274
5046
|
lastError = handleErrorResponse(responseData, response.status);
|
5275
|
-
const shouldRetry =
|
5047
|
+
const shouldRetry = lastError instanceof CrosspostError && lastError.code === ApiErrorCode.RATE_LIMITED;
|
5276
5048
|
if (shouldRetry && attempt < options.retries) {
|
5277
5049
|
await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
|
5278
5050
|
continue;
|
5279
5051
|
}
|
5280
5052
|
throw lastError;
|
5281
5053
|
}
|
5282
|
-
if (responseData && typeof responseData === "object" && "success" in responseData
|
5283
|
-
|
5284
|
-
|
5285
|
-
|
5286
|
-
|
5287
|
-
|
5054
|
+
if (responseData && typeof responseData === "object" && "success" in responseData) {
|
5055
|
+
if (responseData.success) {
|
5056
|
+
return responseData.data;
|
5057
|
+
} else {
|
5058
|
+
lastError = handleErrorResponse(responseData, response.status);
|
5059
|
+
const shouldRetry = lastError instanceof CrosspostError && lastError.code === ApiErrorCode.RATE_LIMITED;
|
5060
|
+
if (shouldRetry && attempt < options.retries) {
|
5061
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
|
5062
|
+
continue;
|
5063
|
+
}
|
5064
|
+
throw lastError;
|
5288
5065
|
}
|
5289
|
-
throw lastError;
|
5290
5066
|
}
|
5291
|
-
return responseData;
|
5292
5067
|
} catch (error) {
|
5293
5068
|
clearTimeout(timeoutId);
|
5294
5069
|
lastError = error instanceof Error ? error : new Error(String(error));
|
@@ -5297,13 +5072,13 @@ async function makeRequest(method, path, options, data, query) {
|
|
5297
5072
|
await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
|
5298
5073
|
continue;
|
5299
5074
|
}
|
5300
|
-
if (!(error instanceof
|
5075
|
+
if (!(error instanceof CrosspostError)) {
|
5301
5076
|
throw createNetworkError(error, url, options.timeout);
|
5302
5077
|
}
|
5303
5078
|
throw error;
|
5304
5079
|
}
|
5305
5080
|
}
|
5306
|
-
throw lastError || new
|
5081
|
+
throw lastError || new CrosspostError("Request failed after multiple retries", ApiErrorCode.INTERNAL_ERROR, 500);
|
5307
5082
|
}, context);
|
5308
5083
|
}
|
5309
5084
|
|
@@ -5412,25 +5187,28 @@ var AuthApi = class {
|
|
5412
5187
|
/**
|
5413
5188
|
* Refreshes the authentication token for the specified platform.
|
5414
5189
|
* @param platform The target platform.
|
5415
|
-
* @returns A promise resolving with the refresh response.
|
5190
|
+
* @returns A promise resolving with the refresh response containing updated auth details.
|
5416
5191
|
*/
|
5417
|
-
async refreshToken(platform) {
|
5192
|
+
async refreshToken(platform, userId) {
|
5418
5193
|
return makeRequest(
|
5419
5194
|
"POST",
|
5420
5195
|
`/auth/${platform}/refresh`,
|
5421
|
-
this.options
|
5196
|
+
this.options,
|
5197
|
+
{ userId }
|
5422
5198
|
);
|
5423
5199
|
}
|
5424
5200
|
/**
|
5425
5201
|
* Refreshes the user's profile information from the specified platform.
|
5426
5202
|
* @param platform The target platform.
|
5427
|
-
* @
|
5203
|
+
* @param userId The user ID on the platform
|
5204
|
+
* @returns A promise resolving with the updated account profile information.
|
5428
5205
|
*/
|
5429
|
-
async refreshProfile(platform) {
|
5206
|
+
async refreshProfile(platform, userId) {
|
5430
5207
|
return makeRequest(
|
5431
5208
|
"POST",
|
5432
5209
|
`/auth/${platform}/refresh-profile`,
|
5433
|
-
this.options
|
5210
|
+
this.options,
|
5211
|
+
{ userId }
|
5434
5212
|
);
|
5435
5213
|
}
|
5436
5214
|
/**
|
@@ -5438,11 +5216,25 @@ var AuthApi = class {
|
|
5438
5216
|
* @param platform The target platform.
|
5439
5217
|
* @returns A promise resolving with the authentication status response.
|
5440
5218
|
*/
|
5441
|
-
async getAuthStatus(platform) {
|
5219
|
+
async getAuthStatus(platform, userId) {
|
5442
5220
|
return makeRequest(
|
5443
5221
|
"GET",
|
5444
|
-
`/auth/${platform}/status`,
|
5445
|
-
this.options
|
5222
|
+
`/auth/${platform}/status/${userId}`,
|
5223
|
+
this.options,
|
5224
|
+
void 0,
|
5225
|
+
{ platform, userId }
|
5226
|
+
);
|
5227
|
+
}
|
5228
|
+
/**
|
5229
|
+
* Unauthorizes a NEAR account from using the service
|
5230
|
+
* @returns A promise resolving with the unauthorized response
|
5231
|
+
*/
|
5232
|
+
async unauthorizeNear() {
|
5233
|
+
return makeRequest(
|
5234
|
+
"DELETE",
|
5235
|
+
"/auth/unauthorize/near",
|
5236
|
+
this.options,
|
5237
|
+
{}
|
5446
5238
|
);
|
5447
5239
|
}
|
5448
5240
|
/**
|
@@ -5450,11 +5242,12 @@ var AuthApi = class {
|
|
5450
5242
|
* @param platform The target platform.
|
5451
5243
|
* @returns A promise resolving with the revocation response.
|
5452
5244
|
*/
|
5453
|
-
async revokeAuth(platform) {
|
5245
|
+
async revokeAuth(platform, userId) {
|
5454
5246
|
return makeRequest(
|
5455
5247
|
"DELETE",
|
5456
5248
|
`/auth/${platform}/revoke`,
|
5457
|
-
this.options
|
5249
|
+
this.options,
|
5250
|
+
{ userId }
|
5458
5251
|
);
|
5459
5252
|
}
|
5460
5253
|
/**
|
@@ -5539,7 +5332,7 @@ var PostApi = class {
|
|
5539
5332
|
async likePost(request) {
|
5540
5333
|
return makeRequest(
|
5541
5334
|
"POST",
|
5542
|
-
`/api/post/like
|
5335
|
+
`/api/post/like`,
|
5543
5336
|
this.options,
|
5544
5337
|
request
|
5545
5338
|
);
|
@@ -5552,7 +5345,7 @@ var PostApi = class {
|
|
5552
5345
|
async unlikePost(request) {
|
5553
5346
|
return makeRequest(
|
5554
5347
|
"DELETE",
|
5555
|
-
`/api/post/like
|
5348
|
+
`/api/post/like`,
|
5556
5349
|
this.options,
|
5557
5350
|
request
|
5558
5351
|
);
|
@@ -5563,17 +5356,9 @@ var PostApi = class {
|
|
5563
5356
|
* @returns A promise resolving with the delete response.
|
5564
5357
|
*/
|
5565
5358
|
async deletePost(request) {
|
5566
|
-
const postId = request.posts[0]?.postId || "";
|
5567
|
-
if (!postId) {
|
5568
|
-
throw new ApiError(
|
5569
|
-
"Post ID is required for deletion path",
|
5570
|
-
ApiErrorCode.VALIDATION_ERROR,
|
5571
|
-
400
|
5572
|
-
);
|
5573
|
-
}
|
5574
5359
|
return makeRequest(
|
5575
5360
|
"DELETE",
|
5576
|
-
`/api/post
|
5361
|
+
`/api/post`,
|
5577
5362
|
this.options,
|
5578
5363
|
request
|
5579
5364
|
);
|
@@ -5609,7 +5394,9 @@ var SystemApi = class {
|
|
5609
5394
|
return makeRequest(
|
5610
5395
|
"GET",
|
5611
5396
|
`/api/rate-limit/${endpoint}`,
|
5612
|
-
this.options
|
5397
|
+
this.options,
|
5398
|
+
void 0,
|
5399
|
+
{ endpoint }
|
5613
5400
|
);
|
5614
5401
|
}
|
5615
5402
|
/**
|
@@ -5656,75 +5443,98 @@ var CrosspostClient = class {
|
|
5656
5443
|
}
|
5657
5444
|
/**
|
5658
5445
|
* Sets the authentication data (signature) for the client
|
5446
|
+
* Required for non-GET requests
|
5659
5447
|
* @param nearAuthData The NEAR authentication data
|
5660
5448
|
*/
|
5661
5449
|
setAuthentication(nearAuthData) {
|
5662
5450
|
this.options.nearAuthData = nearAuthData;
|
5451
|
+
if (!this.options.nearAccount) {
|
5452
|
+
this.options.nearAccount = nearAuthData.account_id;
|
5453
|
+
}
|
5454
|
+
}
|
5455
|
+
/**
|
5456
|
+
* Sets the NEAR account ID for simplified GET request authentication
|
5457
|
+
* If not set, will use account_id from nearAuthData
|
5458
|
+
* @param nearAccount The NEAR account ID
|
5459
|
+
*/
|
5460
|
+
setNearAccount(nearAccount) {
|
5461
|
+
this.options.nearAccount = nearAccount;
|
5462
|
+
}
|
5463
|
+
/**
|
5464
|
+
* Gets the current NEAR account ID being used for authentication
|
5465
|
+
* @returns The NEAR account ID from nearAccount or nearAuthData
|
5466
|
+
*/
|
5467
|
+
getNearAccount() {
|
5468
|
+
return this.options.nearAccount || this.options.nearAuthData?.account_id;
|
5663
5469
|
}
|
5664
5470
|
/**
|
5665
5471
|
* Checks if authentication data (signature) exists on client
|
5666
|
-
* @
|
5472
|
+
* @returns true if nearAuthData is set (required for non-GET requests)
|
5667
5473
|
*/
|
5668
5474
|
isAuthenticated() {
|
5669
5475
|
return !!this.options.nearAuthData;
|
5670
5476
|
}
|
5477
|
+
/**
|
5478
|
+
* Checks if a NEAR account is set for GET request authentication
|
5479
|
+
* @returns true if either nearAccount or nearAuthData.account_id is set
|
5480
|
+
*/
|
5481
|
+
hasNearAccount() {
|
5482
|
+
return !!(this.options.nearAccount || this.options.nearAuthData?.account_id);
|
5483
|
+
}
|
5484
|
+
/**
|
5485
|
+
* Clears all authentication data from the client
|
5486
|
+
* This will prevent all requests from working until new authentication is set
|
5487
|
+
*/
|
5488
|
+
clear() {
|
5489
|
+
this.options.nearAuthData = void 0;
|
5490
|
+
this.options.nearAccount = void 0;
|
5491
|
+
}
|
5671
5492
|
};
|
5672
5493
|
// Annotate the CommonJS export names for ESM import in node:
|
5673
5494
|
0 && (module.exports = {
|
5674
5495
|
AccountActivityEntrySchema,
|
5675
5496
|
AccountActivityParamsSchema,
|
5676
5497
|
AccountActivityQuerySchema,
|
5677
|
-
AccountActivityResponseSchema,
|
5678
5498
|
AccountPostSchema,
|
5679
5499
|
AccountPostsParamsSchema,
|
5680
5500
|
AccountPostsQuerySchema,
|
5681
|
-
AccountPostsResponseSchema,
|
5682
5501
|
ActivityApi,
|
5683
5502
|
ActivityLeaderboardQuerySchema,
|
5684
|
-
ActivityLeaderboardResponseSchema,
|
5685
5503
|
AllRateLimitsResponseSchema,
|
5686
|
-
ApiError,
|
5687
5504
|
ApiErrorCode,
|
5688
|
-
|
5505
|
+
ApiErrorCodeSchema,
|
5689
5506
|
AuthApi,
|
5690
5507
|
AuthCallbackQuerySchema,
|
5691
5508
|
AuthCallbackResponseSchema,
|
5692
5509
|
AuthInitRequestSchema,
|
5693
5510
|
AuthRevokeResponseSchema,
|
5511
|
+
AuthStatusParamsSchema,
|
5694
5512
|
AuthStatusResponseSchema,
|
5513
|
+
AuthTokenRequestSchema,
|
5695
5514
|
AuthUrlResponseSchema,
|
5696
|
-
BaseError,
|
5697
|
-
CompositeApiError,
|
5698
5515
|
ConnectedAccountSchema,
|
5699
5516
|
ConnectedAccountsResponseSchema,
|
5700
5517
|
CreatePostRequestSchema,
|
5701
|
-
CreatePostResponseLegacySchema,
|
5702
5518
|
CreatePostResponseSchema,
|
5703
|
-
CreatePostTargetErrorSchema,
|
5704
|
-
CreatePostTargetResultSchema,
|
5705
5519
|
CrosspostClient,
|
5706
5520
|
DeletePostRequestSchema,
|
5707
5521
|
DeletePostResponseSchema,
|
5708
5522
|
DeleteResultSchema,
|
5709
|
-
ERROR_CATEGORIES,
|
5710
5523
|
EndpointRateLimitResponseSchema,
|
5711
|
-
EnhancedErrorResponseSchema,
|
5712
|
-
EnhancedResponseMetaSchema,
|
5713
|
-
EnhancedResponseSchema,
|
5714
5524
|
ErrorDetailSchema,
|
5715
|
-
|
5525
|
+
HealthStatusSchema,
|
5716
5526
|
LikePostRequestSchema,
|
5717
5527
|
LikePostResponseSchema,
|
5718
5528
|
LikeResultSchema,
|
5719
5529
|
MediaContentSchema,
|
5720
5530
|
MediaSchema,
|
5721
|
-
|
5531
|
+
MultiStatusDataSchema,
|
5722
5532
|
NearAuthorizationRequestSchema,
|
5723
5533
|
NearAuthorizationResponseSchema,
|
5724
5534
|
NearAuthorizationStatusResponseSchema,
|
5535
|
+
NearUnauthorizationResponseSchema,
|
5725
5536
|
Platform,
|
5726
5537
|
PlatformActivitySchema,
|
5727
|
-
PlatformError,
|
5728
5538
|
PlatformParamSchema,
|
5729
5539
|
PlatformRateLimitSchema,
|
5730
5540
|
PlatformSchema,
|
@@ -5738,7 +5548,6 @@ var CrosspostClient = class {
|
|
5738
5548
|
PostSuccessDetailSchema,
|
5739
5549
|
PostToDeleteSchema,
|
5740
5550
|
ProfileRefreshResponseSchema,
|
5741
|
-
ProfileRefreshResultSchema,
|
5742
5551
|
QuotePostRequestSchema,
|
5743
5552
|
QuotePostResponseSchema,
|
5744
5553
|
RateLimitEndpointParamSchema,
|
@@ -5750,6 +5559,7 @@ var CrosspostClient = class {
|
|
5750
5559
|
ReplyToPostResponseSchema,
|
5751
5560
|
RepostRequestSchema,
|
5752
5561
|
RepostResponseSchema,
|
5562
|
+
ResponseMetaSchema,
|
5753
5563
|
SUPPORTED_PLATFORMS,
|
5754
5564
|
SuccessDetailSchema,
|
5755
5565
|
SupportedPlatformSchema,
|
@@ -5761,21 +5571,14 @@ var CrosspostClient = class {
|
|
5761
5571
|
UsageRateLimitSchema,
|
5762
5572
|
UserProfileSchema,
|
5763
5573
|
apiWrapper,
|
5764
|
-
createApiResponse,
|
5765
|
-
createEnhancedApiResponse,
|
5766
|
-
createEnhancedErrorResponse,
|
5767
|
-
createErrorDetail,
|
5768
|
-
createErrorResponse,
|
5769
|
-
createMultiStatusResponse,
|
5770
5574
|
createNetworkError,
|
5771
|
-
createSuccessDetail,
|
5772
5575
|
enrichErrorWithContext,
|
5576
|
+
errorCodeToStatusCode,
|
5773
5577
|
getErrorDetails,
|
5774
5578
|
getErrorMessage,
|
5775
5579
|
handleErrorResponse,
|
5776
5580
|
isAuthError,
|
5777
5581
|
isContentError,
|
5778
|
-
isErrorOfCategory,
|
5779
5582
|
isMediaError,
|
5780
5583
|
isNetworkError,
|
5781
5584
|
isPlatformError,
|