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