@codybrom/denim 1.3.3 → 1.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codybrom/denim",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Typescript/Deno module to simplify posting to Threads",
5
5
  "main": "mod.ts",
6
6
  "directories": {
package/types.ts ADDED
@@ -0,0 +1,235 @@
1
+ // types.ts
2
+
3
+ /**
4
+ * Represents the types of media that can be posted on Threads.
5
+ */
6
+ export type MediaType = "TEXT" | "IMAGE" | "VIDEO" | "CAROUSEL";
7
+
8
+ /**
9
+ * Represents the options for controlling who can reply to a post.
10
+ */
11
+ export type ReplyControl =
12
+ | "everyone"
13
+ | "accounts_you_follow"
14
+ | "mentioned_only";
15
+
16
+ /**
17
+ * Represents a request to post content on Threads.
18
+ */
19
+ export interface ThreadsPostRequest {
20
+ /** The user ID of the Threads account */
21
+ userId: string;
22
+ /** The access token for authentication */
23
+ accessToken: string;
24
+ /** The type of media being posted */
25
+ mediaType: MediaType;
26
+ /** The text content of the post (optional) */
27
+ text?: string;
28
+ /** The URL of the image to be posted (optional, for IMAGE type) */
29
+ imageUrl?: string;
30
+ /** The URL of the video to be posted (optional, for VIDEO type) */
31
+ videoUrl?: string;
32
+ /** The accessibility text for the image or video (optional) */
33
+ altText?: string;
34
+ /** The URL to be attached as a link to the post (optional, for text posts only) */
35
+ linkAttachment?: string;
36
+ /** List of country codes where the post should be visible (optional - requires special API access) */
37
+ allowlistedCountryCodes?: string[];
38
+ /** Controls who can reply to the post (optional) */
39
+ replyControl?: ReplyControl;
40
+ /** Array of carousel item IDs (required for CAROUSEL type, not applicable for other types) */
41
+ children?: string[];
42
+ /** Whether to return the permalink of the post (optional, default: false) */
43
+ getPermalink?: boolean;
44
+ }
45
+
46
+ /**
47
+ * Represents a single Threads media object.
48
+ */
49
+ export interface ThreadsPost {
50
+ /** Unique identifier for the media object */
51
+ id: string;
52
+ /** Type of product where the media is published (e.g., "THREADS") */
53
+ media_product_type: string;
54
+ /** Type of media (e.g., "TEXT", "IMAGE", "VIDEO", "CAROUSEL") */
55
+ media_type: MediaType;
56
+ /** URL of the media content (if applicable) */
57
+ media_url?: string;
58
+ /** Permanent link to the post */
59
+ permalink?: string;
60
+ /** Information about the owner of the post */
61
+ owner: { id: string };
62
+ /** Username of the account that created the post */
63
+ username: string;
64
+ /** Text content of the post */
65
+ text?: string;
66
+ /** Timestamp of when the post was created (ISO 8601 format) */
67
+ timestamp: string;
68
+ /** Short code identifier for the media */
69
+ shortcode: string;
70
+ /** URL of the thumbnail image (for video posts) */
71
+ thumbnail_url?: string;
72
+ /** List of child posts (for carousel posts) */
73
+ children?: ThreadsPost[];
74
+ /** Indicates if the post is a quote of another post */
75
+ is_quote_post: boolean;
76
+ /** Accessibility text for the image or video */
77
+ altText?: string;
78
+ /** URL of the attached link */
79
+ linkAttachmentUrl?: string;
80
+ /** Indicates if the post has replies */
81
+ hasReplies: boolean;
82
+ /** Indicates if the post is a reply to another post */
83
+ isReply: boolean;
84
+ /** Indicates if the reply is owned by the current user */
85
+ isReplyOwnedByMe: boolean;
86
+ /** Information about the root post (for replies) */
87
+ rootPost?: { id: string };
88
+ /** Information about the post being replied to */
89
+ repliedTo?: { id: string };
90
+ /** Visibility status of the post */
91
+ hideStatus?: "VISIBLE" | "HIDDEN";
92
+ /** Controls who can reply to the post */
93
+ replyAudience?: ReplyControl;
94
+ }
95
+
96
+ /**
97
+ * Represents the response structure when retrieving a list of Threads.
98
+ */
99
+ export interface ThreadsListResponse {
100
+ /** Array of ThreadsPost representing the retrieved posts */
101
+ data: ThreadsPost[];
102
+ /** Pagination information */
103
+ paging?: {
104
+ /** Cursors for navigating through pages of results */
105
+ cursors: {
106
+ /** Cursor for the previous page */
107
+ before: string;
108
+ /** Cursor for the next page */
109
+ after: string;
110
+ };
111
+ };
112
+ }
113
+
114
+ /**
115
+ * Represents the publishing limit information for a user.
116
+ */
117
+ export interface PublishingLimit {
118
+ /** Current usage count towards the quota */
119
+ quota_usage: number;
120
+ /** Configuration for the publishing limit */
121
+ config: {
122
+ /** Total allowed quota */
123
+ quota_total: number;
124
+ /** Duration of the quota period in seconds */
125
+ quota_duration: number;
126
+ };
127
+ }
128
+
129
+ /**
130
+ * Represents a Threads media container.
131
+ */
132
+ export interface ThreadsContainer {
133
+ /** Unique identifier for the container */
134
+ id: string;
135
+ /** Permanent link to the container */
136
+ permalink: string;
137
+ /** Status of the container */
138
+ status: "FINISHED" | "FAILED";
139
+ /** Error message if the container failed */
140
+ errorMessage?: string;
141
+ }
142
+
143
+ /**
144
+ * Represents a Threads user profile.
145
+ */
146
+ export interface ThreadsProfile {
147
+ /** Unique identifier for the user */
148
+ id: string;
149
+ /** Username of the account */
150
+ username: string;
151
+ /** Display name of the user */
152
+ name: string;
153
+ /** URL of the user's profile picture */
154
+ threadsProfilePictureUrl: string;
155
+ /** Biography text of the user */
156
+ threadsBiography: string;
157
+ }
158
+
159
+ /**
160
+ * Represents the mock API for Threads operations.
161
+ */
162
+ export interface MockThreadsAPI {
163
+ /**
164
+ * Creates a Threads media container.
165
+ * @param request The request object containing post details
166
+ * @returns A promise that resolves to either a string ID or an object with ID and permalink
167
+ */
168
+ createThreadsContainer(
169
+ request: ThreadsPostRequest
170
+ ): Promise<string | { id: string; permalink: string }>;
171
+
172
+ /**
173
+ * Publishes a Threads media container.
174
+ * @param userId The user ID
175
+ * @param accessToken The access token
176
+ * @param containerId The ID of the container to publish
177
+ * @param getPermalink Whether to return the permalink
178
+ * @returns A promise that resolves to either a string ID or an object with ID and permalink
179
+ */
180
+ publishThreadsContainer(
181
+ userId: string,
182
+ accessToken: string,
183
+ containerId: string,
184
+ getPermalink?: boolean
185
+ ): Promise<string | { id: string; permalink: string }>;
186
+
187
+ /**
188
+ * Creates a carousel item for a Threads post.
189
+ * @param request The request object containing carousel item details
190
+ * @returns A promise that resolves to either a string ID or an object with ID
191
+ */
192
+ createCarouselItem(
193
+ request: Omit<ThreadsPostRequest, "mediaType"> & {
194
+ mediaType: "IMAGE" | "VIDEO";
195
+ }
196
+ ): Promise<string | { id: string }>;
197
+
198
+ /**
199
+ * Retrieves the publishing limit for a user.
200
+ * @param userId The user ID
201
+ * @param accessToken The access token
202
+ * @returns A promise that resolves to the publishing limit information
203
+ */
204
+ getPublishingLimit(
205
+ userId: string,
206
+ accessToken: string
207
+ ): Promise<PublishingLimit>;
208
+
209
+ /**
210
+ * Retrieves a list of Threads posts for a user.
211
+ * @param userId The user ID
212
+ * @param accessToken The access token
213
+ * @param options Optional parameters for pagination and date range
214
+ * @returns A promise that resolves to the Threads list response
215
+ */
216
+ getThreadsList(
217
+ userId: string,
218
+ accessToken: string,
219
+ options?: {
220
+ since?: string;
221
+ until?: string;
222
+ limit?: number;
223
+ after?: string;
224
+ before?: string;
225
+ }
226
+ ): Promise<ThreadsListResponse>;
227
+
228
+ /**
229
+ * Retrieves a single Thread post.
230
+ * @param mediaId The ID of the media to retrieve
231
+ * @param accessToken The access token
232
+ * @returns A promise that resolves to the Thread post
233
+ */
234
+ getSingleThread(mediaId: string, accessToken: string): Promise<ThreadsPost>;
235
+ }