@crosspost/types 0.1.2

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 ADDED
@@ -0,0 +1,125 @@
1
+ # @crosspost/types
2
+
3
+ Shared type definitions for the Crosspost API ecosystem.
4
+
5
+ ## Overview
6
+
7
+ This package contains TypeScript type definitions used across the Crosspost API ecosystem,
8
+ including:
9
+
10
+ - Common types (PlatformName, ApiErrorCode, etc.)
11
+ - Request types for all API endpoints
12
+ - Response types for all API endpoints
13
+
14
+ ## Installation
15
+
16
+ ### Node.js / npm
17
+
18
+ ```bash
19
+ # Using npm
20
+ npm install @crosspost/types
21
+
22
+ # Using yarn
23
+ yarn add @crosspost/types
24
+
25
+ # Using pnpm
26
+ pnpm add @crosspost/types
27
+
28
+ # Using bun
29
+ bun add @crosspost/types
30
+ ```
31
+
32
+ ### Deno
33
+
34
+ ```typescript
35
+ // Import from JSR
36
+ import { PlatformName } from '@crosspost/types';
37
+
38
+ // Or import directly from GitHub
39
+ import { PlatformName } from 'https://raw.githubusercontent.com/your-org/crosspost/main/packages/types/mod.ts';
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ```typescript
45
+ import { CreatePostRequest, CreatePostResponse, PlatformName } from '@crosspost/types';
46
+
47
+ // Use the types in your code
48
+ const platform: PlatformName = 'twitter';
49
+
50
+ const request: CreatePostRequest = {
51
+ content: {
52
+ text: 'Hello, world!',
53
+ },
54
+ };
55
+
56
+ // Type checking for responses
57
+ function handleResponse(response: CreatePostResponse) {
58
+ console.log(`Post created with ID: ${response.id}`);
59
+ }
60
+ ```
61
+
62
+ ## Available Types
63
+
64
+ ### Common Types
65
+
66
+ - `PlatformName` - Supported social media platforms
67
+ - `ApiErrorCode` - Error codes returned by the API
68
+ - `ApiError` - Error structure returned by the API
69
+
70
+ ### Enhanced Response Types
71
+
72
+ - `EnhancedApiResponse<T>` - Standard response format with metadata
73
+ - `EnhancedErrorResponse` - Error response format
74
+ - `ErrorDetail` - Detailed error information
75
+ - `SuccessDetail` - Success information for multi-status responses
76
+ - `MultiStatusResponse` - Response format for operations with partial success/failure
77
+
78
+ #### Helper Functions
79
+
80
+ - `createEnhancedApiResponse` - Create a standard response
81
+ - `createEnhancedErrorResponse` - Create an error response
82
+ - `createErrorDetail` - Create detailed error information
83
+ - `createSuccessDetail` - Create success information
84
+ - `createMultiStatusResponse` - Create a multi-status response
85
+
86
+ Example usage:
87
+
88
+ ```typescript
89
+ import { ApiErrorCode, createEnhancedApiResponse, createErrorDetail } from '@crosspost/types';
90
+
91
+ // Success response
92
+ const response = createEnhancedApiResponse({
93
+ id: '123',
94
+ text: 'Hello, world!',
95
+ });
96
+
97
+ // Error response
98
+ const errorResponse = createEnhancedErrorResponse([
99
+ createErrorDetail(
100
+ 'Post not found',
101
+ ApiErrorCode.NOT_FOUND,
102
+ 'twitter',
103
+ 'user123',
104
+ false,
105
+ ),
106
+ ]);
107
+ ```
108
+
109
+ ### Request Types
110
+
111
+ - Authentication requests
112
+ - Post creation and management requests
113
+ - Media upload requests
114
+ - Rate limit requests
115
+
116
+ ### Response Types
117
+
118
+ - Authentication responses
119
+ - Post creation and management responses
120
+ - Media upload responses
121
+ - Rate limit responses
122
+
123
+ ## License
124
+
125
+ MIT