@dracoonghost/trndup-sdk 1.3.21 → 1.3.22

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.mts CHANGED
@@ -595,6 +595,110 @@ declare namespace Instagram {
595
595
  stories: Story[];
596
596
  count: number;
597
597
  }
598
+ /** Sync status enum matching backend */
599
+ type SyncStatus = 'NEVER_SYNCED' | 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED';
600
+ /** Individual sync type info */
601
+ interface SyncTypeInfo {
602
+ status: SyncStatus;
603
+ lastSyncAt: string | null;
604
+ lastError?: string | null;
605
+ failedAttempts?: number;
606
+ isStale: boolean;
607
+ nextSyncAt: string | null;
608
+ timeUntilNextSync: string;
609
+ interval: string;
610
+ }
611
+ /**
612
+ * Unified sync status response
613
+ * GET /v1/platforms/instagram/sync/status
614
+ */
615
+ interface UnifiedSyncStatusResponse {
616
+ isConnected: boolean;
617
+ igUserId: string | null;
618
+ username: string | null;
619
+ totalPosts: number;
620
+ syncs: {
621
+ accountInfo: SyncTypeInfo;
622
+ posts: SyncTypeInfo;
623
+ accountAnalytics: SyncTypeInfo;
624
+ postInsights: SyncTypeInfo;
625
+ stories: SyncTypeInfo;
626
+ };
627
+ }
628
+ /**
629
+ * Response from POST /v1/platforms/instagram/posts/sync
630
+ */
631
+ interface PostsSyncResponse {
632
+ posts: {
633
+ total: number;
634
+ synced: number;
635
+ oldestPostDate: string | null;
636
+ };
637
+ syncStatus: {
638
+ isFirstSync: boolean;
639
+ lastSyncAt: string;
640
+ };
641
+ }
642
+ /**
643
+ * Response from GET /v1/platforms/instagram/posts/sync/status
644
+ */
645
+ interface PostsSyncStatusResponse {
646
+ needsSync: boolean;
647
+ status: SyncStatus;
648
+ lastSyncAt: string | null;
649
+ postCount: number;
650
+ oldestPostDate: string | null;
651
+ }
652
+ /**
653
+ * Response from POST /v1/platforms/instagram/analytics/account/sync
654
+ */
655
+ interface AccountAnalyticsSyncResponse {
656
+ range: string;
657
+ metricsCount: number;
658
+ syncStatus: SyncStatus;
659
+ lastSyncAt: string;
660
+ }
661
+ /**
662
+ * Response from GET /v1/platforms/instagram/analytics/account/sync/status
663
+ */
664
+ interface AccountAnalyticsSyncStatusResponse {
665
+ needsSync: boolean;
666
+ status: SyncStatus;
667
+ insightRecords: number;
668
+ dateRange: {
669
+ start: string;
670
+ end: string;
671
+ } | null;
672
+ lastSyncAt: string | null;
673
+ message: string;
674
+ }
675
+ /**
676
+ * Response from POST /v1/platforms/instagram/analytics/posts/sync
677
+ */
678
+ interface PostInsightsSyncResponse {
679
+ totalPosts: number;
680
+ postsWithInsights: number;
681
+ errorCount: number;
682
+ syncStatus: SyncStatus;
683
+ lastSyncAt: string;
684
+ }
685
+ /**
686
+ * Response from GET /v1/platforms/instagram/analytics/posts/sync/status
687
+ */
688
+ interface PostInsightsSyncStatusResponse {
689
+ needsSync: boolean;
690
+ status: SyncStatus;
691
+ totalPosts: number;
692
+ postsWithInsights: number;
693
+ coverage: number;
694
+ lastSyncAt: string | null;
695
+ metadata?: {
696
+ postsWithInsights?: number;
697
+ totalPosts?: number;
698
+ lastCheckedAt?: string;
699
+ } | null;
700
+ message: string;
701
+ }
598
702
  interface SyncResponse {
599
703
  message: string;
600
704
  profile?: {
@@ -1650,21 +1754,62 @@ declare class YouTubeModule {
1650
1754
  * TrndUp SDK - Instagram Module
1651
1755
  *
1652
1756
  * Instagram analytics and data methods
1757
+ * Route structure mirrors YouTube for UI consistency
1653
1758
  */
1654
1759
 
1655
1760
  declare class InstagramModule {
1656
1761
  private client;
1657
1762
  constructor(client: TrndUpClient);
1658
1763
  /**
1659
- * Get Instagram initialization status
1660
- * GET /v1/platforms/instagram/status/init
1764
+ * Get unified sync status for all Instagram data types
1765
+ * GET /v1/platforms/instagram/sync/status
1766
+ *
1767
+ * Shows when each type was last synced and when next sync is due.
1661
1768
  */
1662
- getInitStatus(): Promise<Instagram.InitStatusResponse>;
1769
+ getSyncStatus(): Promise<Instagram.UnifiedSyncStatusResponse>;
1663
1770
  /**
1664
1771
  * Initialize Instagram data sync
1665
- * GET /v1/platforms/instagram/init
1772
+ * POST /v1/platforms/instagram/init
1666
1773
  */
1667
1774
  initialize(): Promise<Instagram.InitResponse>;
1775
+ /**
1776
+ * Get Instagram initialization status
1777
+ * GET /v1/platforms/instagram/init/status
1778
+ */
1779
+ getInitStatus(): Promise<Instagram.InitStatusResponse>;
1780
+ /**
1781
+ * Sync all posts from Instagram to database
1782
+ * POST /v1/platforms/instagram/posts/sync
1783
+ */
1784
+ syncPosts(): Promise<Instagram.PostsSyncResponse>;
1785
+ /**
1786
+ * Check posts sync status without triggering a sync
1787
+ * GET /v1/platforms/instagram/posts/sync/status
1788
+ */
1789
+ getPostsSyncStatus(): Promise<Instagram.PostsSyncStatusResponse>;
1790
+ /**
1791
+ * Sync account-level analytics (reach, impressions, engagement)
1792
+ * POST /v1/platforms/instagram/analytics/account/sync
1793
+ * @param range Time range: '7d', '14d', '30d' (default '30d')
1794
+ */
1795
+ syncAccountAnalytics(params?: {
1796
+ range?: string;
1797
+ }): Promise<Instagram.AccountAnalyticsSyncResponse>;
1798
+ /**
1799
+ * Get account analytics sync status
1800
+ * GET /v1/platforms/instagram/analytics/account/sync/status
1801
+ */
1802
+ getAccountAnalyticsSyncStatus(): Promise<Instagram.AccountAnalyticsSyncStatusResponse>;
1803
+ /**
1804
+ * Sync post-level insights for all posts
1805
+ * POST /v1/platforms/instagram/analytics/posts/sync
1806
+ */
1807
+ syncPostInsights(): Promise<Instagram.PostInsightsSyncResponse>;
1808
+ /**
1809
+ * Get post insights sync status
1810
+ * GET /v1/platforms/instagram/analytics/posts/sync/status
1811
+ */
1812
+ getPostInsightsSyncStatus(): Promise<Instagram.PostInsightsSyncStatusResponse>;
1668
1813
  /**
1669
1814
  * Get user profile info
1670
1815
  * GET /v1/platforms/instagram/profile
@@ -1677,7 +1822,7 @@ declare class InstagramModule {
1677
1822
  */
1678
1823
  getAccountOverview(params?: Instagram.GetAccountOverviewParams): Promise<Instagram.AccountOverviewResponse>;
1679
1824
  /**
1680
- * Get account-level insights
1825
+ * Get account-level insights (historical data)
1681
1826
  * GET /v1/platforms/instagram/account/insights
1682
1827
  * @param range Time range: '7d', '14d', '28d', '30d'
1683
1828
  */
@@ -1698,18 +1843,11 @@ declare class InstagramModule {
1698
1843
  */
1699
1844
  getStories(): Promise<Instagram.StoriesResponse>;
1700
1845
  /**
1701
- * Trigger manual data sync
1846
+ * Trigger manual data sync (legacy - use specific sync methods)
1702
1847
  * POST /v1/platforms/instagram/sync
1848
+ * @deprecated Use syncPosts, syncAccountAnalytics, syncPostInsights instead
1703
1849
  */
1704
1850
  sync(): Promise<Instagram.SyncResponse>;
1705
- /**
1706
- * @deprecated Use getAccountInsights instead
1707
- */
1708
- getAccountMetrics(): Promise<Instagram.AccountInsightsResponse>;
1709
- /**
1710
- * @deprecated Use sync instead
1711
- */
1712
- refresh(): Promise<Instagram.SyncResponse>;
1713
1851
  }
1714
1852
 
1715
1853
  /**
package/dist/index.d.ts CHANGED
@@ -595,6 +595,110 @@ declare namespace Instagram {
595
595
  stories: Story[];
596
596
  count: number;
597
597
  }
598
+ /** Sync status enum matching backend */
599
+ type SyncStatus = 'NEVER_SYNCED' | 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED';
600
+ /** Individual sync type info */
601
+ interface SyncTypeInfo {
602
+ status: SyncStatus;
603
+ lastSyncAt: string | null;
604
+ lastError?: string | null;
605
+ failedAttempts?: number;
606
+ isStale: boolean;
607
+ nextSyncAt: string | null;
608
+ timeUntilNextSync: string;
609
+ interval: string;
610
+ }
611
+ /**
612
+ * Unified sync status response
613
+ * GET /v1/platforms/instagram/sync/status
614
+ */
615
+ interface UnifiedSyncStatusResponse {
616
+ isConnected: boolean;
617
+ igUserId: string | null;
618
+ username: string | null;
619
+ totalPosts: number;
620
+ syncs: {
621
+ accountInfo: SyncTypeInfo;
622
+ posts: SyncTypeInfo;
623
+ accountAnalytics: SyncTypeInfo;
624
+ postInsights: SyncTypeInfo;
625
+ stories: SyncTypeInfo;
626
+ };
627
+ }
628
+ /**
629
+ * Response from POST /v1/platforms/instagram/posts/sync
630
+ */
631
+ interface PostsSyncResponse {
632
+ posts: {
633
+ total: number;
634
+ synced: number;
635
+ oldestPostDate: string | null;
636
+ };
637
+ syncStatus: {
638
+ isFirstSync: boolean;
639
+ lastSyncAt: string;
640
+ };
641
+ }
642
+ /**
643
+ * Response from GET /v1/platforms/instagram/posts/sync/status
644
+ */
645
+ interface PostsSyncStatusResponse {
646
+ needsSync: boolean;
647
+ status: SyncStatus;
648
+ lastSyncAt: string | null;
649
+ postCount: number;
650
+ oldestPostDate: string | null;
651
+ }
652
+ /**
653
+ * Response from POST /v1/platforms/instagram/analytics/account/sync
654
+ */
655
+ interface AccountAnalyticsSyncResponse {
656
+ range: string;
657
+ metricsCount: number;
658
+ syncStatus: SyncStatus;
659
+ lastSyncAt: string;
660
+ }
661
+ /**
662
+ * Response from GET /v1/platforms/instagram/analytics/account/sync/status
663
+ */
664
+ interface AccountAnalyticsSyncStatusResponse {
665
+ needsSync: boolean;
666
+ status: SyncStatus;
667
+ insightRecords: number;
668
+ dateRange: {
669
+ start: string;
670
+ end: string;
671
+ } | null;
672
+ lastSyncAt: string | null;
673
+ message: string;
674
+ }
675
+ /**
676
+ * Response from POST /v1/platforms/instagram/analytics/posts/sync
677
+ */
678
+ interface PostInsightsSyncResponse {
679
+ totalPosts: number;
680
+ postsWithInsights: number;
681
+ errorCount: number;
682
+ syncStatus: SyncStatus;
683
+ lastSyncAt: string;
684
+ }
685
+ /**
686
+ * Response from GET /v1/platforms/instagram/analytics/posts/sync/status
687
+ */
688
+ interface PostInsightsSyncStatusResponse {
689
+ needsSync: boolean;
690
+ status: SyncStatus;
691
+ totalPosts: number;
692
+ postsWithInsights: number;
693
+ coverage: number;
694
+ lastSyncAt: string | null;
695
+ metadata?: {
696
+ postsWithInsights?: number;
697
+ totalPosts?: number;
698
+ lastCheckedAt?: string;
699
+ } | null;
700
+ message: string;
701
+ }
598
702
  interface SyncResponse {
599
703
  message: string;
600
704
  profile?: {
@@ -1650,21 +1754,62 @@ declare class YouTubeModule {
1650
1754
  * TrndUp SDK - Instagram Module
1651
1755
  *
1652
1756
  * Instagram analytics and data methods
1757
+ * Route structure mirrors YouTube for UI consistency
1653
1758
  */
1654
1759
 
1655
1760
  declare class InstagramModule {
1656
1761
  private client;
1657
1762
  constructor(client: TrndUpClient);
1658
1763
  /**
1659
- * Get Instagram initialization status
1660
- * GET /v1/platforms/instagram/status/init
1764
+ * Get unified sync status for all Instagram data types
1765
+ * GET /v1/platforms/instagram/sync/status
1766
+ *
1767
+ * Shows when each type was last synced and when next sync is due.
1661
1768
  */
1662
- getInitStatus(): Promise<Instagram.InitStatusResponse>;
1769
+ getSyncStatus(): Promise<Instagram.UnifiedSyncStatusResponse>;
1663
1770
  /**
1664
1771
  * Initialize Instagram data sync
1665
- * GET /v1/platforms/instagram/init
1772
+ * POST /v1/platforms/instagram/init
1666
1773
  */
1667
1774
  initialize(): Promise<Instagram.InitResponse>;
1775
+ /**
1776
+ * Get Instagram initialization status
1777
+ * GET /v1/platforms/instagram/init/status
1778
+ */
1779
+ getInitStatus(): Promise<Instagram.InitStatusResponse>;
1780
+ /**
1781
+ * Sync all posts from Instagram to database
1782
+ * POST /v1/platforms/instagram/posts/sync
1783
+ */
1784
+ syncPosts(): Promise<Instagram.PostsSyncResponse>;
1785
+ /**
1786
+ * Check posts sync status without triggering a sync
1787
+ * GET /v1/platforms/instagram/posts/sync/status
1788
+ */
1789
+ getPostsSyncStatus(): Promise<Instagram.PostsSyncStatusResponse>;
1790
+ /**
1791
+ * Sync account-level analytics (reach, impressions, engagement)
1792
+ * POST /v1/platforms/instagram/analytics/account/sync
1793
+ * @param range Time range: '7d', '14d', '30d' (default '30d')
1794
+ */
1795
+ syncAccountAnalytics(params?: {
1796
+ range?: string;
1797
+ }): Promise<Instagram.AccountAnalyticsSyncResponse>;
1798
+ /**
1799
+ * Get account analytics sync status
1800
+ * GET /v1/platforms/instagram/analytics/account/sync/status
1801
+ */
1802
+ getAccountAnalyticsSyncStatus(): Promise<Instagram.AccountAnalyticsSyncStatusResponse>;
1803
+ /**
1804
+ * Sync post-level insights for all posts
1805
+ * POST /v1/platforms/instagram/analytics/posts/sync
1806
+ */
1807
+ syncPostInsights(): Promise<Instagram.PostInsightsSyncResponse>;
1808
+ /**
1809
+ * Get post insights sync status
1810
+ * GET /v1/platforms/instagram/analytics/posts/sync/status
1811
+ */
1812
+ getPostInsightsSyncStatus(): Promise<Instagram.PostInsightsSyncStatusResponse>;
1668
1813
  /**
1669
1814
  * Get user profile info
1670
1815
  * GET /v1/platforms/instagram/profile
@@ -1677,7 +1822,7 @@ declare class InstagramModule {
1677
1822
  */
1678
1823
  getAccountOverview(params?: Instagram.GetAccountOverviewParams): Promise<Instagram.AccountOverviewResponse>;
1679
1824
  /**
1680
- * Get account-level insights
1825
+ * Get account-level insights (historical data)
1681
1826
  * GET /v1/platforms/instagram/account/insights
1682
1827
  * @param range Time range: '7d', '14d', '28d', '30d'
1683
1828
  */
@@ -1698,18 +1843,11 @@ declare class InstagramModule {
1698
1843
  */
1699
1844
  getStories(): Promise<Instagram.StoriesResponse>;
1700
1845
  /**
1701
- * Trigger manual data sync
1846
+ * Trigger manual data sync (legacy - use specific sync methods)
1702
1847
  * POST /v1/platforms/instagram/sync
1848
+ * @deprecated Use syncPosts, syncAccountAnalytics, syncPostInsights instead
1703
1849
  */
1704
1850
  sync(): Promise<Instagram.SyncResponse>;
1705
- /**
1706
- * @deprecated Use getAccountInsights instead
1707
- */
1708
- getAccountMetrics(): Promise<Instagram.AccountInsightsResponse>;
1709
- /**
1710
- * @deprecated Use sync instead
1711
- */
1712
- refresh(): Promise<Instagram.SyncResponse>;
1713
1851
  }
1714
1852
 
1715
1853
  /**
package/dist/index.js CHANGED
@@ -486,22 +486,87 @@ var InstagramModule = class {
486
486
  constructor(client) {
487
487
  this.client = client;
488
488
  }
489
+ // ===== UNIFIED SYNC STATUS =====
490
+ /**
491
+ * Get unified sync status for all Instagram data types
492
+ * GET /v1/platforms/instagram/sync/status
493
+ *
494
+ * Shows when each type was last synced and when next sync is due.
495
+ */
496
+ async getSyncStatus() {
497
+ return this.client.get("/v1/platforms/instagram/sync/status");
498
+ }
489
499
  // ===== INITIALIZATION =====
500
+ /**
501
+ * Initialize Instagram data sync
502
+ * POST /v1/platforms/instagram/init
503
+ */
504
+ async initialize() {
505
+ return this.client.post("/v1/platforms/instagram/init");
506
+ }
490
507
  /**
491
508
  * Get Instagram initialization status
492
- * GET /v1/platforms/instagram/status/init
509
+ * GET /v1/platforms/instagram/init/status
493
510
  */
494
511
  async getInitStatus() {
495
- return this.client.get("/v1/platforms/instagram/status/init");
512
+ return this.client.get("/v1/platforms/instagram/init/status");
496
513
  }
514
+ // ===== POSTS SYNC =====
497
515
  /**
498
- * Initialize Instagram data sync
499
- * GET /v1/platforms/instagram/init
516
+ * Sync all posts from Instagram to database
517
+ * POST /v1/platforms/instagram/posts/sync
500
518
  */
501
- async initialize() {
502
- return this.client.get("/v1/platforms/instagram/init");
519
+ async syncPosts() {
520
+ return this.client.post("/v1/platforms/instagram/posts/sync");
503
521
  }
504
- // ===== ACCOUNT INSIGHTS =====
522
+ /**
523
+ * Check posts sync status without triggering a sync
524
+ * GET /v1/platforms/instagram/posts/sync/status
525
+ */
526
+ async getPostsSyncStatus() {
527
+ return this.client.get("/v1/platforms/instagram/posts/sync/status");
528
+ }
529
+ // ===== ACCOUNT ANALYTICS SYNC =====
530
+ /**
531
+ * Sync account-level analytics (reach, impressions, engagement)
532
+ * POST /v1/platforms/instagram/analytics/account/sync
533
+ * @param range Time range: '7d', '14d', '30d' (default '30d')
534
+ */
535
+ async syncAccountAnalytics(params) {
536
+ const queryParams = params?.range ? `?range=${params.range}` : "";
537
+ return this.client.post(
538
+ `/v1/platforms/instagram/analytics/account/sync${queryParams}`
539
+ );
540
+ }
541
+ /**
542
+ * Get account analytics sync status
543
+ * GET /v1/platforms/instagram/analytics/account/sync/status
544
+ */
545
+ async getAccountAnalyticsSyncStatus() {
546
+ return this.client.get(
547
+ "/v1/platforms/instagram/analytics/account/sync/status"
548
+ );
549
+ }
550
+ // ===== POST INSIGHTS SYNC =====
551
+ /**
552
+ * Sync post-level insights for all posts
553
+ * POST /v1/platforms/instagram/analytics/posts/sync
554
+ */
555
+ async syncPostInsights() {
556
+ return this.client.post(
557
+ "/v1/platforms/instagram/analytics/posts/sync"
558
+ );
559
+ }
560
+ /**
561
+ * Get post insights sync status
562
+ * GET /v1/platforms/instagram/analytics/posts/sync/status
563
+ */
564
+ async getPostInsightsSyncStatus() {
565
+ return this.client.get(
566
+ "/v1/platforms/instagram/analytics/posts/sync/status"
567
+ );
568
+ }
569
+ // ===== DATA RETRIEVAL =====
505
570
  /**
506
571
  * Get user profile info
507
572
  * GET /v1/platforms/instagram/profile
@@ -521,7 +586,7 @@ var InstagramModule = class {
521
586
  );
522
587
  }
523
588
  /**
524
- * Get account-level insights
589
+ * Get account-level insights (historical data)
525
590
  * GET /v1/platforms/instagram/account/insights
526
591
  * @param range Time range: '7d', '14d', '28d', '30d'
527
592
  */
@@ -531,7 +596,6 @@ var InstagramModule = class {
531
596
  params
532
597
  );
533
598
  }
534
- // ===== MEDIA / POSTS =====
535
599
  /**
536
600
  * Get Instagram posts
537
601
  * GET /v1/platforms/instagram/posts
@@ -551,7 +615,6 @@ var InstagramModule = class {
551
615
  `/v1/platforms/instagram/posts/${postId}/insights`
552
616
  );
553
617
  }
554
- // ===== STORIES =====
555
618
  /**
556
619
  * Get active stories
557
620
  * GET /v1/platforms/instagram/stories
@@ -559,27 +622,15 @@ var InstagramModule = class {
559
622
  async getStories() {
560
623
  return this.client.get("/v1/platforms/instagram/stories");
561
624
  }
562
- // ===== SYNC =====
625
+ // ===== LEGACY SYNC (backward compat) =====
563
626
  /**
564
- * Trigger manual data sync
627
+ * Trigger manual data sync (legacy - use specific sync methods)
565
628
  * POST /v1/platforms/instagram/sync
629
+ * @deprecated Use syncPosts, syncAccountAnalytics, syncPostInsights instead
566
630
  */
567
631
  async sync() {
568
632
  return this.client.post("/v1/platforms/instagram/sync");
569
633
  }
570
- // ===== LEGACY (backward compat) =====
571
- /**
572
- * @deprecated Use getAccountInsights instead
573
- */
574
- async getAccountMetrics() {
575
- return this.getAccountInsights();
576
- }
577
- /**
578
- * @deprecated Use sync instead
579
- */
580
- async refresh() {
581
- return this.sync();
582
- }
583
634
  };
584
635
 
585
636
  // modules/social.ts