@dracoonghost/trndup-sdk 1.4.0 → 1.5.1

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.mjs CHANGED
@@ -365,6 +365,93 @@ var AuthModule = class {
365
365
  const response = await this.getInstagramOAuthUrl(redirectUri);
366
366
  return response.authUrl;
367
367
  }
368
+ // =========================================================================
369
+ // PHONE LINKING (for existing authenticated users)
370
+ // =========================================================================
371
+ /**
372
+ * Send OTP to link phone number to existing account
373
+ * POST /auth/phone/link/send-otp
374
+ *
375
+ * @param phoneNumber - Phone number to link (E.164 format)
376
+ */
377
+ async linkPhoneSendOTP(phoneNumber) {
378
+ return this.client.post(
379
+ "/auth/phone/link/send-otp",
380
+ { phoneNumber }
381
+ );
382
+ }
383
+ /**
384
+ * Verify OTP and link phone to account
385
+ * POST /auth/phone/link/verify
386
+ *
387
+ * @param phoneNumber - Phone number to link
388
+ * @param code - 6-digit verification code
389
+ */
390
+ async linkPhoneVerify(phoneNumber, code) {
391
+ return this.client.post(
392
+ "/auth/phone/link/verify",
393
+ { phoneNumber, code }
394
+ );
395
+ }
396
+ /**
397
+ * Remove phone number from account
398
+ * DELETE /auth/phone
399
+ */
400
+ async unlinkPhone() {
401
+ return this.client.delete("/auth/phone");
402
+ }
403
+ // =========================================================================
404
+ // ACCOUNT MANAGEMENT (App Store & GDPR compliance)
405
+ // =========================================================================
406
+ /**
407
+ * Delete account (soft delete - 30 day grace period)
408
+ * DELETE /auth/account
409
+ *
410
+ * Account is scheduled for permanent deletion after 30 days.
411
+ * User can reactivate by logging in within the grace period.
412
+ * Required for App Store compliance.
413
+ *
414
+ * @param reason - Optional reason for deletion (sent as query param)
415
+ */
416
+ async deleteAccount(reason) {
417
+ const path = reason ? `/auth/account?reason=${encodeURIComponent(reason)}` : "/auth/account";
418
+ return this.client.delete(path);
419
+ }
420
+ /**
421
+ * Reactivate deleted account (within 30 day grace period)
422
+ * POST /auth/account/reactivate
423
+ */
424
+ async reactivateAccount() {
425
+ return this.client.post("/auth/account/reactivate");
426
+ }
427
+ /**
428
+ * Export user data (GDPR compliance)
429
+ * GET /auth/privacy-export
430
+ *
431
+ * Returns all user data for GDPR data portability requirements.
432
+ */
433
+ async exportUserData() {
434
+ return this.client.get("/auth/privacy-export");
435
+ }
436
+ // =========================================================================
437
+ // NOTIFICATION PREFERENCES
438
+ // =========================================================================
439
+ /**
440
+ * Get notification preferences
441
+ * GET /auth/notifications
442
+ */
443
+ async getNotificationPreferences() {
444
+ return this.client.get("/auth/notifications");
445
+ }
446
+ /**
447
+ * Update notification preferences
448
+ * PATCH /auth/notifications
449
+ *
450
+ * @param preferences - Notification channels to enable/disable
451
+ */
452
+ async updateNotificationPreferences(preferences) {
453
+ return this.client.patch("/auth/notifications", preferences);
454
+ }
368
455
  };
369
456
 
370
457
  // modules/youtube.ts
@@ -727,6 +814,203 @@ var SocialModule = class {
727
814
  var InsightsModule = class {
728
815
  constructor(client) {
729
816
  this.client = client;
817
+ // =========================================================================
818
+ // INSTAGRAM INSIGHTS
819
+ // =========================================================================
820
+ /**
821
+ * Instagram insights sub-module
822
+ */
823
+ this.instagram = {
824
+ /**
825
+ * Get all Instagram insights in one call
826
+ *
827
+ * Efficient for dashboard display - fetches all insights in parallel.
828
+ *
829
+ * @example
830
+ * ```typescript
831
+ * const all = await client.insights.instagram.getAll({ range: '30d' });
832
+ *
833
+ * // Check which insights are available
834
+ * if (all.data.health.hasData) {
835
+ * console.log(`Health Score: ${all.data.health.data.overall}/100`);
836
+ * }
837
+ *
838
+ * if (all.data.bestPost.hasData) {
839
+ * console.log(`Best Post: ${all.data.bestPost.data.post.caption}`);
840
+ * }
841
+ * ```
842
+ *
843
+ * GET /v1/insights/instagram
844
+ */
845
+ getAll: (params) => {
846
+ const queryParams = new URLSearchParams();
847
+ if (params?.range) queryParams.set("range", params.range);
848
+ const query = queryParams.toString();
849
+ return this.client.get(
850
+ `/v1/insights/instagram${query ? `?${query}` : ""}`
851
+ );
852
+ },
853
+ /**
854
+ * Get Instagram health score
855
+ *
856
+ * Overall account health based on consistency, engagement, growth, and reach.
857
+ * Score ranges from 0-100 with labels: excellent, good, fair, needs_attention, poor.
858
+ *
859
+ * @example
860
+ * ```typescript
861
+ * const health = await client.insights.instagram.getHealthScore({ range: '30d' });
862
+ *
863
+ * if (health.hasData) {
864
+ * console.log(`Score: ${health.data.overall}/100 (${health.data.label})`);
865
+ * console.log(`Consistency: ${health.data.components.consistency.score}`);
866
+ * console.log(`Engagement: ${health.data.components.engagement.score}`);
867
+ * console.log(`Growth: ${health.data.components.growth.score}`);
868
+ * console.log(`Reach: ${health.data.components.reach.score}`);
869
+ * }
870
+ * ```
871
+ *
872
+ * GET /v1/insights/instagram/health
873
+ */
874
+ getHealthScore: (params) => {
875
+ const queryParams = new URLSearchParams();
876
+ if (params?.range) queryParams.set("range", params.range);
877
+ const query = queryParams.toString();
878
+ return this.client.get(
879
+ `/v1/insights/instagram/health${query ? `?${query}` : ""}`
880
+ );
881
+ },
882
+ /**
883
+ * Get best performing post
884
+ *
885
+ * Identifies the top performing post in the period based on engagement rate.
886
+ * Includes analysis of why it worked and comparison to average.
887
+ *
888
+ * @example
889
+ * ```typescript
890
+ * const best = await client.insights.instagram.getBestPost({ range: '30d' });
891
+ *
892
+ * if (best.hasData) {
893
+ * console.log(`Post: ${best.data.post.caption}`);
894
+ * console.log(`Engagement: ${best.data.post.metrics.engagementRate}%`);
895
+ * console.log(`Above average: ${best.data.comparison.vsAverage.engagement}%`);
896
+ * }
897
+ * ```
898
+ *
899
+ * GET /v1/insights/instagram/best-post
900
+ */
901
+ getBestPost: (params) => {
902
+ const queryParams = new URLSearchParams();
903
+ if (params?.range) queryParams.set("range", params.range);
904
+ const query = queryParams.toString();
905
+ return this.client.get(
906
+ `/v1/insights/instagram/best-post${query ? `?${query}` : ""}`
907
+ );
908
+ },
909
+ /**
910
+ * Get posting consistency analysis
911
+ *
912
+ * Analyzes posting frequency patterns and consistency.
913
+ * Identifies best posting days and gaps in schedule.
914
+ *
915
+ * @example
916
+ * ```typescript
917
+ * const consistency = await client.insights.instagram.getConsistency({ range: '90d' });
918
+ *
919
+ * if (consistency.hasData) {
920
+ * console.log(`Posts/week: ${consistency.data.frequency.current.postsPerWeek}`);
921
+ * console.log(`Score: ${consistency.data.consistency.score}/100`);
922
+ * console.log(`Best day: ${consistency.data.patterns.mostActiveDay}`);
923
+ * }
924
+ * ```
925
+ *
926
+ * GET /v1/insights/instagram/consistency
927
+ */
928
+ getConsistency: (params) => {
929
+ const queryParams = new URLSearchParams();
930
+ if (params?.range) queryParams.set("range", params.range);
931
+ const query = queryParams.toString();
932
+ return this.client.get(
933
+ `/v1/insights/instagram/consistency${query ? `?${query}` : ""}`
934
+ );
935
+ },
936
+ /**
937
+ * Get follower quality analysis
938
+ *
939
+ * Measures the quality and engagement of followers.
940
+ * Shows growth metrics and engagement rates.
941
+ *
942
+ * @example
943
+ * ```typescript
944
+ * const quality = await client.insights.instagram.getFollowerQuality({ range: '30d' });
945
+ *
946
+ * if (quality.hasData) {
947
+ * console.log(`Quality: ${quality.data.qualityScore}/100`);
948
+ * console.log(`Engagement rate: ${quality.data.metrics.engagementRate}%`);
949
+ * console.log(`Growth: +${quality.data.growth.netChange} followers`);
950
+ * }
951
+ * ```
952
+ *
953
+ * GET /v1/insights/instagram/follower-quality
954
+ */
955
+ getFollowerQuality: (params) => {
956
+ const queryParams = new URLSearchParams();
957
+ if (params?.range) queryParams.set("range", params.range);
958
+ const query = queryParams.toString();
959
+ return this.client.get(
960
+ `/v1/insights/instagram/follower-quality${query ? `?${query}` : ""}`
961
+ );
962
+ },
963
+ /**
964
+ * Get account momentum
965
+ *
966
+ * Shows current account trajectory: surging, growing, stable, declining, or stalling.
967
+ * Compares recent performance to previous periods.
968
+ *
969
+ * @example
970
+ * ```typescript
971
+ * const momentum = await client.insights.instagram.getMomentum();
972
+ *
973
+ * if (momentum.hasData) {
974
+ * console.log(`Status: ${momentum.data.current.status}`);
975
+ * console.log(`Score: ${momentum.data.current.score}`);
976
+ * console.log(`vs Last Week: ${momentum.data.comparison.vsLastWeek}%`);
977
+ * }
978
+ * ```
979
+ *
980
+ * GET /v1/insights/instagram/momentum
981
+ */
982
+ getMomentum: () => {
983
+ return this.client.get("/v1/insights/instagram/momentum");
984
+ },
985
+ /**
986
+ * Get engagement breakdown
987
+ *
988
+ * Breaks down engagement by type: likes, comments, shares, saves.
989
+ * Identifies engagement style and opportunities.
990
+ *
991
+ * @example
992
+ * ```typescript
993
+ * const engagement = await client.insights.instagram.getEngagement({ range: '30d' });
994
+ *
995
+ * if (engagement.hasData) {
996
+ * console.log(`Total: ${engagement.data.totalEngagement}`);
997
+ * console.log(`Style: ${engagement.data.engagementStyle}`);
998
+ * console.log(`Likes: ${engagement.data.breakdown.likes.percent}%`);
999
+ * console.log(`Comments: ${engagement.data.breakdown.comments.percent}%`);
1000
+ * }
1001
+ * ```
1002
+ *
1003
+ * GET /v1/insights/instagram/engagement
1004
+ */
1005
+ getEngagement: (params) => {
1006
+ const queryParams = new URLSearchParams();
1007
+ if (params?.range) queryParams.set("range", params.range);
1008
+ const query = queryParams.toString();
1009
+ return this.client.get(
1010
+ `/v1/insights/instagram/engagement${query ? `?${query}` : ""}`
1011
+ );
1012
+ }
1013
+ };
730
1014
  }
731
1015
  /**
732
1016
  * Get cross-platform metrics