@dracoonghost/trndup-sdk 1.3.18 → 1.3.20

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.d.ts CHANGED
@@ -86,6 +86,22 @@ declare namespace Auth {
86
86
  interface UpdateProfileResponse {
87
87
  user: User;
88
88
  }
89
+ /**
90
+ * Response from OAuth URL request
91
+ */
92
+ interface OAuthUrlResponse {
93
+ /** URL to redirect user to for OAuth consent */
94
+ authUrl: string;
95
+ }
96
+ /**
97
+ * OAuth callback result (returned in redirect URL params)
98
+ */
99
+ interface OAuthCallbackResult {
100
+ success: boolean;
101
+ provider: 'facebook' | 'instagram';
102
+ message?: string;
103
+ error?: string;
104
+ }
89
105
  /**
90
106
  * Status for a single sync step
91
107
  */
@@ -432,38 +448,113 @@ declare namespace YouTube {
432
448
  }
433
449
  declare namespace Instagram {
434
450
  interface InitStatusResponse {
451
+ connected: boolean;
452
+ needsInit: boolean;
453
+ isInitialSyncDone?: boolean;
454
+ lastSyncedAt?: string | null;
455
+ authMethod?: 'facebook' | 'instagram';
456
+ account?: {
457
+ username?: string;
458
+ name?: string;
459
+ profilePictureUrl?: string;
460
+ followersCount?: number;
461
+ mediaCount?: number;
462
+ } | null;
463
+ syncedMediaCount?: number;
464
+ message?: string;
465
+ }
466
+ interface InitResponse {
435
467
  needsInit: boolean;
436
468
  message: string;
437
- postCount?: number;
438
- accountId?: string;
439
- username?: string;
469
+ profile?: {
470
+ username?: string;
471
+ name?: string;
472
+ profilePictureUrl?: string;
473
+ followersCount?: number;
474
+ mediaCount?: number;
475
+ };
476
+ syncedMedia?: number;
477
+ lastSyncedAt?: string;
478
+ }
479
+ interface GetAccountInsightsParams {
480
+ range?: '7d' | '14d' | '28d' | '30d';
481
+ }
482
+ interface AccountInsightsResponse {
483
+ range: string;
484
+ aggregated: Record<string, number>;
485
+ timeSeries: Record<string, Array<{
486
+ date: string;
487
+ value: number;
488
+ }>>;
440
489
  }
441
490
  interface Post {
442
491
  id: string;
492
+ media_id: string;
443
493
  caption?: string;
444
- mediaType: 'IMAGE' | 'VIDEO' | 'CAROUSEL_ALBUM';
445
- mediaUrl: string;
446
- permalink: string;
494
+ media_type: 'IMAGE' | 'VIDEO' | 'CAROUSEL_ALBUM' | 'REELS';
495
+ media_url?: string;
496
+ thumbnail_url?: string;
497
+ permalink?: string;
447
498
  timestamp: string;
448
- likeCount?: number;
449
- commentsCount?: number;
450
- engagementRate?: number;
499
+ like_count?: number;
500
+ comments_count?: number;
451
501
  }
452
502
  interface GetPostsParams {
453
503
  limit?: number;
454
504
  offset?: number;
505
+ mediaType?: string;
506
+ sortBy?: 'timestamp' | 'like_count' | 'comments_count';
507
+ sortOrder?: 'asc' | 'desc';
455
508
  }
456
509
  interface GetPostsResponse {
457
510
  posts: Post[];
458
- total: number;
459
- hasMore: boolean;
511
+ pagination: {
512
+ limit: number;
513
+ offset: number;
514
+ total: number;
515
+ hasMore: boolean;
516
+ };
517
+ }
518
+ interface PostInsightsResponse {
519
+ postId: string;
520
+ mediaType: string;
521
+ insights: {
522
+ data: Array<{
523
+ name: string;
524
+ title: string;
525
+ values: Array<{
526
+ value: number;
527
+ }>;
528
+ }>;
529
+ };
530
+ }
531
+ interface Story {
532
+ id: string;
533
+ media_type: 'IMAGE' | 'VIDEO';
534
+ media_url?: string;
535
+ timestamp: string;
536
+ permalink?: string;
537
+ }
538
+ interface StoriesResponse {
539
+ stories: Story[];
540
+ count: number;
541
+ }
542
+ interface SyncResponse {
543
+ message: string;
544
+ profile?: {
545
+ username?: string;
546
+ followersCount?: number;
547
+ mediaCount?: number;
548
+ };
549
+ syncedMedia?: number;
460
550
  }
551
+ /** @deprecated Use InitStatusResponse */
461
552
  interface AccountMetrics {
462
553
  followersCount: number;
463
554
  followsCount: number;
464
555
  mediaCount: number;
465
- averageLikes: number;
466
- engagementRate: number;
556
+ averageLikes?: number;
557
+ engagementRate?: number;
467
558
  }
468
559
  }
469
560
  declare namespace Insights {
@@ -1023,6 +1114,61 @@ declare namespace Insights {
1023
1114
  data: OptimalVideoLengthData;
1024
1115
  _meta: InsightMeta;
1025
1116
  };
1117
+ /** Consistency status levels */
1118
+ type ConsistencyStatus = 'excellent' | 'good' | 'needs_improvement' | 'poor' | 'inactive';
1119
+ /** Monthly upload breakdown */
1120
+ interface MonthlyUploadData {
1121
+ month: string;
1122
+ uploads: number;
1123
+ avgGap: number | null;
1124
+ }
1125
+ /** Upload consistency insight data */
1126
+ interface UploadConsistencyData {
1127
+ /** Period analyzed */
1128
+ period: {
1129
+ start: string;
1130
+ end: string;
1131
+ days: number;
1132
+ };
1133
+ /** Overall consistency score (0-100) */
1134
+ consistencyScore: number;
1135
+ /** Status label */
1136
+ status: ConsistencyStatus;
1137
+ /** Key metrics */
1138
+ metrics: {
1139
+ totalUploads: number;
1140
+ avgDaysBetweenUploads: number;
1141
+ uploadVariance: number;
1142
+ daysSinceLastUpload: number;
1143
+ lastUploadDate: string | null;
1144
+ };
1145
+ /** Upload pattern analysis */
1146
+ pattern: {
1147
+ isRegular: boolean;
1148
+ typicalGap: string;
1149
+ longestStreak: number;
1150
+ currentStreak: number;
1151
+ trend: 'increasing' | 'stable' | 'decreasing';
1152
+ trendDescription: string;
1153
+ };
1154
+ /** Monthly breakdown */
1155
+ monthlyBreakdown: MonthlyUploadData[];
1156
+ /** Frequency recommendation */
1157
+ recommendation: {
1158
+ suggested: string;
1159
+ current: string;
1160
+ reason: string;
1161
+ };
1162
+ /** Human-readable summary */
1163
+ insight: string;
1164
+ /** Actionable recommendations */
1165
+ recommendations: string[];
1166
+ }
1167
+ type UploadConsistencyResponse = (InsufficientDataResponse) | {
1168
+ hasData: true;
1169
+ data: UploadConsistencyData;
1170
+ _meta: InsightMeta;
1171
+ };
1026
1172
  interface AllInsightsData {
1027
1173
  bestPerformingVideo: BestPerformingVideoResponse;
1028
1174
  contentDecay: ContentDecayResponse;
@@ -1031,6 +1177,7 @@ declare namespace Insights {
1031
1177
  fadingHits: FadingHitsResponse;
1032
1178
  audienceFatigue: AudienceFatigueResponse;
1033
1179
  optimalLength: OptimalVideoLengthResponse;
1180
+ uploadConsistency: UploadConsistencyResponse;
1034
1181
  }
1035
1182
  interface AllInsightsResponse {
1036
1183
  data: AllInsightsData;
@@ -1287,6 +1434,44 @@ declare class AuthModule {
1287
1434
  * GET /user/platforms/status
1288
1435
  */
1289
1436
  getPlatformStatus(): Promise<Auth.PlatformStatus>;
1437
+ /**
1438
+ * Get Facebook OAuth URL for connecting Instagram Business accounts
1439
+ * GET /auth/facebook
1440
+ *
1441
+ * After receiving the authUrl, redirect/open this URL in a browser.
1442
+ * User will authenticate with Facebook and grant Instagram permissions.
1443
+ * After completion, user is redirected to the specified redirect_uri.
1444
+ *
1445
+ * @param redirectUri - URL to redirect to after OAuth (your app's deep link)
1446
+ * @returns OAuth authorization URL to redirect user to
1447
+ */
1448
+ getFacebookOAuthUrl(redirectUri?: string): Promise<Auth.OAuthUrlResponse>;
1449
+ /**
1450
+ * Get Instagram OAuth URL for connecting Instagram Professional accounts
1451
+ * GET /auth/instagram
1452
+ *
1453
+ * After receiving the authUrl, redirect/open this URL in a browser.
1454
+ * User will authenticate with Instagram and grant permissions.
1455
+ * After completion, user is redirected to the specified redirect_uri.
1456
+ *
1457
+ * @param redirectUri - URL to redirect to after OAuth (your app's deep link)
1458
+ * @returns OAuth authorization URL to redirect user to
1459
+ */
1460
+ getInstagramOAuthUrl(redirectUri?: string): Promise<Auth.OAuthUrlResponse>;
1461
+ /**
1462
+ * Build OAuth URL for Facebook (Instagram Business)
1463
+ * Convenience method that returns just the URL string
1464
+ *
1465
+ * @param redirectUri - URL to redirect to after OAuth
1466
+ */
1467
+ buildFacebookOAuthUrl(redirectUri?: string): Promise<string>;
1468
+ /**
1469
+ * Build OAuth URL for Instagram
1470
+ * Convenience method that returns just the URL string
1471
+ *
1472
+ * @param redirectUri - URL to redirect to after OAuth
1473
+ */
1474
+ buildInstagramOAuthUrl(redirectUri?: string): Promise<string>;
1290
1475
  }
1291
1476
 
1292
1477
  /**
@@ -1416,38 +1601,48 @@ declare class InstagramModule {
1416
1601
  constructor(client: TrndUpClient);
1417
1602
  /**
1418
1603
  * Get Instagram initialization status
1419
- * GET /v1/platforms/instagram/init/status
1604
+ * GET /v1/platforms/instagram/status/init
1420
1605
  */
1421
1606
  getInitStatus(): Promise<Instagram.InitStatusResponse>;
1422
1607
  /**
1423
1608
  * Initialize Instagram data sync
1424
- * POST /v1/platforms/instagram/init
1609
+ * GET /v1/platforms/instagram/init
1425
1610
  */
1426
- initialize(): Promise<{
1427
- message: string;
1428
- }>;
1611
+ initialize(): Promise<Instagram.InitResponse>;
1612
+ /**
1613
+ * Get account-level insights
1614
+ * GET /v1/platforms/instagram/account/insights
1615
+ * @param range Time range: '7d', '14d', '28d', '30d'
1616
+ */
1617
+ getAccountInsights(params?: Instagram.GetAccountInsightsParams): Promise<Instagram.AccountInsightsResponse>;
1429
1618
  /**
1430
1619
  * Get Instagram posts
1431
1620
  * GET /v1/platforms/instagram/posts
1432
1621
  */
1433
1622
  getPosts(params?: Instagram.GetPostsParams): Promise<Instagram.GetPostsResponse>;
1434
1623
  /**
1435
- * Get specific post by ID
1436
- * GET /v1/platforms/instagram/posts/:postId
1624
+ * Get insights for a specific post
1625
+ * GET /v1/platforms/instagram/posts/:postId/insights
1437
1626
  */
1438
- getPost(postId: string): Promise<Instagram.Post>;
1627
+ getPostInsights(postId: string): Promise<Instagram.PostInsightsResponse>;
1439
1628
  /**
1440
- * Get account metrics
1441
- * GET /v1/platforms/instagram/account/metrics
1629
+ * Get active stories
1630
+ * GET /v1/platforms/instagram/stories
1442
1631
  */
1443
- getAccountMetrics(): Promise<Instagram.AccountMetrics>;
1632
+ getStories(): Promise<Instagram.StoriesResponse>;
1444
1633
  /**
1445
- * Refresh Instagram data
1446
- * POST /v1/platforms/instagram/refresh
1634
+ * Trigger manual data sync
1635
+ * POST /v1/platforms/instagram/sync
1447
1636
  */
1448
- refresh(): Promise<{
1449
- message: string;
1450
- }>;
1637
+ sync(): Promise<Instagram.SyncResponse>;
1638
+ /**
1639
+ * @deprecated Use getAccountInsights instead
1640
+ */
1641
+ getAccountMetrics(): Promise<Instagram.AccountInsightsResponse>;
1642
+ /**
1643
+ * @deprecated Use sync instead
1644
+ */
1645
+ refresh(): Promise<Instagram.SyncResponse>;
1451
1646
  }
1452
1647
 
1453
1648
  /**
@@ -1761,6 +1956,40 @@ declare class InsightsModule {
1761
1956
  * GET /v1/insights/youtube/optimal-length
1762
1957
  */
1763
1958
  getYouTubeOptimalLength(): Promise<Insights.OptimalVideoLengthResponse>;
1959
+ /**
1960
+ * Analyze your upload schedule consistency
1961
+ *
1962
+ * Measures how regularly you upload and provides recommendations
1963
+ * for maintaining a consistent schedule that helps algorithm performance.
1964
+ *
1965
+ * @example
1966
+ * ```typescript
1967
+ * const result = await client.insights.getYouTubeUploadConsistency();
1968
+ *
1969
+ * if (result.hasData) {
1970
+ * console.log(`Consistency Score: ${result.data.consistencyScore}/100`);
1971
+ * console.log(`Status: ${result.data.status}`);
1972
+ * console.log(`Avg gap: ${result.data.metrics.avgDaysBetweenUploads} days`);
1973
+ * console.log(`Days since last upload: ${result.data.metrics.daysSinceLastUpload}`);
1974
+ *
1975
+ * // Pattern analysis
1976
+ * console.log(`Pattern: ${result.data.pattern.typicalGap}`);
1977
+ * console.log(`Trend: ${result.data.pattern.trendDescription}`);
1978
+ *
1979
+ * // Recommendation
1980
+ * console.log(`Current: ${result.data.recommendation.current}`);
1981
+ * console.log(`Suggested: ${result.data.recommendation.suggested}`);
1982
+ *
1983
+ * // Monthly breakdown
1984
+ * for (const month of result.data.monthlyBreakdown) {
1985
+ * console.log(`${month.month}: ${month.uploads} uploads`);
1986
+ * }
1987
+ * }
1988
+ * ```
1989
+ *
1990
+ * GET /v1/insights/youtube/upload-consistency
1991
+ */
1992
+ getYouTubeUploadConsistency(): Promise<Insights.UploadConsistencyResponse>;
1764
1993
  /**
1765
1994
  * Get all YouTube insights in one call
1766
1995
  *
@@ -1783,8 +2012,8 @@ declare class InsightsModule {
1783
2012
  * console.log(`Fatigue: ${all.data.audienceFatigue.data.fatigueLevel}`);
1784
2013
  * }
1785
2014
  *
1786
- * if (all.data.optimalLength.hasData) {
1787
- * console.log(`Optimal Length: ${all.data.optimalLength.data.optimalLength.bucket}`);
2015
+ * if (all.data.uploadConsistency.hasData) {
2016
+ * console.log(`Consistency: ${all.data.uploadConsistency.data.consistencyScore}/100`);
1788
2017
  * }
1789
2018
  * ```
1790
2019
  *
package/dist/index.js CHANGED
@@ -264,6 +264,59 @@ var AuthModule = class {
264
264
  async getPlatformStatus() {
265
265
  return this.client.get("/user/platforms/status");
266
266
  }
267
+ // =========================================================================
268
+ // OAUTH FLOWS
269
+ // =========================================================================
270
+ /**
271
+ * Get Facebook OAuth URL for connecting Instagram Business accounts
272
+ * GET /auth/facebook
273
+ *
274
+ * After receiving the authUrl, redirect/open this URL in a browser.
275
+ * User will authenticate with Facebook and grant Instagram permissions.
276
+ * After completion, user is redirected to the specified redirect_uri.
277
+ *
278
+ * @param redirectUri - URL to redirect to after OAuth (your app's deep link)
279
+ * @returns OAuth authorization URL to redirect user to
280
+ */
281
+ async getFacebookOAuthUrl(redirectUri) {
282
+ const params = redirectUri ? { redirect_uri: redirectUri } : void 0;
283
+ return this.client.get("/auth/facebook", params);
284
+ }
285
+ /**
286
+ * Get Instagram OAuth URL for connecting Instagram Professional accounts
287
+ * GET /auth/instagram
288
+ *
289
+ * After receiving the authUrl, redirect/open this URL in a browser.
290
+ * User will authenticate with Instagram and grant permissions.
291
+ * After completion, user is redirected to the specified redirect_uri.
292
+ *
293
+ * @param redirectUri - URL to redirect to after OAuth (your app's deep link)
294
+ * @returns OAuth authorization URL to redirect user to
295
+ */
296
+ async getInstagramOAuthUrl(redirectUri) {
297
+ const params = redirectUri ? { redirect_uri: redirectUri } : void 0;
298
+ return this.client.get("/auth/instagram", params);
299
+ }
300
+ /**
301
+ * Build OAuth URL for Facebook (Instagram Business)
302
+ * Convenience method that returns just the URL string
303
+ *
304
+ * @param redirectUri - URL to redirect to after OAuth
305
+ */
306
+ async buildFacebookOAuthUrl(redirectUri) {
307
+ const response = await this.getFacebookOAuthUrl(redirectUri);
308
+ return response.authUrl;
309
+ }
310
+ /**
311
+ * Build OAuth URL for Instagram
312
+ * Convenience method that returns just the URL string
313
+ *
314
+ * @param redirectUri - URL to redirect to after OAuth
315
+ */
316
+ async buildInstagramOAuthUrl(redirectUri) {
317
+ const response = await this.getInstagramOAuthUrl(redirectUri);
318
+ return response.authUrl;
319
+ }
267
320
  };
268
321
 
269
322
  // modules/youtube.ts
@@ -433,20 +486,34 @@ var InstagramModule = class {
433
486
  constructor(client) {
434
487
  this.client = client;
435
488
  }
489
+ // ===== INITIALIZATION =====
436
490
  /**
437
491
  * Get Instagram initialization status
438
- * GET /v1/platforms/instagram/init/status
492
+ * GET /v1/platforms/instagram/status/init
439
493
  */
440
494
  async getInitStatus() {
441
- return this.client.get("/v1/platforms/instagram/init/status");
495
+ return this.client.get("/v1/platforms/instagram/status/init");
442
496
  }
443
497
  /**
444
498
  * Initialize Instagram data sync
445
- * POST /v1/platforms/instagram/init
499
+ * GET /v1/platforms/instagram/init
446
500
  */
447
501
  async initialize() {
448
- return this.client.post("/v1/platforms/instagram/init");
502
+ return this.client.get("/v1/platforms/instagram/init");
449
503
  }
504
+ // ===== ACCOUNT INSIGHTS =====
505
+ /**
506
+ * Get account-level insights
507
+ * GET /v1/platforms/instagram/account/insights
508
+ * @param range Time range: '7d', '14d', '28d', '30d'
509
+ */
510
+ async getAccountInsights(params) {
511
+ return this.client.get(
512
+ "/v1/platforms/instagram/account/insights",
513
+ params
514
+ );
515
+ }
516
+ // ===== MEDIA / POSTS =====
450
517
  /**
451
518
  * Get Instagram posts
452
519
  * GET /v1/platforms/instagram/posts
@@ -458,25 +525,42 @@ var InstagramModule = class {
458
525
  );
459
526
  }
460
527
  /**
461
- * Get specific post by ID
462
- * GET /v1/platforms/instagram/posts/:postId
528
+ * Get insights for a specific post
529
+ * GET /v1/platforms/instagram/posts/:postId/insights
530
+ */
531
+ async getPostInsights(postId) {
532
+ return this.client.get(
533
+ `/v1/platforms/instagram/posts/${postId}/insights`
534
+ );
535
+ }
536
+ // ===== STORIES =====
537
+ /**
538
+ * Get active stories
539
+ * GET /v1/platforms/instagram/stories
540
+ */
541
+ async getStories() {
542
+ return this.client.get("/v1/platforms/instagram/stories");
543
+ }
544
+ // ===== SYNC =====
545
+ /**
546
+ * Trigger manual data sync
547
+ * POST /v1/platforms/instagram/sync
463
548
  */
464
- async getPost(postId) {
465
- return this.client.get(`/v1/platforms/instagram/posts/${postId}`);
549
+ async sync() {
550
+ return this.client.post("/v1/platforms/instagram/sync");
466
551
  }
552
+ // ===== LEGACY (backward compat) =====
467
553
  /**
468
- * Get account metrics
469
- * GET /v1/platforms/instagram/account/metrics
554
+ * @deprecated Use getAccountInsights instead
470
555
  */
471
556
  async getAccountMetrics() {
472
- return this.client.get("/v1/platforms/instagram/account/metrics");
557
+ return this.getAccountInsights();
473
558
  }
474
559
  /**
475
- * Refresh Instagram data
476
- * POST /v1/platforms/instagram/refresh
560
+ * @deprecated Use sync instead
477
561
  */
478
562
  async refresh() {
479
- return this.client.post("/v1/platforms/instagram/refresh");
563
+ return this.sync();
480
564
  }
481
565
  };
482
566
 
@@ -859,6 +943,47 @@ var InsightsModule = class {
859
943
  );
860
944
  }
861
945
  // =========================================================================
946
+ // YOUTUBE UPLOAD CONSISTENCY
947
+ // =========================================================================
948
+ /**
949
+ * Analyze your upload schedule consistency
950
+ *
951
+ * Measures how regularly you upload and provides recommendations
952
+ * for maintaining a consistent schedule that helps algorithm performance.
953
+ *
954
+ * @example
955
+ * ```typescript
956
+ * const result = await client.insights.getYouTubeUploadConsistency();
957
+ *
958
+ * if (result.hasData) {
959
+ * console.log(`Consistency Score: ${result.data.consistencyScore}/100`);
960
+ * console.log(`Status: ${result.data.status}`);
961
+ * console.log(`Avg gap: ${result.data.metrics.avgDaysBetweenUploads} days`);
962
+ * console.log(`Days since last upload: ${result.data.metrics.daysSinceLastUpload}`);
963
+ *
964
+ * // Pattern analysis
965
+ * console.log(`Pattern: ${result.data.pattern.typicalGap}`);
966
+ * console.log(`Trend: ${result.data.pattern.trendDescription}`);
967
+ *
968
+ * // Recommendation
969
+ * console.log(`Current: ${result.data.recommendation.current}`);
970
+ * console.log(`Suggested: ${result.data.recommendation.suggested}`);
971
+ *
972
+ * // Monthly breakdown
973
+ * for (const month of result.data.monthlyBreakdown) {
974
+ * console.log(`${month.month}: ${month.uploads} uploads`);
975
+ * }
976
+ * }
977
+ * ```
978
+ *
979
+ * GET /v1/insights/youtube/upload-consistency
980
+ */
981
+ async getYouTubeUploadConsistency() {
982
+ return this.client.get(
983
+ "/v1/insights/youtube/upload-consistency"
984
+ );
985
+ }
986
+ // =========================================================================
862
987
  // YOUTUBE ALL INSIGHTS
863
988
  // =========================================================================
864
989
  /**
@@ -883,8 +1008,8 @@ var InsightsModule = class {
883
1008
  * console.log(`Fatigue: ${all.data.audienceFatigue.data.fatigueLevel}`);
884
1009
  * }
885
1010
  *
886
- * if (all.data.optimalLength.hasData) {
887
- * console.log(`Optimal Length: ${all.data.optimalLength.data.optimalLength.bucket}`);
1011
+ * if (all.data.uploadConsistency.hasData) {
1012
+ * console.log(`Consistency: ${all.data.uploadConsistency.data.consistencyScore}/100`);
888
1013
  * }
889
1014
  * ```
890
1015
  *