ugcinc 4.3.2 → 4.4.0

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/base.d.ts CHANGED
@@ -16,5 +16,6 @@ export declare class BaseClient {
16
16
  protected request<T>(endpoint: string, options?: RequestInit): Promise<ApiResponse<T>>;
17
17
  protected post<T>(endpoint: string, body?: unknown): Promise<ApiResponse<T>>;
18
18
  protected get<T>(endpoint: string): Promise<ApiResponse<T>>;
19
+ protected rawPost(endpoint: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<Response>;
19
20
  protected postFormData<T>(endpoint: string, formData: FormData): Promise<ApiResponse<T>>;
20
21
  }
package/dist/base.js CHANGED
@@ -73,6 +73,25 @@ class BaseClient {
73
73
  method: 'GET',
74
74
  });
75
75
  }
76
+ async rawPost(endpoint, body, extraHeaders) {
77
+ let url = `${this.baseUrl}${endpoint}`;
78
+ if (this.orgId) {
79
+ const separator = endpoint.includes('?') ? '&' : '?';
80
+ url = `${url}${separator}orgId=${encodeURIComponent(this.orgId)}`;
81
+ }
82
+ const headers = {
83
+ 'Content-Type': 'application/json',
84
+ ...(this.admin
85
+ ? { 'x-api-key': this.apiKey }
86
+ : { 'Authorization': `Bearer ${this.apiKey}` }),
87
+ ...extraHeaders,
88
+ };
89
+ return fetch(url, {
90
+ method: 'POST',
91
+ headers,
92
+ body: body ? JSON.stringify(body) : undefined,
93
+ });
94
+ }
76
95
  async postFormData(endpoint, formData) {
77
96
  let url = `${this.baseUrl}${endpoint}`;
78
97
  // If orgId is provided, add it as query param to scope to that org
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export type { ClientConfig } from './base';
28
28
  export type { Account, AccountStat, AccountTask, EditProfileInfo, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, AccountInfoUpdate, UpdateAccountInfoParams, AccountInfoUpdateResult, UpdateAccountInfoResponse, AccountSocialUpdate, UpdateAccountSocialParams, AccountSocialUpdateResult, UpdateAccountSocialResponse, DeleteAccountPostsParams, DeleteAccountPostsResponse, ResetWarmupParams, ResetWarmupResponse, NicheSwitchUpdate, NicheSwitchParams, NicheSwitchResult, NicheSwitchResponse, CreateAccountInput, CreateAccountsParams, CreateAccountResult, CreateAccountsResponse, TroubleshootFailReason, TroubleshootAccount, TroubleshootParams, } from './accounts';
29
29
  export type { TaskType, Task, GetTasksParams } from './tasks';
30
30
  export type { PostType, PostStatus, Post, PostStat, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, UpdatePostParams, DeletePostsParams, DeletePostsResponse, RetryPostsParams, SetPostStatusParams, SetPostStatusResponse, } from './posts';
31
- export type { RefreshStatsParams, RefreshStatsError, RefreshStatsResponse, DailyAggregatedStat, GetDailyAggregatedStatsParams, DailyAccountStat, GetDailyAccountStatsParams, DailyPostStat, GetDailyPostStatsParams, DashboardDailyStat, GetDashboardDailyStatsParams, TopAccount, GetTopAccountsParams, TopPost, GetTopPostsParams, } from './stats';
31
+ export type { RefreshStatsParams, RefreshStatsError, RefreshStatsResponse, RefreshStartEvent, RefreshProgressEvent, RefreshDoneEvent, RefreshStreamEvent, DailyAggregatedStat, GetDailyAggregatedStatsParams, DailyAccountStat, GetDailyAccountStatsParams, DailyPostStat, GetDailyPostStatsParams, DashboardDailyStat, GetDashboardDailyStatsParams, TopAccount, GetTopAccountsParams, TopPost, GetTopPostsParams, } from './stats';
32
32
  export type { Org, ApiKey, DeleteApiKeyParams, EditApiKeyParams, IntegrationKey, IntegrationProvider, UpsertIntegrationKeyParams, DeleteIntegrationKeyParams } from './org';
33
33
  export type { UserMedia, MediaUse, SocialAudio, Media, GetMediaParams, GetSocialAudioParams, UploadMediaParams, UploadMediaResponse, MediaTagUpdate, UpdateMediaTagsParams, MediaTagUpdateResult, UpdateMediaTagsResponse, UpdateMediaTagParams, UpdateMediaNameParams, DeleteMediaParams, DeleteMediaResponse, CreateSocialAudioParams, ImportTextParams, ImportTextResponse, CreateMediaFromUrlParams, GetMediaUseParams, GetMediaUseResponse, FilterMediaParams, FilterMediaResponse, GetUploadTokenParams, UploadTokenResponse, } from './media';
34
34
  export type { CommentStatus, Comment, CreateCommentParams, CreateCommentResponse, GetCommentsParams, } from './comments';
package/dist/stats.d.ts CHANGED
@@ -147,6 +147,28 @@ export interface GetTopPostsParams {
147
147
  limit?: number;
148
148
  postIds?: string[];
149
149
  }
150
+ export interface RefreshStartEvent {
151
+ type: 'start';
152
+ totalAccounts: number;
153
+ totalPosts: number;
154
+ }
155
+ export interface RefreshProgressEvent {
156
+ type: 'progress';
157
+ completedAccounts: number;
158
+ completedPosts: number;
159
+ totalAccounts: number;
160
+ totalPosts: number;
161
+ }
162
+ export interface RefreshDoneEvent {
163
+ type: 'done';
164
+ accounts_refreshed?: number;
165
+ accounts_failed?: number;
166
+ total_accounts?: number;
167
+ post_stats_count?: number;
168
+ errors?: RefreshStatsError[];
169
+ error?: string;
170
+ }
171
+ export type RefreshStreamEvent = RefreshStartEvent | RefreshProgressEvent | RefreshDoneEvent;
150
172
  /**
151
173
  * Client for managing statistics
152
174
  */
@@ -336,4 +358,14 @@ export declare class StatsClient extends BaseClient {
336
358
  * Note: Can only be called once per hour per organization (or per org_group if specified)
337
359
  */
338
360
  refresh(params?: RefreshStatsParams): Promise<ApiResponse<RefreshStatsResponse>>;
361
+ /**
362
+ * Refresh stats with NDJSON streaming progress.
363
+ * Returns the raw Response so the caller can read the stream.
364
+ *
365
+ * Events streamed (one JSON object per line):
366
+ * - `{ type: 'start', totalAccounts, totalPosts }`
367
+ * - `{ type: 'progress', completedAccounts, completedPosts, totalAccounts, totalPosts }`
368
+ * - `{ type: 'done', accounts_refreshed, ... }`
369
+ */
370
+ refreshStream(params?: RefreshStatsParams): Promise<Response>;
339
371
  }
package/dist/stats.js CHANGED
@@ -209,5 +209,17 @@ class StatsClient extends base_1.BaseClient {
209
209
  async refresh(params) {
210
210
  return this.post('/stats/refresh', params ?? {});
211
211
  }
212
+ /**
213
+ * Refresh stats with NDJSON streaming progress.
214
+ * Returns the raw Response so the caller can read the stream.
215
+ *
216
+ * Events streamed (one JSON object per line):
217
+ * - `{ type: 'start', totalAccounts, totalPosts }`
218
+ * - `{ type: 'progress', completedAccounts, completedPosts, totalAccounts, totalPosts }`
219
+ * - `{ type: 'done', accounts_refreshed, ... }`
220
+ */
221
+ async refreshStream(params) {
222
+ return this.rawPost('/stats/refresh', params ?? {}, { 'X-Stream-Progress': 'true' });
223
+ }
212
224
  }
213
225
  exports.StatsClient = StatsClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.3.2",
3
+ "version": "4.4.0",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",