@crosspost/types 0.3.0 → 0.3.1
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/README.md +0 -94
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -1
- package/package.json +1 -1
- package/src/auth.ts +1 -0
package/README.md
CHANGED
|
@@ -1,97 +1,3 @@
|
|
|
1
1
|
# @crosspost/types
|
|
2
2
|
|
|
3
3
|
Shared type definitions for the Crosspost API and SDK.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
This package contains TypeScript type definitions, including:
|
|
8
|
-
|
|
9
|
-
- Common types (PlatformName, ApiErrorCode, etc.)
|
|
10
|
-
- Request types for all API endpoints
|
|
11
|
-
- Response types for all API endpoints
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
### Node.js
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install @crosspost/types
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Deno
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
// Import from JSR
|
|
25
|
-
import { PlatformName } from '@crosspost/types';
|
|
26
|
-
|
|
27
|
-
// Or import directly from GitHub
|
|
28
|
-
import { PlatformName } from 'https://raw.githubusercontent.com/your-org/crosspost/main/packages/types/mod.ts';
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { CreatePostRequest, CreatePostResponse, PlatformName } from '@crosspost/types';
|
|
35
|
-
|
|
36
|
-
// Use the types in your code
|
|
37
|
-
const platform: PlatformName = 'twitter';
|
|
38
|
-
|
|
39
|
-
const request: CreatePostRequest = {
|
|
40
|
-
targets: [{ platform: 'twitter', userId: 'your-twitter-id' }],
|
|
41
|
-
content: {
|
|
42
|
-
text: 'Hello, world!',
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// Type checking for responses
|
|
47
|
-
function handleResponse(response: CreatePostResponse) {
|
|
48
|
-
console.log(`Post created with ID: ${response.id}`);
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Available Types
|
|
53
|
-
|
|
54
|
-
### Common Types
|
|
55
|
-
|
|
56
|
-
- `PlatformName` - Supported social media platforms
|
|
57
|
-
- `ApiErrorCode` - Error codes returned by the API
|
|
58
|
-
- `ApiError` - Error structure returned by the API
|
|
59
|
-
|
|
60
|
-
### Enhanced Response Types
|
|
61
|
-
|
|
62
|
-
- `EnhancedApiResponse<T>` - Standard response format with metadata
|
|
63
|
-
- `EnhancedErrorResponse` - Error response format
|
|
64
|
-
- `ErrorDetail` - Detailed error information
|
|
65
|
-
- `SuccessDetail` - Success information for multi-status responses
|
|
66
|
-
- `MultiStatusResponse` - Response format for operations with partial success/failure
|
|
67
|
-
|
|
68
|
-
#### Helper Functions
|
|
69
|
-
|
|
70
|
-
- `createEnhancedApiResponse` - Create a standard response
|
|
71
|
-
- `createEnhancedErrorResponse` - Create an error response
|
|
72
|
-
- `createErrorDetail` - Create detailed error information
|
|
73
|
-
- `createSuccessDetail` - Create success information
|
|
74
|
-
- `createMultiStatusResponse` - Create a multi-status response
|
|
75
|
-
|
|
76
|
-
Example usage:
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
import { ApiErrorCode, createEnhancedApiResponse, createErrorDetail } from '@crosspost/types';
|
|
80
|
-
|
|
81
|
-
// Success response
|
|
82
|
-
const response = createEnhancedApiResponse({
|
|
83
|
-
id: '123',
|
|
84
|
-
text: 'Hello, world!',
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Error response
|
|
88
|
-
const errorResponse = createEnhancedErrorResponse([
|
|
89
|
-
createErrorDetail(
|
|
90
|
-
'Post not found',
|
|
91
|
-
ApiErrorCode.NOT_FOUND,
|
|
92
|
-
'twitter',
|
|
93
|
-
'user123',
|
|
94
|
-
false,
|
|
95
|
-
),
|
|
96
|
-
]);
|
|
97
|
-
```
|
package/dist/index.cjs
CHANGED
|
@@ -303,7 +303,8 @@ var ConnectedAccountSchema = import_zod5.z.object({
|
|
|
303
303
|
platform: PlatformSchema,
|
|
304
304
|
userId: import_zod5.z.string().describe("User ID on the platform"),
|
|
305
305
|
connectedAt: import_zod5.z.string().describe("When the account was connected"),
|
|
306
|
-
profile: UserProfileSchema.nullable().describe("Full user profile data")
|
|
306
|
+
profile: UserProfileSchema.nullable().describe("Full user profile data"),
|
|
307
|
+
error: import_zod5.z.string().optional().describe("Error message if fetching profile failed")
|
|
307
308
|
}).describe("Connected account");
|
|
308
309
|
var ConnectedAccountsResponseSchema = import_zod5.z.object({
|
|
309
310
|
accounts: import_zod5.z.array(ConnectedAccountSchema)
|
package/dist/index.d.cts
CHANGED
|
@@ -598,6 +598,7 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
|
598
598
|
url?: string | undefined;
|
|
599
599
|
isPremium?: boolean | undefined;
|
|
600
600
|
}>>;
|
|
601
|
+
error: z.ZodOptional<z.ZodString>;
|
|
601
602
|
}, "strip", z.ZodTypeAny, {
|
|
602
603
|
platform: Platform;
|
|
603
604
|
userId: string;
|
|
@@ -611,6 +612,7 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
|
611
612
|
isPremium?: boolean | undefined;
|
|
612
613
|
} | null;
|
|
613
614
|
connectedAt: string;
|
|
615
|
+
error?: string | undefined;
|
|
614
616
|
}, {
|
|
615
617
|
platform: Platform;
|
|
616
618
|
userId: string;
|
|
@@ -624,6 +626,7 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
|
624
626
|
isPremium?: boolean | undefined;
|
|
625
627
|
} | null;
|
|
626
628
|
connectedAt: string;
|
|
629
|
+
error?: string | undefined;
|
|
627
630
|
}>;
|
|
628
631
|
declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
629
632
|
accounts: z.ZodArray<z.ZodObject<{
|
|
@@ -655,6 +658,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
655
658
|
url?: string | undefined;
|
|
656
659
|
isPremium?: boolean | undefined;
|
|
657
660
|
}>>;
|
|
661
|
+
error: z.ZodOptional<z.ZodString>;
|
|
658
662
|
}, "strip", z.ZodTypeAny, {
|
|
659
663
|
platform: Platform;
|
|
660
664
|
userId: string;
|
|
@@ -668,6 +672,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
668
672
|
isPremium?: boolean | undefined;
|
|
669
673
|
} | null;
|
|
670
674
|
connectedAt: string;
|
|
675
|
+
error?: string | undefined;
|
|
671
676
|
}, {
|
|
672
677
|
platform: Platform;
|
|
673
678
|
userId: string;
|
|
@@ -681,6 +686,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
681
686
|
isPremium?: boolean | undefined;
|
|
682
687
|
} | null;
|
|
683
688
|
connectedAt: string;
|
|
689
|
+
error?: string | undefined;
|
|
684
690
|
}>, "many">;
|
|
685
691
|
}, "strip", z.ZodTypeAny, {
|
|
686
692
|
accounts: {
|
|
@@ -696,6 +702,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
696
702
|
isPremium?: boolean | undefined;
|
|
697
703
|
} | null;
|
|
698
704
|
connectedAt: string;
|
|
705
|
+
error?: string | undefined;
|
|
699
706
|
}[];
|
|
700
707
|
}, {
|
|
701
708
|
accounts: {
|
|
@@ -711,6 +718,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
711
718
|
isPremium?: boolean | undefined;
|
|
712
719
|
} | null;
|
|
713
720
|
connectedAt: string;
|
|
721
|
+
error?: string | undefined;
|
|
714
722
|
}[];
|
|
715
723
|
}>;
|
|
716
724
|
declare const NearAuthorizationRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -598,6 +598,7 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
|
598
598
|
url?: string | undefined;
|
|
599
599
|
isPremium?: boolean | undefined;
|
|
600
600
|
}>>;
|
|
601
|
+
error: z.ZodOptional<z.ZodString>;
|
|
601
602
|
}, "strip", z.ZodTypeAny, {
|
|
602
603
|
platform: Platform;
|
|
603
604
|
userId: string;
|
|
@@ -611,6 +612,7 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
|
611
612
|
isPremium?: boolean | undefined;
|
|
612
613
|
} | null;
|
|
613
614
|
connectedAt: string;
|
|
615
|
+
error?: string | undefined;
|
|
614
616
|
}, {
|
|
615
617
|
platform: Platform;
|
|
616
618
|
userId: string;
|
|
@@ -624,6 +626,7 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
|
624
626
|
isPremium?: boolean | undefined;
|
|
625
627
|
} | null;
|
|
626
628
|
connectedAt: string;
|
|
629
|
+
error?: string | undefined;
|
|
627
630
|
}>;
|
|
628
631
|
declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
629
632
|
accounts: z.ZodArray<z.ZodObject<{
|
|
@@ -655,6 +658,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
655
658
|
url?: string | undefined;
|
|
656
659
|
isPremium?: boolean | undefined;
|
|
657
660
|
}>>;
|
|
661
|
+
error: z.ZodOptional<z.ZodString>;
|
|
658
662
|
}, "strip", z.ZodTypeAny, {
|
|
659
663
|
platform: Platform;
|
|
660
664
|
userId: string;
|
|
@@ -668,6 +672,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
668
672
|
isPremium?: boolean | undefined;
|
|
669
673
|
} | null;
|
|
670
674
|
connectedAt: string;
|
|
675
|
+
error?: string | undefined;
|
|
671
676
|
}, {
|
|
672
677
|
platform: Platform;
|
|
673
678
|
userId: string;
|
|
@@ -681,6 +686,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
681
686
|
isPremium?: boolean | undefined;
|
|
682
687
|
} | null;
|
|
683
688
|
connectedAt: string;
|
|
689
|
+
error?: string | undefined;
|
|
684
690
|
}>, "many">;
|
|
685
691
|
}, "strip", z.ZodTypeAny, {
|
|
686
692
|
accounts: {
|
|
@@ -696,6 +702,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
696
702
|
isPremium?: boolean | undefined;
|
|
697
703
|
} | null;
|
|
698
704
|
connectedAt: string;
|
|
705
|
+
error?: string | undefined;
|
|
699
706
|
}[];
|
|
700
707
|
}, {
|
|
701
708
|
accounts: {
|
|
@@ -711,6 +718,7 @@ declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
|
|
711
718
|
isPremium?: boolean | undefined;
|
|
712
719
|
} | null;
|
|
713
720
|
connectedAt: string;
|
|
721
|
+
error?: string | undefined;
|
|
714
722
|
}[];
|
|
715
723
|
}>;
|
|
716
724
|
declare const NearAuthorizationRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
package/dist/index.js
CHANGED
|
@@ -198,7 +198,8 @@ var ConnectedAccountSchema = z5.object({
|
|
|
198
198
|
platform: PlatformSchema,
|
|
199
199
|
userId: z5.string().describe("User ID on the platform"),
|
|
200
200
|
connectedAt: z5.string().describe("When the account was connected"),
|
|
201
|
-
profile: UserProfileSchema.nullable().describe("Full user profile data")
|
|
201
|
+
profile: UserProfileSchema.nullable().describe("Full user profile data"),
|
|
202
|
+
error: z5.string().optional().describe("Error message if fetching profile failed")
|
|
202
203
|
}).describe("Connected account");
|
|
203
204
|
var ConnectedAccountsResponseSchema = z5.object({
|
|
204
205
|
accounts: z5.array(ConnectedAccountSchema)
|
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -73,6 +73,7 @@ export const ConnectedAccountSchema = z.object({
|
|
|
73
73
|
userId: z.string().describe('User ID on the platform'),
|
|
74
74
|
connectedAt: z.string().describe('When the account was connected'),
|
|
75
75
|
profile: UserProfileSchema.nullable().describe('Full user profile data'),
|
|
76
|
+
error: z.string().optional().describe('Error message if fetching profile failed'),
|
|
76
77
|
}).describe('Connected account');
|
|
77
78
|
|
|
78
79
|
export const ConnectedAccountsResponseSchema = z.object({
|